summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-27 13:11:20 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-27 13:11:20 +0200
commit30c4f72770568749b4230a6b598e3fb87a065e91 (patch)
tree8d20925b4a1903c606a06cd54edb4a4991cca55d /src/arch
parent29414b3003eafb1fd82c14893fb64805dae818b8 (diff)
msp430: Add preprocessor macro for CPU speed
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/msp430fr5969lp/Makefile.inc1
-rw-r--r--src/arch/msp430fr5969lp/driver/spi_b.cc7
2 files changed, 7 insertions, 1 deletions
diff --git a/src/arch/msp430fr5969lp/Makefile.inc b/src/arch/msp430fr5969lp/Makefile.inc
index 5512cb9..28c1cef 100644
--- a/src/arch/msp430fr5969lp/Makefile.inc
+++ b/src/arch/msp430fr5969lp/Makefile.inc
@@ -5,6 +5,7 @@ MCU = msp430fr5969
INCLUDES += -I/opt/msp430/ti/gcc/include
COMMON_FLAGS += -mcpu=${CPU} -mmcu=${MCU} -DMULTIPASS_ARCH_msp430fr5969lp
+COMMON_FLAGS += -DF_CPU=16000000UL
COMMON_FLAGS += -DMULTIPASS_ARCH_HAS_I2C
CC = /opt/msp430/ti/gcc/bin/msp430-elf-gcc
diff --git a/src/arch/msp430fr5969lp/driver/spi_b.cc b/src/arch/msp430fr5969lp/driver/spi_b.cc
index 2eb3a79..0fa71da 100644
--- a/src/arch/msp430fr5969lp/driver/spi_b.cc
+++ b/src/arch/msp430fr5969lp/driver/spi_b.cc
@@ -1,6 +1,10 @@
#include "driver/spi_b.h"
#include <msp430.h>
+#ifndef F_I2C
+#define F_I2C 1000000UL
+#endif
+
void SPI::setup()
{
UCB0CTLW0 |= UCSWRST;
@@ -22,7 +26,8 @@ void SPI::setup()
//P1REN |= BIT6;
UCB0CTLW0 = UCCKPH | UCMSB | UCMST | UCSYNC | UCMODE_0 | UCSSEL__SMCLK | UCSWRST;
- UCB0BRW = 15; // /16 -> 1MHz
+ UCB0BRW = (F_CPU/F_I2C)-1; // /16 -> 1MHz
+ // UCB0BRW = (F_CPU / F_I2C) - 1
UCB0CTLW0 &= ~UCSWRST;
}