Functions | |
void | SPIConfigSetExpClk (uint32_t ui32Base, uint32_t ui32SPIClk, uint32_t ui32Protocol, uint32_t ui32Mode, uint32_t ui32BitRate, uint32_t ui32DataWidth) |
Configures the serial peripheral port. More... | |
static void | SPIEnable (uint32_t ui32Base) |
Enables the serial peripheral port. More... | |
static void | SPIDisable (uint32_t ui32Base) |
Disables the serial peripheral port. More... | |
void | SPIDataPut (uint32_t ui32Base, uint32_t ui32Data) |
Puts a data element into the SPI transmit FIFO. More... | |
int32_t | SPIDataPutNonBlocking (uint32_t ui32Base, uint32_t ui32Data) |
Puts a data element into the SPI transmit FIFO. More... | |
void | SPIDataGet (uint32_t ui32Base, uint32_t *pui32Data) |
Gets a data element from the SPI receive FIFO. More... | |
int32_t | SPIDataGetNonBlocking (uint32_t ui32Base, uint32_t *pui32Data) |
Gets a data element from the SPI receive FIFO. More... | |
static bool | SPIBusy (uint32_t ui32Base) |
Determines whether the SPI transmitter is busy or not. More... | |
static uint32_t | SPIStatus (uint32_t ui32Base) |
Get the status of the SPI data buffers. More... | |
void | SPIIntRegister (uint32_t ui32Base, void(*pfnHandler)(void)) |
Registers an interrupt handler for the Serial Peripheral Interface in the dynamic interrupt table. More... | |
void | SPIIntUnregister (uint32_t ui32Base) |
Unregisters an interrupt handler for the Serial Peripheral Interface in the dynamic interrupt table. More... | |
static void | SPIIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags) |
Enables individual SPI interrupt sources. More... | |
static void | SPIIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags) |
Disables individual SPI interrupt sources. More... | |
static void | SPIIntClear (uint32_t ui32Base, uint32_t ui32IntFlags) |
Clears SPI interrupt sources. More... | |
static uint32_t | SPIIntStatus (uint32_t ui32Base, bool bMasked) |
Gets the current interrupt status. More... | |
static void | SPIDMAEnable (uint32_t ui32Base, uint32_t ui32DMAFlags) |
Enable SPI DMA operation. More... | |
static void | SPIDMADisable (uint32_t ui32Base, uint32_t ui32DMAFlags) |
Disable SPI DMA operation. More... | |
|
inlinestatic |
Determines whether the SPI transmitter is busy or not.
Allows the caller to determine whether all transmitted bytes have cleared the transmitter hardware. If false
is returned, then the transmit FIFO is empty and all bits of the last transmitted word have left the hardware shift register.
ui32Base | is the base address of the SPI port. |
true
: SPI is transmitting.false
: SPI transmissions are complete. void SPIConfigSetExpClk | ( | uint32_t | ui32Base, |
uint32_t | ui32SPIClk, | ||
uint32_t | ui32Protocol, | ||
uint32_t | ui32Mode, | ||
uint32_t | ui32BitRate, | ||
uint32_t | ui32DataWidth | ||
) |
Configures the serial peripheral port.
This function configures the serial peripheral port. It sets the SPI protocol, mode of operation, bit rate, and data width.
The ui32Protocol
parameter defines the data frame format. The Motorola frame formats imply the following polarity and phase configurations:
Polarity Phase Motorola Protocol Mode 0 0 3-wire SPI_FRF_MOTO_MODE_0 0 1 3-wire SPI_FRF_MOTO_MODE_1 1 0 3-wire SPI_FRF_MOTO_MODE_2 1 1 3-wire SPI_FRF_MOTO_MODE_3 0 0 4-wire SPI_FRF_MOTO_MODE_4 0 1 4-wire SPI_FRF_MOTO_MODE_5 1 0 4-wire SPI_FRF_MOTO_MODE_6 1 1 4-wire SPI_FRF_MOTO_MODE_7
The ui32Mode
parameter defines the operating mode of the SPI module. The SPI module can operate as a controller or peripheral; if a peripheral, the SPI can be configured to disable output on its serial output line.
The ui32BitRate
parameter defines the bit rate for the SPI.
The ui32DataWidth
parameter defines the width of the data transfers, and can be a value between 4 and 32, for controller mode, and 7 to 32, in peripheral mode.
ui32Base | specifies the SPI module base address. |
ui32SPIClk | is the rate of the clock supplied to the SPI module. |
ui32Protocol | specifies the data transfer protocol. The parameter can be one of the following values: |
ui32Mode | specifies the mode of operation. The parameter can be one of the following values: |
ui32BitRate | specifies the clock rate. |
ui32DataWidth | specifies number of bits transferred per frame. Must be a value between 4 and 32, for controller mode, and 7 to 32, in peripheral mode. |
void SPIDataGet | ( | uint32_t | ui32Base, |
uint32_t * | pui32Data | ||
) |
Gets a data element from the SPI receive FIFO.
This function gets received data from the receive FIFO of the specified SPI module and places that data into the location specified by the pui32Data
parameter.
pui32Data
contain valid data, where N is the data width as configured by SPIConfigSetExpClk(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to pui32Data
contain valid data.ui32Base | specifies the SPI module base address. |
pui32Data | is a pointer to a storage location for data that was received over the SPI interface. |
Referenced by SPIDisable().
int32_t SPIDataGetNonBlocking | ( | uint32_t | ui32Base, |
uint32_t * | pui32Data | ||
) |
Gets a data element from the SPI receive FIFO.
This function gets received data from the receive FIFO of the specified SPI module and places that data into the location specified by the ui32Data
parameter. If there is no data in the FIFO, then this function returns a zero.
pui32Data
contain valid data, where N is the data width as configured by SPIConfigSetExpClk(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to pui32Data
contain valid data.ui32Base | specifies the SPI module base address. |
pui32Data | is a pointer to a storage location for data that was received over the SPI interface. |
Referenced by SPIDisable().
void SPIDataPut | ( | uint32_t | ui32Base, |
uint32_t | ui32Data | ||
) |
Puts a data element into the SPI transmit FIFO.
This function places the supplied data into the transmit FIFO of the specified SPI module.
ui32Data
are discarded by the hardware, where N is the data width as configured by SPIConfigSetExpClk(). For example, if the interface is configured for 8-bit data width, the upper 24 bits of ui32Data
are discarded.ui32Base | specifies the SPI module base address. |
ui32Data | is the data to be transmitted over the SPI interface. |
Referenced by SPIDisable().
int32_t SPIDataPutNonBlocking | ( | uint32_t | ui32Base, |
uint32_t | ui32Data | ||
) |
Puts a data element into the SPI transmit FIFO.
This function places the supplied data into the transmit FIFO of the specified SPI module. If there is no space in the FIFO, then this function returns a zero.
ui32Data
are discarded by the hardware, where N is the data width as configured by SPIConfigSetExpClk(). For example, if the interface is configured for 8-bit data width, the upper 24 bits of ui32Data
are discarded.ui32Base | specifies the SPI module base address. |
ui32Data | is the data to be transmitted over the SPI interface. |
Referenced by SPIDisable().
|
inlinestatic |
Disables the serial peripheral port.
This function disables operation of the serial peripheral port.
ui32Base | specifies the SPI module base address. |
|
inlinestatic |
Disable SPI DMA operation.
This function is used to disable SPI DMA features that were enabled by SPIDMAEnable(). The specified SPI DMA features are disabled.
ui32Base | is the base address of the SPI port. |
ui32DMAFlags | is a bit mask of the DMA features to disable. The parameter is the bitwise OR of any of the following values:
|
|
inlinestatic |
Enable SPI DMA operation.
The specified SPI DMA features are enabled. The SPI can be configured to use DMA for transmit and/or receive data transfers.
ui32Base | is the base address of the SPI port. |
ui32DMAFlags | is a bit mask of the DMA features to enable. The parameter is the bitwise OR of any of the following values:
|
|
inlinestatic |
Enables the serial peripheral port.
This function enables operation of the serial peripheral port. The serial peripheral port must be configured before it is enabled.
ui32Base | specifies the SPI module base address. |
|
inlinestatic |
Clears SPI interrupt sources.
The specified SPI interrupt sources are cleared so that they no longer assert. This function must be called in the interrupt handler to keep the interrupts from being recognized again immediately upon exit.
ui32Base | specifies the SPI module base address. |
ui32IntFlags | is a bit mask of the interrupt sources to be cleared. The parameter can consist of either or both of: |
|
inlinestatic |
Disables individual SPI interrupt sources.
Disables the indicated SPI interrupt sources.
ui32Base | specifies the SPI module base address. |
ui32IntFlags | is a bit mask of the interrupt sources to be disabled. |
|
inlinestatic |
Enables individual SPI interrupt sources.
Enables the indicated SPI interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.
ui32Base | specifies the SPI module base address. |
ui32IntFlags | is a bit mask of the interrupt sources to be enabled. |
void SPIIntRegister | ( | uint32_t | ui32Base, |
void(*)(void) | pfnHandler | ||
) |
Registers an interrupt handler for the Serial Peripheral Interface in the dynamic interrupt table.
This function registers a function as the interrupt handler for a specific interrupt and enables the corresponding interrupt in the interrupt controller.
Specific SPI interrupts must be enabled via SPIIntEnable(). If necessary, it is the interrupt handler's responsibility to clear the interrupt source via SPIIntClear().
ui32Base | specifies the SPI module base address. |
pfnHandler | is a pointer to the function to be called when the serial peripheral port interrupt occurs. |
Referenced by SPIStatus().
|
inlinestatic |
Gets the current interrupt status.
This function returns the interrupt status for the SPI module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.
ui32Base | specifies the SPI module base address. |
bMasked | selects either raw or masked interrupt. false : Raw interrupt status is required. true : Masked interrupt status is required. |
void SPIIntUnregister | ( | uint32_t | ui32Base | ) |
Unregisters an interrupt handler for the Serial Peripheral Interface in the dynamic interrupt table.
This function will clear the handler to be called when a SPI interrupt occurs. This will also mask off the interrupt in the interrupt controller so that the interrupt handler no longer is called.
ui32Base | specifies the SPI module base address. |
Referenced by SPIStatus().
|
inlinestatic |
Get the status of the SPI data buffers.
This function is used to poll the status of the internal FIFOs in the SPI module. The status of both TX and RX FIFO is returned.
ui32Base | specifies the SPI module base address. |
#define SPI_BUSY SPI_STAT_BUSY_ACTIVE |
Busy.
#define SPI_DMA_DONE_RX SPI_IMASK_DMA_DONE_RX |
DMA Done 1 event for RX event mask.
#define SPI_DMA_DONE_TX SPI_IMASK_DMA_DONE_TX |
DMA Done 1 event for TX event mask.
#define SPI_DMA_RX SPI_DMACR_RXDMAE |
Enable DMA for receive.
#define SPI_DMA_TX SPI_DMACR_TXDMAE |
Enable DMA for transmit.
#define SPI_FRF_MOTO_MODE_0 |
Motorola format 3-wire, polarity 0, phase 0.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_1 |
Motorola format 3-wire, polarity 0, phase 1.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_2 |
Motorola format 3-wire, polarity 1, phase 0.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_3 |
Motorola format 3-wire, polarity 1, phase 1.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_4 |
Motorola format 4-wire, polarity 0, phase 0.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_5 |
Motorola format 4-wire, polarity 0, phase 1.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_6 |
Motorola format 4-wire, polarity 1, phase 0.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_MOTO_MODE_7 |
Motorola format 4-wire, polarity 1, phase 1.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_NMW SPI_CTL0_FRF_MIRCOWIRE |
MicroWire frame format.
Referenced by SPIConfigSetExpClk().
#define SPI_FRF_TI SPI_CTL0_FRF_TI_SYNC |
TI Sync frame format.
Referenced by SPIConfigSetExpClk().
#define SPI_IDLE SPI_IMASK_IDLE |
SPI Idle event mask.
#define SPI_MODE_CONTROLLER SPI_CTL1_MS_ENABLE |
SPI controller.
Referenced by SPIConfigSetExpClk().
#define SPI_MODE_PERIPHERAL SPI_CTL1_MS_DISABLE |
SPI peripheral.
Referenced by SPIConfigSetExpClk().
#define SPI_MODE_PERIPHERAL_OD SPI_CTL1_SOD_ENABLE |
#define SPI_PER SPI_IMASK_PER |
Parity error event mask.
#define SPI_RTOUT SPI_IMASK_RTOUT |
Enable SPI Receive Time-Out event mask.
#define SPI_RX SPI_IMASK_RX |
Receive FIFO event. This interrupt is set if the selected Receive FIFO level has been reached.
#define SPI_RX_EMPTY SPI_STAT_RFE_EMPTY |
Receive FIFO empty.
#define SPI_RX_NOT_FULL SPI_STAT_RNF_NOT_FULL |
Receive FIFO not full.
#define SPI_RXFIFO_OVF SPI_IMASK_RXFIFO_OVF |
RXFIFO overflow event mask.
#define SPI_STATUS_MASK 0x0000001F |
Mask for bits above.
Referenced by SPIStatus().
#define SPI_TX SPI_IMASK_TX |
Transmit FIFO event mask.
#define SPI_TX_EMPTY SPI_STAT_TFE_EMPTY |
Transmit FIFO empty.
#define SPI_TX_NOT_FULL SPI_STAT_TNF_NOT_FULL |
Transmit FIFO not full.
#define SPI_TXEMPTY SPI_IMASK_TXEMPTY |
Transmit FIFO Empty event mask.