xSPI API Reference. More...
|
Defines | |
| #define | xSPIConfigSet(ulBase, ulBitRate, ulConfig) |
| Configures the synchronous serial interface. | |
| #define | xSPISingleDataReadWrite(ulBase, ulWData) |
| Read and write a data element from and to the SPI interface. | |
| #define | xSPIBitLengthGet(ulBase) |
| Gets the number of bits transferred per frame. | |
| #define | xSPIDataRead(ulBase, pulRData, ulLen) |
| Gets a data element from the SPI interface. | |
| #define | xSPIDataWrite(ulBase, pulWData, ulLen) |
| Write datas element to the SPI interface. | |
| #define | xSPIIntEnable(ulBase, ulIntFlags) |
| Enable the SPI interrupt of the specified SPI port. | |
| #define | xSPIIntCallbackInit(ulBase, xtSPICallback) |
| Init interrupts callback for the specified SPI Port. | |
| #define | xSPIIntDisable(ulBase, ulIntFlags) |
| Disable the SPI interrupt of the specified SPI port. | |
| #define | xSPIStatusGet(ulBase, xbMasked) |
| Get the SPI interrupt flag of the specified SPI port. | |
| #define | xSPIIsBusy(ulBase) |
| Check the busy status of the specified SPI port. | |
| #define | xSPIIsRxEmpty(ulBase) |
| Check the status of the Rx buffer of the specified SPI port. | |
| #define | xSPIIsTxEmpty(ulBase) |
| Check the status of the Tx buffer of the specified SPI port. | |
| #define | xSPIIsRxFull(ulBase) |
| Check the status of the Rx buffer of the specified SPI port. | |
| #define | xSPIIsTxFull(ulBase) |
| Check the status of the Tx buffer of the specified SPI port. | |
| #define | xSPIEnable(ulBase) |
| Enable the specified SPI port. | |
| #define | xSPIDisable(ulBase) |
| Disable the specified SPI port. | |
Functions | |
| void | xSPISSSet (unsigned long ulBase, unsigned long ulSSMode, unsigned long ulSlaveSel) |
| Set the slave select pins of the specified SPI port. | |
xSPI API Reference.
//! +------------------------+----------------+------------------------+ //! |xSPI API | CoX | NUC122 | //! |------------------------|----------------|------------------------| //! |xSPIConfigSet | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPISingleDataReadWrite | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIBitLengthGet | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIDataRead | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIDataWrite | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIntEnable | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIntCallbackInit | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIntDisable | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIStatusGet | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIsBusy | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIsRxEmpty | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIsTxEmpty | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIsRxFull | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIIsTxFull | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIEnable | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPIDisable | Mandatory | Y | //! |------------------------|----------------|------------------------| //! |xSPISSSet | Mandatory | Y | //! +------------------------+----------------+------------------------+ //!
| #define xSPIConfigSet | ( | ulBase, | |
| ulBitRate, | |||
| ulConfig | |||
| ) |
Configures the synchronous serial interface.
| ulBase | specifies the SPI module base address. |
| ulBitRate | specifies the clock rate. |
| ulConfig | is the required configuration of the SPI. Details please refer to xSPI Configure. |
This function configures the synchronous serial interface. It sets the SPI protocol, mode of operation, bit rate, and data width and the first bit.
The ulConfig parameter is the logical OR of several different values, many of which are grouped into sets where only one can be chosen.
The Protocol of SPI can be one of the following values: xSPI_MOTO_FORMAT_MODE_0, xSPI_MOTO_FORMAT_MODE_1, xSPI_MOTO_FORMAT_MODE_2, xSPI_MOTO_FORMAT_MODE_3. The Motorola frame formats imply the following polarity and phase configurations:
Polarity Phase Mode
0 0 xSPI_MOTO_FORMAT_MODE_0
0 1 xSPI_MOTO_FORMAT_MODE_1
1 0 xSPI_MOTO_FORMAT_MODE_2
1 1 xSPI_MOTO_FORMAT_MODE_3
The SPI module can operate as a master or slave; The Mode of SPI can be one of the following values: xSPI_MODE_MASTER, or xSPI_MODE_SLAVE.
The ulBitRate parameter defines the bit rate for the SPI. This bit rate must satisfy the following clock ratio criteria:
The width of the data transfers can be a value between 1 and 32, inclusive. It can be one of the following values: xSPI_DATA_WIDTH1, xSPI_DATA_WIDTH2,xSPI_DATA_WIDTH3,xSPI_DATA_WIDTH4, xSPI_DATA_WIDTH5,xSPI_DATA_WIDTH6,xSPI_DATA_WIDTH7, xSPI_DATA_WIDTH8,xSPI_DATA_WIDTH9,xSPI_DATA_WIDTH10, xSPI_DATA_WIDTH11,xSPI_DATA_WIDTH12,xSPI_DATA_WIDTH13, xSPI_DATA_WIDTH11,xSPI_DATA_WIDTH15,xSPI_DATA_WIDTH16, xSPI_DATA_WIDTH17,xSPI_DATA_WIDTH18,xSPI_DATA_WIDTH19, xSPI_DATA_WIDTH20,xSPI_DATA_WIDTH21,xSPI_DATA_WIDTH22, xSPI_DATA_WIDTH23,xSPI_DATA_WIDTH24,xSPI_DATA_WIDTH25, xSPI_DATA_WIDTH26,xSPI_DATA_WIDTH27,xSPI_DATA_WIDTH28, xSPI_DATA_WIDTH29,xSPI_DATA_WIDTH30,xSPI_DATA_WIDTH31, xSPI_DATA_WIDTH32,
The first bit of the data transfers, can be one of the following values: xSPI_MSB_FIRST, or xSPI_LSB_FIRST. Details please refer to 2. CoX Port Details.
| #define xSPISingleDataReadWrite | ( | ulBase, | |
| ulWData | |||
| ) |
Read and write a data element from and to the SPI interface.
| ulBase | specifies the SPI module base address. |
| ulWData | is the data that was transmitted over the SPI interface. |
This function send transmitted data to the SPI interface of the specified SPI module and gets received data from the SPI interface of the specified SPI module and return that data.
| #define xSPIBitLengthGet | ( | ulBase | ) |
Gets the number of bits transferred per frame.
| ulBase | specifies the SPI module base address. |
This function gets the number of bits transferred per frame.
| #define xSPIDataRead | ( | ulBase, | |
| pulRData, | |||
| ulLen | |||
| ) |
Gets a data element from the SPI interface.
| ulBase | specifies the SPI module base address. |
| pulData | is a pointer to a storage location for data that was received over the SPI interface. |
| ulLen | specifies the length of data will be read. |
This function gets received data from the interface of the specified SPI module and places that data into the location specified by the pulData parameter.
| #define xSPIDataWrite | ( | ulBase, | |
| pulWData, | |||
| ulLen | |||
| ) |
Write datas element to the SPI interface.
| ulBase | specifies the SPI module base address. |
| pulWData | is a pointer to a storage location for data that was transmitted over the SPI interface. |
| ulLen | specifies the length of data will be write. |
This function transmitted data to the interface of the specified SPI module .
| #define xSPIIntEnable | ( | ulBase, | |
| ulIntFlags | |||
| ) |
Enable the SPI interrupt of the specified SPI port.
| ulBase | specifies the SPI module base address. |
| ulIntFlags | specifies the type of SPI interrupt. Details please refer to xSPI Interrupts. |
This function is to enable the SPI interrupt of the specified SPI port.
| #define xSPIIntCallbackInit | ( | ulBase, | |
| xtSPICallback | |||
| ) |
| #define xSPIIntDisable | ( | ulBase, | |
| ulIntFlags | |||
| ) |
| #define xSPIStatusGet | ( | ulBase, | |
| xbMasked | |||
| ) |
Get the SPI interrupt flag of the specified SPI port.
| ulBase | specifies the SPI module base address. |
| xbMasked | is false if the raw interrupt status is required or true if the masked interrupt status is required. |
| #define xSPIIsBusy | ( | ulBase | ) |
Check the busy status of the specified SPI port.
| ulBase | specifies the SPI module base address. |
This function Check the busy status of the specified SPI module.
| #define xSPIIsRxEmpty | ( | ulBase | ) |
Check the status of the Rx buffer of the specified SPI port.
| ulBase | specifies the SPI module base address. |
This function Check the Rx buffer status of the specified SPI module.
| #define xSPIIsTxEmpty | ( | ulBase | ) |
Check the status of the Tx buffer of the specified SPI port.
| ulBase | specifies the SPI module base address. |
This function Check the Tx buffer status of the specified SPI module.
| #define xSPIIsRxFull | ( | ulBase | ) |
Check the status of the Rx buffer of the specified SPI port.
| ulBase | specifies the SPI module base address. |
This function Check the Rx buffer status of the specified SPI module.
| #define xSPIIsTxFull | ( | ulBase | ) |
Check the status of the Tx buffer of the specified SPI port.
| ulBase | specifies the SPI module base address. |
This function Check the Tx buffer status of the specified SPI module.
| #define xSPIEnable | ( | ulBase | ) |
| #define xSPIDisable | ( | ulBase | ) |
| void xSPISSSet | ( | unsigned long | ulBase, |
| unsigned long | ulSSMode, | ||
| unsigned long | ulSlaveSel | ||
| ) |
Set the slave select pins of the specified SPI port.
| ulBase | specifies the SPI module base address. |
| ulSSMode | specifies the SS is hardware control or software control. Details please reference to xSPI Slave Select Mode. |
| ulSlaveSel | specifies the slave select pins which will be used. Details please reference to xSPI Slave Select. |
This function is to Set the slave select pins of the specified SPI port.
The ulSSMode can be one of the following values: xSPI_SS_HARDWARE, xSPI_SS_SOFTWARE. Details please reference to 2. CoX Port Details.
The ulSlaveSel can be one of the following values: xSPI_SS_NONE, xSPI_SS0,xSPI_SS1, or xSPI_SS0_SS1. Details please reference to 2. CoX Port Details.
Definition at line 164 of file xspi.c.
References SPI0_BASE, SPI1_BASE, SPI_SS0, SPI_SS0_SS1, SPI_SS1, SPI_SS_NONE, SPI_SSR, SPI_SSR_SSR_M, xASSERT, and xHWREG.