Contiki-NG
|
Driver for the cc2538 SPI peripheral. More...
Files | |
file | spi-arch-legacy.h |
Header file for the cc2538 SPI driver, including macros for the implementation of the low-level SPI primitives such as waiting for the TX FIFO to be ready, inserting into the TX FIFO, etc. | |
file | spi-legacy.c |
Implementation of the cc2538 SPI peripheral driver. | |
file | ssi.h |
Header file for the cc2538 Synchronous Serial Interface. | |
Arch-specific SPI functions | |
void | spix_init (uint8_t spi) |
Initialize the SPI bus for the instance given. More... | |
void | spix_enable (uint8_t spi) |
Enables the SPI peripheral for the instance given. | |
void | spix_disable (uint8_t spi) |
Disables the SPI peripheral for the instance given. More... | |
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. More... | |
void | spix_set_clock_freq (uint8_t spi, uint32_t freq) |
Sets the SPI clock frequency of the given SSI instance. More... | |
void | spix_cs_init (uint8_t port, uint8_t pin) |
Configure a GPIO to be the chip select pin. More... | |
Number of SSI instances supported by this CPU. | |
#define | SSI_INSTANCE_COUNT 2 |
Base register memory locations. | |
#define | SSI0_BASE 0x40008000 |
Base address for SSI0. | |
#define | SSI1_BASE 0x40009000 |
Base address for SSI1. | |
#define | SSI_BASE(dev) (SSI0_BASE + (dev) * (SSI1_BASE - SSI0_BASE)) |
Base address of the dev instance of the SSI. | |
Driver for the cc2538 SPI peripheral.
Register and bitmask definitions based on the Foundation Firmware from Texas Instruments.
void spix_cs_init | ( | uint8_t | port, |
uint8_t | pin | ||
) |
Configure a GPIO to be the chip select pin.
Even if this function does not depend on the SPI instance used, we rename it to reflect the new naming convention.
Definition at line 354 of file spi-legacy.c.
References GPIO_PIN_MASK, GPIO_PORT_TO_BASE, GPIO_SET_OUTPUT, GPIO_SET_PIN, GPIO_SOFTWARE_CONTROL, IOC_OVERRIDE_DIS, and ioc_set_over().
void spix_disable | ( | uint8_t | spi | ) |
Disables the SPI peripheral for the instance given.
Definition at line 286 of file spi-legacy.c.
void spix_init | ( | uint8_t | spi | ) |
Initialize the SPI bus for the instance given.
This sets the mode to Motorola SPI with the following format options: Clock phase: 1; data captured on second (rising) edge Clock polarity: 1; clock is high when idle Data size: 8 bits
Use spix_set_mode() to change the spi mode.
Definition at line 213 of file spi-legacy.c.
void spix_set_clock_freq | ( | uint8_t | spi, |
uint32_t | freq | ||
) |
Sets the SPI clock frequency of the given SSI instance.
spi | SSI instance |
freq | Frequency (Hz) |
Definition at line 323 of file spi-legacy.c.
Referenced by mmc_arch_spi_set_clock_freq().
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.
This function configures the SSI peripheral to use a particular SPI configuration that a slave device requires. It should always be called before using the SPI bus as another driver could have changed the settings.
See section 19.4.4 in the CC2538 user guide for more information.
spi | The SSI instance to use. |
frame_format | Set the SSI frame format. Use SSI_CR0_FRF_MOTOROLA, SSI_CR0_FRF_TI, or SSI_CR0_FRF_MICROWIRE. |
clock_polarity | In Motorola mode, set whether the clock is high or low when idle. Use SSI_CR0_SPO or 0. |
clock_phase | In Motorola mode, select whether data is valid on the first or second edge of the clock. Use SSI_CR0_SPH or 0. |
data_size | The number of bits in each "byte" of data. Must be between 4 and 16, inclusive. |
Definition at line 295 of file spi-legacy.c.