Low-Level

group group_scb_spi_low_level_functions

Functions

__STATIC_INLINE uint32_t Cy_SCB_SPI_Read (CySCB_Type const *base)

Reads a single data element from the SPI RX FIFO.

This function does not check whether the RX FIFO has data before reading it. If the RX FIFO is empty, the function returns CY_SCB_SPI_RX_NO_DATA.

note

  • This function only reads data available in the RX FIFO. It does not initiate an SPI transfer.

  • When in the master mode, this function writes data into the TX FIFO and waits until the transfer is completed before reading data from the RX FIFO.

Return

Data from the RX FIFO. The data element size is defined by the configured RX data width.

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE uint32_t Cy_SCB_SPI_ReadArray (CySCB_Type const *base, void *buffer, uint32_t size)

Reads an array of data out of the SPI RX FIFO.

This function does not block. It returns how many data elements were read from the RX FIFO.

note

  • This function only reads data available in the RX FIFO. It does not initiate an SPI transfer.

  • When in the master mode, this function writes data into the TX FIFO and waits until the transfer is completed before reading data from the RX FIFO.

Return

The number of data elements read from the RX FIFO.

Parameters
  • base: The pointer to the SPI SCB instance.

  • buffer: The pointer to the location to place data read from the RX FIFO. The element size is defined by the data type, which depends on the configured RX data width.

  • size: The number of data elements to read from the RX FIFO.

__STATIC_INLINE uint32_t Cy_SCB_SPI_Write (CySCB_Type *base, uint32_t data)

Places a single data element in the SPI TX FIFO.

This function does not block. It returns how many data elements were placed in the TX FIFO.

note

  • When in the master mode, writing data into the TX FIFO starts an SPI transfer.

  • When in the slave mode, writing data into the TX FIFO does not start an SPI transfer. The data is loaded in the TX FIFO and will be sent to the master on its request.

  • The SPI interface is full-duplex, therefore reads and writes occur at the same time. Thus, for every data element transferred out of the TX FIFO, one is transferred into the RX FIFO.

Return

The number of data elements placed in the TX FIFO: 0 or 1.

Parameters
  • base: The pointer to the SPI SCB instance.

  • data: Data to put in the TX FIFO. The element size is defined by the data type, which depends on the configured TX data width.

__STATIC_INLINE uint32_t Cy_SCB_SPI_WriteArray (CySCB_Type *base, void *buffer, uint32_t size)

Places an array of data in the SPI TX FIFO.

This function does not block. It returns how many data elements were placed in the TX FIFO.

note

  • When in the master mode, writing data into the TX FIFO starts an SPI transfer.

  • When in the slave mode, writing data into the TX FIFO does not start an SPI transfer. The data is loaded in the TX FIFO and will be sent to the master on its request.

  • The SPI interface is full-duplex, therefore reads and writes occur at the same time. Thus, for every data element transferred out of the TX FIFO, one is transferred into the RX FIFO.

Return

The number of data elements placed in the TX FIFO.

Parameters
  • base: The pointer to the SPI SCB instance.

  • buffer: The pointer to the data to place in the TX FIFO. The element size is defined by the data type, which depends on the configured TX data width.

  • size: The number of data elements to transmit.

__STATIC_INLINE void Cy_SCB_SPI_WriteArrayBlocking (CySCB_Type *base, void *buffer, uint32_t size)

Places an array of data in the SPI TX FIFO.

This function blocks until the number of data elements specified by size is placed in the SPI TX FIFO.

note

  • When in the master mode, writing data into the TX FIFO starts an SPI transfer.

  • When in the slave mode, writing data into the TX FIFO does not start an SPI transfer. The data is loaded in the TX FIFO and will be sent to the master on its request.

  • The SPI interface is full-duplex, therefore reads and writes occur at the same time. Thus, for every data element transferred out of the TX FIFO, one is transferred into the RX FIFO.

Parameters
  • base: The pointer to the SPI SCB instance.

  • buffer: The pointer to data to place in the TX FIFO. The element size is defined by the data type, which depends on the configured TX data width.

  • size: The number of data elements to write into the TX FIFO.

__STATIC_INLINE uint32_t Cy_SCB_SPI_GetTxFifoStatus (CySCB_Type const *base)

Returns the current status of the TX FIFO.

Return

SPI TX FIFO Statuses

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE void Cy_SCB_SPI_ClearTxFifoStatus (CySCB_Type *base, uint32_t clearMask)

Clears the selected statuses of the TX FIFO.

note

Parameters
  • base: The pointer to the SPI SCB instance.

  • clearMask: The mask of which statuses to clear. See SPI TX FIFO Statuses for the set of constants.

__STATIC_INLINE uint32_t Cy_SCB_SPI_GetRxFifoStatus (CySCB_Type const *base)

Returns the current status of the RX FIFO.

Return

SPI RX FIFO Statuses

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE void Cy_SCB_SPI_ClearRxFifoStatus (CySCB_Type *base, uint32_t clearMask)

Clears the selected statuses of the RX FIFO.

note

Parameters
  • base: The pointer to the SPI SCB instance.

  • clearMask: The mask of which statuses to clear. See SPI RX FIFO Statuses for the set of constants.

__STATIC_INLINE uint32_t Cy_SCB_SPI_GetSlaveMasterStatus (CySCB_Type const *base)

Returns the current status of either the slave or the master, depending on the configured SPI mode.

Return

SPI Master and Slave Statuses

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE void Cy_SCB_SPI_ClearSlaveMasterStatus (CySCB_Type *base, uint32_t clearMask)

Clears the selected statuses of either the slave or the master.

Parameters
  • base: The pointer to the SPI SCB instance.

  • clearMask: The mask of which statuses to clear. See SPI Master and Slave Statuses for the set of constants.

__STATIC_INLINE uint32_t Cy_SCB_SPI_GetNumInTxFifo (CySCB_Type const *base)

Returns the number of data elements in the SPI TX FIFO.

note

This number does not include any data currently in the TX shifter.

Return

The number of data elements in the TX FIFO. The size of a data element defined by the configured TX data width.

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE bool Cy_SCB_SPI_IsTxComplete (CySCB_Type const *base)

Checks whether the TX FIFO and Shifter are empty and there is no more data to send.

Return

If true, transmission complete. If false, transmission is not complete.

Parameters
  • base: Pointer to the SPI SCB instance.

__STATIC_INLINE uint32_t Cy_SCB_SPI_GetNumInRxFifo (CySCB_Type const *base)

Returns the number of data elements in the SPI RX FIFO.

note

This number does not include any data currently in the RX shifter.

Return

The number of data elements in the RX FIFO. The size of a data element defined by the configured RX data width.

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE void Cy_SCB_SPI_ClearRxFifo (CySCB_Type *base)

Clears all data out of the SPI RX FIFO.

Side Effects

Any data currently in the shifter is cleared and lost.

Parameters
  • base: The pointer to the SPI SCB instance.

__STATIC_INLINE void Cy_SCB_SPI_ClearTxFifo (CySCB_Type *base)

Clears all data out of the SPI TX FIFO.

Side Effects

The TX FIFO clear operation also clears the shift register; the shifter can be cleared in the middle of a data element transfer, corrupting it. The data element corruption means that all bits that have not been transmitted are transmitted as 1s on the bus.

Parameters
  • base: The pointer to the SPI SCB instance.