Commit 30c4f727 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

msp430: Add preprocessor macro for CPU speed

parent 29414b30
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+6 −1
Original line number Diff line number Diff line
#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;
}