CC23x0R5DriverLibrary
|
Functions | |
void | SPIConfigSetExpClk (uint32_t base, uint32_t spiClk, uint32_t protocol, uint32_t mode, uint32_t bitRate, uint32_t dataWidth) |
Configures the serial peripheral port. More... | |
__STATIC_INLINE void | SPIEnable (uint32_t base) |
Enables the serial peripheral port. More... | |
__STATIC_INLINE void | SPIDisable (uint32_t base) |
Disables the serial peripheral port. More... | |
void | SPIPutData (uint32_t base, uint32_t data) |
Puts a data element into the SPI transmit FIFO. More... | |
int32_t | SPIPutDataNonBlocking (uint32_t base, uint32_t data) |
Puts a data element into the SPI transmit FIFO. More... | |
void | SPIGetData (uint32_t base, uint32_t *data) |
Gets a data element from the SPI receive FIFO. More... | |
int32_t | SPIGetDataNonBlocking (uint32_t base, uint32_t *data) |
Gets a data element from the SPI receive FIFO. More... | |
__STATIC_INLINE bool | SPIBusy (uint32_t base) |
Determines whether the SPI transmitter is busy or not. More... | |
__STATIC_INLINE uint32_t | SPIStatus (uint32_t base) |
Get the status of the SPI data buffers. More... | |
void | SPIRegisterInt (uint32_t base, void(*pfnHandler)(void)) |
Registers an interrupt handler for the Serial Peripheral Interface in the dynamic interrupt table. More... | |
void | SPIUnregisterInt (uint32_t base) |
Unregisters an interrupt handler for the Serial Peripheral Interface in the dynamic interrupt table. More... | |
__STATIC_INLINE void | SPIEnableInt (uint32_t base, uint32_t intFlags) |
Enables individual SPI interrupt sources. More... | |
__STATIC_INLINE void | SPIDisableInt (uint32_t base, uint32_t intFlags) |
Disables individual SPI interrupt sources. More... | |
__STATIC_INLINE void | SPIClearInt (uint32_t base, uint32_t intFlags) |
Clears SPI interrupt sources. More... | |
__STATIC_INLINE uint32_t | SPIIntStatus (uint32_t base, bool isMasked) |
Gets the current interrupt status. More... | |
__STATIC_INLINE void | SPIEnableDMA (uint32_t base, uint32_t dmaFlags) |
Enable SPI DMA operation. More... | |
__STATIC_INLINE void | SPIDisableDMA (uint32_t base, uint32_t dmaFlags) |
Disable SPI DMA operation. More... | |
#define SPI_DMA_DONE_TX SPI_IMASK_DMATX |
DMA Done 1 event for TX event mask.
#define SPI_DMA_DONE_RX SPI_IMASK_DMARX |
DMA Done 1 event for RX event mask.
#define SPI_IDLE SPI_IMASK_IDLE |
SPI Idle event mask.
#define SPI_TXEMPTY SPI_IMASK_TXEMPTY |
Transmit FIFO Empty event mask.
#define SPI_TX SPI_IMASK_TX |
Transmit FIFO 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_RTOUT SPI_IMASK_RTOUT |
Enable SPI Receive Time-Out event mask.
#define SPI_PER SPI_IMASK_PER |
Parity error event mask.
#define SPI_RXFIFO_OVF SPI_IMASK_RXOVF |
RXFIFO overflow event mask.
#define SPI_BUSY SPI_STA_BUSY_ACTIVE |
Busy.
#define SPI_RX_NOT_FULL SPI_STA_RNF_NOT_FULL |
Receive FIFO not full.
#define SPI_RX_EMPTY SPI_STA_RFE_EMPTY |
Receive FIFO empty.
#define SPI_TX_NOT_FULL SPI_STA_TNF_NOT_FULL |
Transmit FIFO not full.
#define SPI_TX_EMPTY SPI_STA_TFE_EMPTY |
Transmit FIFO empty.
#define SPI_STATUS_MASK 0x0000001F |
Mask for bits above.
Referenced by SPIStatus().
#define SPI_FRF_MOTO_MODE_0 (SPI_CTL0_FRF_MOTOROLA_3WIRE | SPI_CTL0_SPO_LO | SPI_CTL0_SPH_FIRST) |
Motorola format 3-wire, polarity 0, phase 0.
#define SPI_FRF_MOTO_MODE_1 (SPI_CTL0_FRF_MOTOROLA_3WIRE | SPI_CTL0_SPO_LO | SPI_CTL0_SPH_SECOND) |
Motorola format 3-wire, polarity 0, phase 1.
#define SPI_FRF_MOTO_MODE_2 (SPI_CTL0_FRF_MOTOROLA_3WIRE | SPI_CTL0_SPO_HI | SPI_CTL0_SPH_FIRST) |
Motorola format 3-wire, polarity 1, phase 0.
#define SPI_FRF_MOTO_MODE_3 (SPI_CTL0_FRF_MOTOROLA_3WIRE | SPI_CTL0_SPO_HI | SPI_CTL0_SPH_SECOND) |
Motorola format 3-wire, polarity 1, phase 1.
#define SPI_FRF_MOTO_MODE_4 (SPI_CTL0_FRF_MOTOROLA_4WIRE | SPI_CTL0_SPO_LO | SPI_CTL0_SPH_FIRST) |
Motorola format 4-wire, polarity 0, phase 0.
#define SPI_FRF_MOTO_MODE_5 (SPI_CTL0_FRF_MOTOROLA_4WIRE | SPI_CTL0_SPO_LO | SPI_CTL0_SPH_SECOND) |
Motorola format 4-wire, polarity 0, phase 1.
#define SPI_FRF_MOTO_MODE_6 (SPI_CTL0_FRF_MOTOROLA_4WIRE | SPI_CTL0_SPO_HI | SPI_CTL0_SPH_FIRST) |
Motorola format 4-wire, polarity 1, phase 0.
#define SPI_FRF_MOTO_MODE_7 (SPI_CTL0_FRF_MOTOROLA_4WIRE | SPI_CTL0_SPO_HI | SPI_CTL0_SPH_SECOND) |
Motorola format 4-wire, polarity 1, phase 1.
#define SPI_FRF_TI SPI_CTL0_FRF_TI_SYNC |
TI Sync frame format.
#define SPI_FRF_NMW SPI_CTL0_FRF_MIRCOWIRE |
MicroWire frame format.
#define SPI_MODE_CONTROLLER SPI_CTL1_MS_CONTROLLER |
SPI controller.
#define SPI_MODE_PERIPHERAL SPI_CTL1_MS_PERIPHERAL |
SPI peripheral.
#define SPI_MODE_PERIPHERAL_OD SPI_CTL1_SOD_ENABLE |
output disabled
SPI peripheral with POCI
#define SPI_DMA_TX SPI_DMACR_TXEN |
Enable DMA for transmit.
#define SPI_DMA_RX SPI_DMACR_RXEN |
Enable DMA for receive.
void SPIConfigSetExpClk | ( | uint32_t | base, |
uint32_t | spiClk, | ||
uint32_t | protocol, | ||
uint32_t | mode, | ||
uint32_t | bitRate, | ||
uint32_t | dataWidth | ||
) |
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 protocol
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 mode
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 bitRate
parameter defines the bit rate for the SPI.
The dataWidth
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.
base | specifies the SPI module base address. |
spiClk | is the rate of the clock supplied to the SPI module. |
protocol | specifies the data transfer protocol. The parameter can be one of the following values: |
mode | specifies the mode of operation. The parameter can be one of the following values: |
bitRate | specifies the clock rate. |
dataWidth | specifies number of bits transferred per frame. Must be a value between 4 and 16 for controller mode, and 7 to 16 in peripheral mode. |
References ASSERT, DSAMPLE_HIGH_BITRATE, DSAMPLE_MED_BITRATE, SPI_CLKCFG1_DSAMPLE_S, and SPIConfig().
__STATIC_INLINE void SPIEnable | ( | uint32_t | base | ) |
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.
base | specifies the SPI module base address. |
References ASSERT, HWREG, SPI_CTL1_EN_EN, and SPI_O_CTL1.
__STATIC_INLINE void SPIDisable | ( | uint32_t | base | ) |
Disables the serial peripheral port.
This function disables operation of the serial peripheral port.
base | specifies the SPI module base address. |
References ASSERT, HWREG, SPI_CTL1_EN_EN, SPI_O_CTL1, SPIGetData(), SPIGetDataNonBlocking(), SPIPutData(), and SPIPutDataNonBlocking().
void SPIPutData | ( | uint32_t | base, |
uint32_t | data | ||
) |
Puts a data element into the SPI transmit FIFO.
This function places the supplied data into the transmit FIFO of the specified SPI module.
data
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 data
are discarded.base | specifies the SPI module base address. |
data | is the data to be transmitted over the SPI interface. |
References ASSERT, HWREG, SPI_O_STA, SPI_O_TXDATA, and SPI_STA_TNF_NOT_FULL.
Referenced by SPIDisable().
int32_t SPIPutDataNonBlocking | ( | uint32_t | base, |
uint32_t | data | ||
) |
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.
data
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 data
are discarded.base | specifies the SPI module base address. |
data | is the data to be transmitted over the SPI interface. |
References ASSERT, HWREG, SPI_O_STA, SPI_O_TXDATA, and SPI_STA_TNF_NOT_FULL.
Referenced by SPIDisable().
void SPIGetData | ( | uint32_t | base, |
uint32_t * | data | ||
) |
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 data
parameter.
data
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 data
contain valid data.base | specifies the SPI module base address. |
data | is a pointer to a storage location for data that was received over the SPI interface. |
References ASSERT, HWREG, SPI_O_RXDATA, SPI_O_STA, and SPI_STA_RFE_EMPTY.
Referenced by SPIDisable().
int32_t SPIGetDataNonBlocking | ( | uint32_t | base, |
uint32_t * | data | ||
) |
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 data
parameter. If there is no data in the FIFO, then this function returns a zero.
data
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 data
contain valid data.base | specifies the SPI module base address. |
data | is a pointer to a storage location for data that was received over the SPI interface. |
References ASSERT, HWREG, SPI_O_RXDATA, SPI_O_STA, and SPI_STA_RFE_EMPTY.
Referenced by SPIDisable().
__STATIC_INLINE bool SPIBusy | ( | uint32_t | base | ) |
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.
base | is the base address of the SPI port. |
true
: SPI is transmitting.false
: SPI transmissions are complete. References ASSERT, HWREG, SPI_O_STA, and SPI_STA_BUSY.
__STATIC_INLINE uint32_t SPIStatus | ( | uint32_t | base | ) |
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.
base | specifies the SPI module base address. |
References ASSERT, HWREG, SPI_O_STA, SPI_STATUS_MASK, SPIRegisterInt(), and SPIUnregisterInt().
void SPIRegisterInt | ( | uint32_t | base, |
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 SPIEnableInt(). If necessary, it is the interrupt handler's responsibility to clear the interrupt source via SPIClearInt().
base | specifies the SPI module base address. |
pfnHandler | is a pointer to the function to be called when the serial peripheral port interrupt occurs. |
References ASSERT, INT_SPI0_COMB, IntEnable(), and IntRegister().
Referenced by SPIStatus().
void SPIUnregisterInt | ( | uint32_t | base | ) |
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.
base | specifies the SPI module base address. |
References ASSERT, INT_SPI0_COMB, IntDisable(), and IntUnregister().
Referenced by SPIStatus().
__STATIC_INLINE void SPIEnableInt | ( | uint32_t | base, |
uint32_t | intFlags | ||
) |
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.
base | specifies the SPI module base address. |
intFlags | is a bit mask of the interrupt sources to be enabled. |
References ASSERT, HWREG, and SPI_O_IMASK.
__STATIC_INLINE void SPIDisableInt | ( | uint32_t | base, |
uint32_t | intFlags | ||
) |
Disables individual SPI interrupt sources.
Disables the indicated SPI interrupt sources.
base | specifies the SPI module base address. |
intFlags | is a bit mask of the interrupt sources to be disabled. |
References ASSERT, HWREG, and SPI_O_IMASK.
__STATIC_INLINE void SPIClearInt | ( | uint32_t | base, |
uint32_t | intFlags | ||
) |
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.
base | specifies the SPI module base address. |
intFlags | is a bit mask of the interrupt sources to be cleared. The parameter can consist of either or both of: |
References ASSERT, HWREG, and SPI_O_ICLR.
__STATIC_INLINE uint32_t SPIIntStatus | ( | uint32_t | base, |
bool | isMasked | ||
) |
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.
base | specifies the SPI module base address. |
isMasked | selects either raw or masked interrupt. false : Raw interrupt status is required. true : Masked interrupt status is required. |
__STATIC_INLINE void SPIEnableDMA | ( | uint32_t | base, |
uint32_t | dmaFlags | ||
) |
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.
base | is the base address of the SPI port. |
dmaFlags | is a bit mask of the DMA features to enable. The parameter is the bitwise OR of any of the following values:
|
References ASSERT, HWREG, and SPI_O_DMACR.
__STATIC_INLINE void SPIDisableDMA | ( | uint32_t | base, |
uint32_t | dmaFlags | ||
) |
Disable SPI DMA operation.
This function is used to disable SPI DMA features that were enabled by SPIEnableDMA(). The specified SPI DMA features are disabled.
base | is the base address of the SPI port. |
dmaFlags | is a bit mask of the DMA features to disable. The parameter is the bitwise OR of any of the following values:
|
References ASSERT, HWREG, and SPI_O_DMACR.