G4 SPI public API.
More...
#include <stddef.h>
#include "common/phal_G4/dma/dma.h"
Go to the source code of this file.
◆ SPI_CPHA
SPI clock phase.
| Enumerator |
|---|
| SPI_CPHA_FIRST_EDGE | |
| SPI_CPHA_SECOND_EDGE | |
◆ SPI_CPOL
SPI clock polarity.
| Enumerator |
|---|
| SPI_CPOL_IDLE_LOW | |
| SPI_CPOL_IDLE_HIGH | |
◆ SPI_Mode
SPI operating mode.
| Enumerator |
|---|
| SPI_MODE_MASTER | |
| SPI_MODE_SLAVE | |
◆ PHAL_SPI_busy()
Check whether the SPI peripheral is busy.
- Parameters
-
- Returns
- true if a transfer is currently in progress.
◆ PHAL_SPI_init()
Initialize an SPI peripheral for DMA-based transfers.
Configures the SPI peripheral, initializes the associated DMA channels, and prepares the peripheral for subsequent transfers.
- Parameters
-
| handle | SPI configuration structure. |
- Returns
- true if initialization was successful, false otherwise. Only can be false if DMA initialization fails.
Initialize an SPI peripheral for DMA-based transfers.
- Parameters
-
| handle | SPI handle to configure. |
- Returns
- true
-
false
Peripheral configuration (See RM0440 42.5.7 Configuration of SPI section)
◆ PHAL_SPI_transfer()
| void PHAL_SPI_transfer |
( |
SPI_InitConfig_t * | spi, |
|
|
const uint8_t * | out_data, |
|
|
uint8_t * | in_data, |
|
|
uint32_t | data_len ) |
Start a DMA-backed SPI transfer.
Non-blocking: returns immediately after the DMA transfer has been started. If another transfer is already in progress, block until it completes before starting the new transfer.
Passing NULL for either buffer transmits or receives dummy data.
- Parameters
-
| spi | SPI configuration. |
| out_data | Transmit buffer, or NULL to transmit dummy (zero) bytes. |
| in_data | Receive buffer, or NULL to discard received bytes. |
| data_len | Number of bytes to transfer (includes both TX and RX). |
◆ PHAL_SPI_transferBlocking()
| void PHAL_SPI_transferBlocking |
( |
SPI_InitConfig_t * | spi, |
|
|
const uint8_t * | out_data, |
|
|
uint8_t * | in_data, |
|
|
uint32_t | data_len ) |
Perform a blocking DMA-backed SPI transfer. (Wrapper around PHAL_SPI_transfer.)
Blocks until the SPI peripheral is available, starts the transfer, and does not return until the transfer has completed.
Passing NULL for either buffer transmits or receives dummy data.
- Parameters
-
| spi | SPI configuration. |
| out_data | Transmit buffer, or NULL to transmit dummy (zero) bytes. |
| in_data | Receive buffer, or NULL to discard received bytes. |
| data_len | Number of bytes to transfer (includes both TX and RX). |
◆ PHAL_SPI_txCallback()
Weak callback fired when a DMA-backed SPI transfer completes.
Called after the transfer has completed and the SPI handle has been marked idle.
Default implementation does nothing.
- Parameters
-
| spi | SPI configuration that completed the transfer. |