CoX Peripheral Interface(NUC122 Implement) V2.1.1.0
API Reference
xSPI API

xSPI API Reference. More...

Collaboration diagram for xSPI API:

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.

Detailed Description

xSPI API Reference.

CoX Port Details

//! +------------------------+----------------+------------------------+
//! |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 Documentation

#define xSPIConfigSet (   ulBase,
  ulBitRate,
  ulConfig 
)

Configures the synchronous serial interface.

Parameters:
ulBasespecifies the SPI module base address.
ulBitRatespecifies the clock rate.
ulConfigis 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:

  • 0 != bit rate (master mode)

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.

Returns:
None.

Definition at line 444 of file xspi.h.

#define xSPISingleDataReadWrite (   ulBase,
  ulWData 
)

Read and write a data element from and to the SPI interface.

Parameters:
ulBasespecifies the SPI module base address.
ulWDatais 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.

Note:
Only the lower N bits of the value written to pulData contain valid data, where N is the data width as configured by SPIConfig(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to pulData contain valid data.
Returns:
the data that was received over the SPI interface.

Definition at line 472 of file xspi.h.

#define xSPIBitLengthGet (   ulBase)

Gets the number of bits transferred per frame.

Parameters:
ulBasespecifies the SPI module base address.

This function gets the number of bits transferred per frame.

Note:
if return 0 that means number of bits is 32.
Returns:
the number of bits transferred per frame.

Definition at line 488 of file xspi.h.

#define xSPIDataRead (   ulBase,
  pulRData,
  ulLen 
)

Gets a data element from the SPI interface.

Parameters:
ulBasespecifies the SPI module base address.
pulDatais a pointer to a storage location for data that was received over the SPI interface.
ulLenspecifies 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.

Note:
Only the lower N bits of the value written to pulData contain valid data, where N is the data width as configured by SPIConfig(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to pulData contain valid data.
Returns:
None.

Definition at line 513 of file xspi.h.

#define xSPIDataWrite (   ulBase,
  pulWData,
  ulLen 
)

Write datas element to the SPI interface.

Parameters:
ulBasespecifies the SPI module base address.
pulWDatais a pointer to a storage location for data that was transmitted over the SPI interface.
ulLenspecifies the length of data will be write.

This function transmitted data to the interface of the specified SPI module .

Note:
Only the lower N bits of the value written to pulData contain valid data, where N is the data width as configured by SPIConfig(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to pulData contain valid data.
Returns:
None.

Definition at line 537 of file xspi.h.

#define xSPIIntEnable (   ulBase,
  ulIntFlags 
)

Enable the SPI interrupt of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.
ulIntFlagsspecifies the type of SPI interrupt. Details please refer to xSPI Interrupts.

This function is to enable the SPI interrupt of the specified SPI port.

Returns:
None.

Definition at line 553 of file xspi.h.

#define xSPIIntCallbackInit (   ulBase,
  xtSPICallback 
)

Init interrupts callback for the specified SPI Port.

Parameters:
ulPortis the base address of the SPI port.
xtI2CCallbackis callback for the specified SPI Port.

Init interrupts callback for the specified SPI Port.

Returns:
None.

Definition at line 568 of file xspi.h.

#define xSPIIntDisable (   ulBase,
  ulIntFlags 
)

Disable the SPI interrupt of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function is to disable the SPI interrupt of the specified SPI port

Returns:
None.

Definition at line 582 of file xspi.h.

#define xSPIStatusGet (   ulBase,
  xbMasked 
)

Get the SPI interrupt flag of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.
xbMaskedis false if the raw interrupt status is required or true if the masked interrupt status is required.
Returns:
the SPI interrupt flag state, if the flag set return 0x00010000, else return 0.

Definition at line 597 of file xspi.h.

#define xSPIIsBusy (   ulBase)

Check the busy status of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function Check the busy status of the specified SPI module.

Returns:
Returns the busy status of the specified SPI port. xtrue The SPI port is in busy,or xfalse The SPI port is not in busy.

Definition at line 612 of file xspi.h.

#define xSPIIsRxEmpty (   ulBase)

Check the status of the Rx buffer of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function Check the Rx buffer status of the specified SPI module.

Note:
Only the chips with the part number NUC1x0xxxCx, ex: NUC140VE3CN, can support this function..
Returns:
Returns the Rx buffer status of the specified SPI port. xtrue The Rx buffer is empty,or xfalse The Rx buffer is not empty.

Definition at line 630 of file xspi.h.

#define xSPIIsTxEmpty (   ulBase)

Check the status of the Tx buffer of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function Check the Tx buffer status of the specified SPI module.

Note:
Only the chips with the part number NUC1x0xxxCx, ex: NUC140VE3CN, can support this function..
Returns:
Returns the Tx buffer status of the specified SPI port. xtrue The Tx buffer is in empty,or xfalse The Tx buffer is not empty.

Definition at line 648 of file xspi.h.

#define xSPIIsRxFull (   ulBase)

Check the status of the Rx buffer of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function Check the Rx buffer status of the specified SPI module.

Note:
Only the chips with the part number NUC1x0xxxCx, ex: NUC140VE3CN, can support this function..
Returns:
Returns the Rx buffer status of the specified SPI port. xtrue The Rx buffer is full,or xfalse The Rx buffer is not full.

Definition at line 666 of file xspi.h.

#define xSPIIsTxFull (   ulBase)

Check the status of the Tx buffer of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function Check the Tx buffer status of the specified SPI module.

Note:
Only the chips with the part number NUC1x0xxxCx, ex: NUC140VE3CN, can support this function..
Returns:
Returns the Tx buffer status of the specified SPI port. xtrue The Tx buffer is in full,or xfalse The Tx buffer is not full.

Definition at line 684 of file xspi.h.

#define xSPIEnable (   ulBase)

Enable the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function enable the specified SPI port.

Note:
do nothing for NUC122.
Returns:
None.

Definition at line 700 of file xspi.h.

#define xSPIDisable (   ulBase)

Disable the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.

This function disable the specified SPI port.

Note:
do nothing for NUC122.
Returns:
None.

Definition at line 715 of file xspi.h.


Function Documentation

void xSPISSSet ( unsigned long  ulBase,
unsigned long  ulSSMode,
unsigned long  ulSlaveSel 
)

Set the slave select pins of the specified SPI port.

Parameters:
ulBasespecifies the SPI module base address.
ulSSModespecifies the SS is hardware control or software control. Details please reference to xSPI Slave Select Mode.
ulSlaveSelspecifies 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.

Note:
this is only for master
Returns:
None.

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.