89 #ifdef SPI_CONF_DEFAULT_INSTANCE
90 #if SPI_CONF_DEFAULT_INSTANCE > (SSI_INSTANCE_COUNT - 1)
91 #error Invalid SPI_CONF_DEFAULT_INSTANCE: valid values are 0 and 1
93 #define SPI_DEFAULT_INSTANCE SPI_CONF_DEFAULT_INSTANCE
98 #ifdef SPI0_CONF_CPRS_CPSDVSR
99 #define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR
101 #define SPI0_CPRS_CPSDVSR 2
104 #ifdef SPI1_CONF_CPRS_CPSDVSR
105 #define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR
107 #define SPI1_CPRS_CPSDVSR 2
111 #define SPIX_WAITFORTxREADY(spi) do { \
112 while(!(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_TNF)) ; \
114 #define SPIX_BUF(spi) REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_DR)
115 #define SPIX_WAITFOREOTx(spi) do { \
116 while(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_BSY) ; \
118 #define SPIX_WAITFOREORx(spi) do { \
119 while(!(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_RNE)) ; \
121 #define SPIX_FLUSH(spi) do { \
122 while(REG(CC_CONCAT3(SSI, spi, _BASE) + SSI_SR) & SSI_SR_RNE) { \
126 #define SPIX_CS_CLR(port, pin) do { \
127 GPIO_CLR_PIN(GPIO_PORT_TO_BASE(port), GPIO_PIN_MASK(pin)); \
129 #define SPIX_CS_SET(port, pin) do { \
130 GPIO_SET_PIN(GPIO_PORT_TO_BASE(port), GPIO_PIN_MASK(pin)); \
134 #ifdef SPI_DEFAULT_INSTANCE
135 #define SPI_WAITFORTxREADY() SPIX_WAITFORTxREADY(SPI_DEFAULT_INSTANCE)
136 #define SPI_TXBUF SPIX_BUF(SPI_DEFAULT_INSTANCE)
137 #define SPI_RXBUF SPI_TXBUF
138 #define SPI_WAITFOREOTx() SPIX_WAITFOREOTx(SPI_DEFAULT_INSTANCE)
139 #define SPI_WAITFOREORx() SPIX_WAITFOREORx(SPI_DEFAULT_INSTANCE)
141 #error You must include spi-arch.h before spi.h for the CC2538
143 #define SPI_FLUSH() SPIX_FLUSH(SPI_DEFAULT_INSTANCE)
145 #define SPI_CS_CLR(port, pin) SPIX_CS_CLR(port, pin)
146 #define SPI_CS_SET(port, pin) SPIX_CS_SET(port, pin)
197 uint32_t clock_polarity, uint32_t clock_phase,
void spix_set_mode(uint8_t spi, 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 for the instance given.
void spix_init(uint8_t spi)
Initialize the SPI bus for the instance given.
void spix_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 spix_disable(uint8_t spi)
Disables the SPI peripheral for the instance given.
void spix_enable(uint8_t spi)
Enables the SPI peripheral for the instance given.