General

group group_scb_spi_general_functions

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.

note

If SCB is already enabled, ensure that the SCB block is disabled Cy_SCB_SPI_Disable before calling this function.

Return

cy_en_scb_spi_status_t

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

  • config: The pointer to the configuration structure cy_stc_scb_spi_config_t.

  • context: The 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.

void Cy_SCB_SPI_DeInit(CySCB_Type *base)

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

note

Ensure that the SCB block is disabled Cy_SCB_SPI_Disable before calling this function.

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

__STATIC_INLINE void Cy_SCB_SPI_Enable (CySCB_Type *base)

Enables the SCB block for the SPI operation.

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

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.

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.

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

  • context: The 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.

__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.

note

The SCB must be idle or disabled before calling this function.

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

  • slaveSelect: The slave select line number. See cy_en_scb_spi_slave_select_t for the set of constants.

__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.

note

The SCB must be idle or disabled before calling this function.

Parameters

__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).

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.

Return

True - the bus is busy; false - the bus is idle.

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