PSoC 6 Peripheral Driver Library

General Description

Functions

cy_en_scb_spi_status_t Cy_SCB_SPI_Init (CySCB_Type *base, cy_stc_scb_spi_config_t const *config, cy_stc_scb_spi_context_t *context)
 Initializes the SCB for SPI operation. More...
 
void Cy_SCB_SPI_DeInit (CySCB_Type *base)
 De-initializes the SCB block; returns the register values to default. More...
 
__STATIC_INLINE void Cy_SCB_SPI_Enable (CySCB_Type *base)
 Enables the SCB block for the SPI operation. More...
 
void Cy_SCB_SPI_Disable (CySCB_Type *base, cy_stc_scb_spi_context_t *context)
 Disables the SCB block, clears context statuses, and disables TX and RX interrupt sources. More...
 
__STATIC_INLINE void Cy_SCB_SPI_SetActiveSlaveSelect (CySCB_Type *base, cy_en_scb_spi_slave_select_t slaveSelect)
 Selects an active slave select line from one of four available. More...
 
__STATIC_INLINE void Cy_SCB_SPI_SetActiveSlaveSelectPolarity (CySCB_Type *base, cy_en_scb_spi_slave_select_t slaveSelect, cy_en_scb_spi_polarity_t polarity)
 Sets the active polarity for the slave select line. More...
 
__STATIC_INLINE bool Cy_SCB_SPI_IsBusBusy (CySCB_Type const *base)
 Returns whether the SPI bus is busy or not. More...
 

Function Documentation

◆ Cy_SCB_SPI_Init()

cy_en_scb_spi_status_t Cy_SCB_SPI_Init ( CySCB_Type base,
cy_stc_scb_spi_config_t const *  config,
cy_stc_scb_spi_context_t context 
)

Initializes the SCB for SPI operation.

Parameters
baseThe pointer to the SPI SCB instance.
configThe pointer to the configuration structure cy_stc_scb_spi_config_t.
contextThe pointer to the context structure cy_stc_scb_spi_context_t allocated by the user. The structure is used during the SPI operation for internal configuration and data retention. The user must not modify anything in this structure. If only SPI Low-Level API will be used pass NULL as pointer to context.
Returns
cy_en_scb_spi_status_t
Note
Ensure that the SCB block is disabled before calling this function.

◆ Cy_SCB_SPI_DeInit()

void Cy_SCB_SPI_DeInit ( CySCB_Type base)

De-initializes the SCB block; returns the register values to default.

Parameters
baseThe pointer to the SPI SCB instance.
Note
Ensure that the SCB block is disabled before calling this function.

◆ Cy_SCB_SPI_Enable()

__STATIC_INLINE void Cy_SCB_SPI_Enable ( CySCB_Type base)

Enables the SCB block for the SPI operation.

Parameters
baseThe pointer to the SPI SCB instance.

◆ Cy_SCB_SPI_Disable()

void Cy_SCB_SPI_Disable ( CySCB_Type base,
cy_stc_scb_spi_context_t context 
)

Disables the SCB block, clears context statuses, and disables TX and RX interrupt sources.

Note that after the block is disabled, the TX and RX FIFOs and hardware statuses are cleared. Also, the hardware stops driving the output and ignores the input. Refer to section Low Power Support for more information about SPI pins when SCB disabled.

Parameters
baseThe pointer to the SPI SCB instance.
contextThe pointer to the context structure cy_stc_scb_spi_context_t allocated by the user. The structure is used during the SPI operation for internal configuration and data retention. The user must not modify anything in this structure. If only SPI functions that do not require context will be used to pass NULL as pointer to context.
Note
Calling this function when the SPI is busy (master preforms data transfer or slave communicates with the master) may cause transfer corruption because the hardware stops driving the outputs and ignores the inputs. Ensure that the SPI is not busy before calling this function.

◆ Cy_SCB_SPI_SetActiveSlaveSelect()

__STATIC_INLINE void Cy_SCB_SPI_SetActiveSlaveSelect ( CySCB_Type base,
cy_en_scb_spi_slave_select_t  slaveSelect 
)

Selects an active slave select line from one of four available.

This function is applicable for the master and slave.

Parameters
baseThe pointer to the SPI SCB instance.
slaveSelectThe slave select line number. See cy_en_scb_spi_slave_select_t for the set of constants.
Note
The SCB must be idle or disabled before calling this function.

◆ Cy_SCB_SPI_SetActiveSlaveSelectPolarity()

__STATIC_INLINE void Cy_SCB_SPI_SetActiveSlaveSelectPolarity ( CySCB_Type base,
cy_en_scb_spi_slave_select_t  slaveSelect,
cy_en_scb_spi_polarity_t  polarity 
)

Sets the active polarity for the slave select line.

Parameters
baseThe pointer to the SPI SCB instance.
slaveSelectThe slave select line number. See cy_en_scb_spi_slave_select_t for the set of constants.
polarityThe polarity of the slave select line. See cy_en_scb_spi_polarity_t for the set of constants.
Note
The SCB must be idle or disabled before calling this function.

◆ Cy_SCB_SPI_IsBusBusy()

__STATIC_INLINE bool Cy_SCB_SPI_IsBusBusy ( CySCB_Type const *  base)

Returns whether the SPI bus is busy or not.

The bus busy is determined using the slave select signal.

  • Motorola and National Semiconductor sub-modes: the bus is busy after the slave select line is activated and lasts until the slave select line is deactivated.
  • Texas Instrument sub-modes: The bus is busy the moment of the initial pulse on the slave select line and lasts until the transfer is complete (all bytes from the TX FIFO area shifted-out on the bus).
Parameters
baseThe pointer to the SPI SCB instance.
Returns
True - the bus is busy; false - the bus is idle.
Note
  • The SPI master does not assign the slave select line immediately after the first data element is written into the TX FIFO. It takes up to two SCLK clocks to assign the slave select line. Before this happens, the bus is considered idle.
  • If the SPI master is configured to transmit each data element separated by a de-assertion of the slave select line, the bus is busy during each element transfer and is free between them.