46 #define SPI_WAITFORTxREADY() do { \
47 while(!(REG(SSI0_BASE + SSI_SR) & SSI_SR_TNF)); \
50 #define SPI_TXBUF REG(SSI0_BASE + SSI_DR)
52 #define SPI_RXBUF REG(SSI0_BASE + SSI_DR)
54 #define SPI_WAITFOREOTx() do { \
55 while(REG(SSI0_BASE + SSI_SR) & SSI_SR_BSY); \
58 #define SPI_WAITFOREORx() do { \
59 while(!(REG(SSI0_BASE + SSI_SR) & SSI_SR_RNE)); \
63 #error "You must include spi-arch.h before spi.h for the CC2538."
65 #define SPI_FLUSH() do { \
67 while (REG(SSI0_BASE + SSI_SR) & SSI_SR_RNE) { \
72 #define SPI_CS_CLR(port, pin) do { \
73 GPIO_CLR_PIN(GPIO_PORT_TO_BASE(port), GPIO_PIN_MASK(pin)); \
76 #define SPI_CS_SET(port, pin) do { \
77 GPIO_SET_PIN(GPIO_PORT_TO_BASE(port), GPIO_PIN_MASK(pin)); \
116 void spi_set_mode(uint32_t frame_format, uint32_t clock_polarity,
117 uint32_t clock_phase, uint32_t data_size);
void spi_cs_init(uint8_t port, uint8_t pin)
Configure a GPIO to be the chip select pin.
Header file for the cc2538 Synchronous Serial Interface.
void spi_enable(void)
Enables the SPI peripheral.
void spi_set_mode(uint32_t frame_format, uint32_t clock_polarity, uint32_t clock_phase, uint32_t data_size)
Configure the SPI data and clock polarity and the data size.
void spi_disable(void)
Disables the SPI peripheral.