summaryrefslogtreecommitdiff
path: root/src/arch/msp430fr5969lp/driver/spi_b.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/msp430fr5969lp/driver/spi_b.cc')
-rw-r--r--src/arch/msp430fr5969lp/driver/spi_b.cc7
1 files changed, 6 insertions, 1 deletions
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;
}