![]() |
EVE 1.0
|
|
Data Structures | |
| struct | spi_cs_t |
| struct | spi_state_t |
| struct | spi_t |
Macros | |
| #define | ERRATA_58 |
| #define | SPI_SYNC_FIFO_DEPTH 4 |
| #define | SPI_CS_UNINITIALIZED ((struct spi_cs_t) { .CsUnInitialized = 1 }) |
Typedefs | |
| typedef void(* | spi_async_callback_t) (const struct spi_t *Spi, void *CallbackData) |
Enumerations |
Functions called from application programs | |
| static bool struct spi_cs_t ChipSelect uint32_t Baudrate struct work_t * | Work |
| return | Ret |
| void | SpiInit (const struct spi_t *Spi) |
| Name: SpiInit Initializes SPI based on selected device. Master operation: Baudrate is limited to 0.5*peripheral clock. Slave operation: Not implemented. Called from main program level. More... | |
| void | SpiDisable (const struct spi_t *Spi) |
| Name: SpiDisable Disables SPI based on selected device. Called from main program level. More... | |
| uint8_t | SpiRead (const struct spi_t *Spi) |
| Name: SpiRead WARNING: SpiWrite() must be called prior to this function. Waits for data received in RX FIFO. More... | |
| void | SpiWrite (const struct spi_t *Spi, uint8_t DataToSend) |
| Name: SpiWrite WARNING: SpiCsEnable() must be called prior to this function. Waits for empty transmit buffer, then sends 1 byte. More... | |
| uint8_t | SpiWriteRead (const struct spi_t *Spi, uint8_t DataToSend) |
| Name: SpiWriteRead WARNING: SpiCsEnable() must be called prior to this function. Waits for empty transmit buffer, sends 1 byte and waits for data received in RX FIFO. More... | |
| void | SpiTransferAsync (const struct spi_t *Spi, const void *TxBuffer, uint32_t TxLength, void *RxBuffer, uint32_t RxLength, spi_async_callback_t Callback, void *CallbackData) |
| Name: SpiTransferAsync WARNING: SpiCsEnable() must be called prior to this function. Starts asynchronous data transfer (both transmit and receive). More... | |
| void | SpiTransferSync (const struct spi_t *Spi, const void *TxBuffer, uint32_t TxLength, void *RxBuffer, uint32_t RxLength, uint32_t Flags) |
| Name: SpiTransferSync WARNING: SpiCsEnable() must be called prior to this function. Does synchronous data transfer (both transmit and receive). More... | |
| void | SpiFlush (const struct spi_t *Spi) |
| Name: SpiFlush WARNING: SpiCsEnable() must be called prior to this function. Waits for any previously transmission to be complete, then flushes RX FIFO. More... | |
| static bool | SpiIsBusy (const struct spi_t *Spi) |
| Name: SpiIsBusy WARNING: SpiCsEnable() must be called prior to this function. Testes if transmitter is busy, i.e. if data in transmit buffer and/or shift register. More... | |
| void | SpiCsInit (struct spi_cs_t ChipSelect, uint32_t MaxBaudrate) |
| Name: SpiCsInit Initializes SPI chip select instance. Called once from main program level before first SpiCsEnable() use. More... | |
| bool | SpiCsEnable (const struct spi_t *Spi, struct spi_cs_t ChipSelect, uint32_t Baudrate) |
| Name: SpiCsEnable Enables peripheral clock for USART, updates SPI setting according to ChipSelect, and activates chip select pin. More... | |
| void | SpiCsRegisterWait (const struct spi_t *Spi, struct work_t *Work) |
| Name: SpiCsRegisterWait Registers a work to be executed when the SPI block becomes available. More... | |
| static bool | __attribute__ ((warn_unused_result)) SpiCsWait(const struct spi_t *Spi |
| Name: SpiCsWait Enables peripheral clock for USART, updates SPI setting according to ChipSelect, and activates chip select pin. More... | |
| if (!Ret) SpiCsRegisterWait(Spi | |
| void | SpiCsDisable (const struct spi_t *Spi, struct spi_cs_t ChipSelect) |
| Name: SpiCsDisable Waits for any ongoing transmission to end, flush RX FIFO, disables chip select pin and disables peripheral clock for USART. More... | |
| static bool | SpiCsIsActive (const struct spi_t *Spi, struct spi_cs_t ChipSelect) |
| Name: SpiCsIsActive Checks that the given chip select is active. More... | |
| void | SpiInterruptHandler (const struct spi_t *Spi) |
| Name: SpiInterruptHandler SPI interrupt handler Called from board.c at hardware interrupt context. More... | |
This SPI driver provides interface to the MCU's SPI blocks.
Functionality included:
Currently only master mode is supported.
| #define SPI_SYNC_FIFO_DEPTH 4 |
| #define SPI_CS_UNINITIALIZED ((struct spi_cs_t) { .CsUnInitialized = 1 }) |
| typedef void(* spi_async_callback_t) (const struct spi_t *Spi, void *CallbackData) |
| enum spi_transfer_flags_t |
| enum spi_mode_t |
| void SpiInit | ( | const struct spi_t * | Spi | ) |
Name: SpiInit
Initializes SPI based on selected device. Master operation: Baudrate is limited to 0.5*peripheral clock. Slave operation: Not implemented. Called from main program level.
| Spi | SPI parameters to be used |
| void SpiDisable | ( | const struct spi_t * | Spi | ) |
Name: SpiDisable
Disables SPI based on selected device. Called from main program level.
| Spi | SPI parameters to be used |
| uint8_t SpiRead | ( | const struct spi_t * | Spi | ) |
Name: SpiRead
WARNING: SpiWrite() must be called prior to this function. Waits for data received in RX FIFO.
| Spi | SPI to be used |
| void SpiWrite | ( | const struct spi_t * | Spi, |
| uint8_t | DataToSend | ||
| ) |
Name: SpiWrite
WARNING: SpiCsEnable() must be called prior to this function. Waits for empty transmit buffer, then sends 1 byte.
| Spi | SPI to be used |
| DataToSend | Data to be sent |
| uint8_t SpiWriteRead | ( | const struct spi_t * | Spi, |
| uint8_t | DataToSend | ||
| ) |
Name: SpiWriteRead
WARNING: SpiCsEnable() must be called prior to this function. Waits for empty transmit buffer, sends 1 byte and waits for data received in RX FIFO.
| Spi | SPI to be used |
| DataToSend | Data to be sent |
| void SpiTransferAsync | ( | const struct spi_t * | Spi, |
| const void * | TxBuffer, | ||
| uint32_t | TxLength, | ||
| void * | RxBuffer, | ||
| uint32_t | RxLength, | ||
| spi_async_callback_t | Callback, | ||
| void * | CallbackData | ||
| ) |
Name: SpiTransferAsync
WARNING: SpiCsEnable() must be called prior to this function. Starts asynchronous data transfer (both transmit and receive).
| Spi | SPI to be used |
| TxBuffer | Transmit buffer |
| TxLength | Amount of bytes to be sent |
| RxBuffer | Receive buffer |
| RxLength | Amount of bytes to be received |
| Callback | Pointer to the function to be called when transfer is finished |
| CallbackData | User-defined data for the callback |
| void SpiTransferSync | ( | const struct spi_t * | Spi, |
| const void * | TxBuffer, | ||
| uint32_t | TxLength, | ||
| void * | RxBuffer, | ||
| uint32_t | RxLength, | ||
| uint32_t | Flags | ||
| ) |
Name: SpiTransferSync
WARNING: SpiCsEnable() must be called prior to this function. Does synchronous data transfer (both transmit and receive).
| Spi | SPI to be used |
| TxBuffer | Transmit buffer |
| TxLength | Amount of bytes to be sent |
| RxBuffer | Receive buffer |
| RxLength | Amount of bytes to be received |
| Flags | Flags of the transfer, bit combination of spi_transfer_flags_t |
| void SpiFlush | ( | const struct spi_t * | Spi | ) |
Name: SpiFlush
WARNING: SpiCsEnable() must be called prior to this function. Waits for any previously transmission to be complete, then flushes RX FIFO.
| Spi | SPI to be used |
|
inlinestatic |
Name: SpiIsBusy
WARNING: SpiCsEnable() must be called prior to this function. Testes if transmitter is busy, i.e. if data in transmit buffer and/or shift register.
| Spi | SPI to be used |
Definition at line 296 of file spi.h.
References __attribute__(), spi_state_t::Busy, spi_state_t::ChipSelect, SpiCsDisable(), SpiCsEnable(), SpiCsInit(), SpiCsRegisterWait(), and spi_t::State.
| void SpiCsInit | ( | struct spi_cs_t | ChipSelect, |
| uint32_t | MaxBaudrate | ||
| ) |
Name: SpiCsInit
Initializes SPI chip select instance. Called once from main program level before first SpiCsEnable() use.
| ChipSelect | CS parameters to be used |
| MaxBaudrate | Maximal baudrate for this CS |
Referenced by SpiIsBusy().
Name: SpiCsEnable
Enables peripheral clock for USART, updates SPI setting according to ChipSelect, and activates chip select pin.
| Spi | SPI to be used |
| ChipSelect | Chip select structure |
| Baudrate | If Baudrate = 0, default baudrate is used |
Referenced by SpiIsBusy().
Name: SpiCsRegisterWait
Registers a work to be executed when the SPI block becomes available.
| Spi | SPI to be used |
| Work | The work item will be scheduled as soon as the SPI block becomes available. |
Referenced by SpiIsBusy().
|
inlinestatic |
Name: SpiCsWait
Enables peripheral clock for USART, updates SPI setting according to ChipSelect, and activates chip select pin.
| Spi | SPI to be used |
| ChipSelect | Chip select structure |
| Baudrate | If Baudrate = 0, default baudrate is used |
| Work | If SPI is already in use, the work item will be scheduled as soon as it becomes available again. |
Referenced by SpiIsBusy().
Name: SpiCsDisable
Waits for any ongoing transmission to end, flush RX FIFO, disables chip select pin and disables peripheral clock for USART.
| Spi | SPI to be used |
| ChipSelect | Chip select structure |
Referenced by SpiIsBusy().
Name: SpiCsIsActive
Checks that the given chip select is active.
| Spi | SPI to be used |
| ChipSelect | Chip select structure |
Definition at line 379 of file spi.h.
References spi_state_t::ChipSelect, SpiInterruptHandler(), and spi_t::State.
| void SpiInterruptHandler | ( | const struct spi_t * | Spi | ) |
Name: SpiInterruptHandler
SPI interrupt handler Called from board.c at hardware interrupt context.
| Spi | SPI parameters to be used |
Referenced by SpiCsIsActive().