From 30c4f72770568749b4230a6b598e3fb87a065e91 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 27 Aug 2018 13:11:20 +0200 Subject: msp430: Add preprocessor macro for CPU speed --- src/arch/msp430fr5969lp/driver/spi_b.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/arch/msp430fr5969lp/driver') 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 +#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; } -- cgit v1.2.3