Hi,
I'm trying to use CC2538 as a SPI Slave. I've been looking for the foundation firmware but there is no success. Could someone point me the right direction?
What I did was the following:
4 void spi_slave_init(){
5 /* Enable the clock for the SSI peripheral */
6 REG(SYS_CTRL_RCGCSSI) |= 1;
7
8 /* Start by disabling the peripheral before configuring it */
9 REG(SSI0_BASE + SSI_CR1) = 0;
10
11 /* Set to Spi Slave */
12 REG(SSI0_BASE + SSI_CR1) |= SSI_CR1_MS_M;
13
14 /* Set the IO clock as the SSI clock */
15 REG(SSI0_BASE + SSI_CC) = 1;
16
17 /* Set the mux correctly to connect the SSI pins to the correct GPIO pins */
18 ioc_set_sel(SPI_MISO_PORT, SPI_MISO_PIN, IOC_PXX_SEL_SSI0_TXD);
19 REG(IOC_CLK_SSIIN_SSI0) = (SPI_CLK_PORT<<3) + SPI_CLK_PIN;
20 REG(IOC_SSIRXD_SSI0) = (SPI_MOSI_PORT<<3) + SPI_MOSI_PIN;
21 REG(IOC_SSIFSSIN_SSI0) = (SPI_CS_PORT<<3) + SPI_CS_PIN;
22
23 /* Put all the SSI gpios into peripheral mode */
24 GPIO_PERIPHERAL_CONTROL(SPI_CLK_PORT_BASE, SPI_CLK_PIN_MASK);
25 GPIO_PERIPHERAL_CONTROL(SPI_MOSI_PORT_BASE, SPI_MOSI_PIN_MASK);
26 GPIO_PERIPHERAL_CONTROL(SPI_MISO_PORT_BASE, SPI_MISO_PIN_MASK);
27 GPIO_PERIPHERAL_CONTROL(SPI_CS_PORT_BASE, SPI_CS_PIN_MASK);
28
29 /* Disable any pull ups or the like */
30 ioc_set_over(SPI_CLK_PORT, SPI_CLK_PIN, IOC_OVERRIDE_DIS);
31 ioc_set_over(SPI_MOSI_PORT, SPI_MOSI_PIN, IOC_OVERRIDE_DIS);
32 ioc_set_over(SPI_CS_PORT, SPI_CS_PIN, IOC_OVERRIDE_DIS);
33
34 /* Configure the clock */
35 REG(SSI0_BASE + SSI_CPSR) = 8;
36
37 /* Configure the default SPI options.
38 * mode: Motorola frame format
39 * clock: High when idle
40 * data: Valid on rising edges of the clock
41 * bits: 8 byte data
42 */
43 REG(SSI0_BASE + SSI_CR0) = SSI_CR0_SPH | SSI_CR0_SPO | (0x07);
44
45 /* Enable the SSI */
46 REG(SSI0_BASE + SSI_CR1) |= SSI_CR1_SSE;
47 }
I'm pulling the SSI SR register to see if the RX fifo is empty, but it's always empty no matter how.
Thanks for any help!
Ye-Sheng