Synergy Software Package User's Manual

Driver for the Simple SPI on SCI. More...

Data Structures

struct  sci_spi_instance_ctrl_t
 
struct  sci_spi_extended_cfg
 

Functions

ssp_err_t R_SCI_SPI_Open (spi_ctrl_t *p_api_ctrl, spi_cfg_t const *const p_cfg)
 Initialize a channel for SPI communication mode. Implements spi_api_t::open. This function performs the following tasks: Performs parameter checking and processes error conditions. Applies power to the SPI channel. Disables interrupts. Initializes the associated registers with default value and the user-configurable options. Provides the channel handle for use with other API functions. Updates user-configurable file if necessary. More...
 
ssp_err_t R_SCI_SPI_Read (spi_ctrl_t *const p_api_ctrl, void const *p_dest, uint32_t const length, spi_bit_width_t const bit_width)
 Receive data from an SPI device. Implements spi_api_t::read. The function performs the following tasks: More...
 
ssp_err_t R_SCI_SPI_Write (spi_ctrl_t *const p_api_ctrl, void const *p_src, uint32_t const length, spi_bit_width_t const bit_width)
 Transmit data to a SPI device. Implements spi_api_t::write. More...
 
ssp_err_t R_SCI_SPI_WriteRead (spi_ctrl_t *const p_api_ctrl, void const *p_src, void const *p_dest, uint32_t const length, spi_bit_width_t const bit_width)
 Simultaneously transmit data to SPI device while receiving data from SPI device (full duplex). Implements spi_api_t::writeRead. The function performs the following tasks: More...
 
ssp_err_t R_SCI_SPI_Close (spi_ctrl_t *const p_api_ctrl)
 Handle the closing of a channel by the following task. Implements spi_api_t::close Power off the channel. Disables all the associated interrupts. Update channel status. More...
 
ssp_err_t R_SCI_SPI_VersionGet (ssp_version_t *p_version)
 Get the version information of the underlying driver. Implements spi_api_t::versionGet. More...
 

Variables

const spi_api_t g_spi_on_sci
 

Detailed Description

Driver for the Simple SPI on SCI.

This module supports simple SPI serial communication using the microcontroller's SCI peripheral. The Interface is defined in r_spi_api.h. This module implements SPI Interface.

Function Documentation

◆ R_SCI_SPI_Close()

ssp_err_t R_SCI_SPI_Close ( spi_ctrl_t *const  p_api_ctrl)

Handle the closing of a channel by the following task. Implements spi_api_t::close Power off the channel. Disables all the associated interrupts. Update channel status.

Return values
SSP_SUCCESSChannel successfully closed.
SSP_ERR_ASSERTIONThe parameter p_api_ctrl is NULL.
SSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.
Note
This function is reentrant.

Check to see if the channel is currently initialized.

Turn off power.

Close transfer block.

Release lock for this channel.

◆ R_SCI_SPI_Open()

ssp_err_t R_SCI_SPI_Open ( spi_ctrl_t p_api_ctrl,
spi_cfg_t const *const  p_cfg 
)

Initialize a channel for SPI communication mode. Implements spi_api_t::open. This function performs the following tasks: Performs parameter checking and processes error conditions. Applies power to the SPI channel. Disables interrupts. Initializes the associated registers with default value and the user-configurable options. Provides the channel handle for use with other API functions. Updates user-configurable file if necessary.

Return values
SSP_SUCCESSChannel initialized successfully.
SSP_ERR_ASSERTIONOne of the following invalid parameter passed.
  • Pointer p_api_ctrl is NULL
  • Pointer p_cfg is NULL
SSP_ERR_IN_USEChannel currently in operation; Close channel first.
SSP_ERR_HW_LOCKEDThe lock could not be acquired. The channel is busy.

See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Note
This function is reentrant.
The bit-rate argument in p_cfg ranges from 2500 to 7.5m for Simple SPI at PCLK=120 MHz. For RSPI, BRDV is fixed at 0 to get the maximum bit rate. The range is 10.0 mbps to 30.0 mbps at PCLK=120.0 MHz.

Attempt to acquire lock for this SCI SPI channel. Prevents re-entrancy conflict.

set valid interrupts with user provided priority.

Turn on power.

Don't use FIFO mode – set FCRL_b.FM = 0.

Select SPI mode - set SCMR.SMIF=0, SIMR1.IICM=0, SMR.CM=1, SPMR.SSE=1.

Set baud rate in SCI channel for the SPI channel.

Open the SCI SPI transfer interface if available.

Peripheral Initialized.

Set control block for SCI channel to SPI mode operation.

◆ R_SCI_SPI_Read()

ssp_err_t R_SCI_SPI_Read ( spi_ctrl_t *const  p_api_ctrl,
void const *  p_dest,
uint32_t const  length,
spi_bit_width_t const  bit_width 
)

Receive data from an SPI device. Implements spi_api_t::read. The function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Disable Interrupts.
  • Set-up data bit width per user request.
  • Enable transmitter.
  • Enable receiver.
  • Enable interrupts.
  • Start data transmission with dummy data via transmit buffer empty interrupt.
  • Copy data from source buffer to the SPI data register for transmission.
  • Receive data from receive buffer full interrupt occurs and copy data to the buffer of destination.
  • Complete data reception via receive buffer full interrupt and transmitting dummy data.
  • Disable transmitter.
  • Disable receiver.
  • Disable interrupts.
Return values
SSP_SUCCESSRead operation successfully completed.
SSP_ERR_ASSERTIONOne of the following invalid parameters passed
  • Pointer p_api_ctrl is NULL
  • Bit width is not 8 bits
  • Length is equal to 0
  • Pointer to destination is NULL
SSP_ERR_HW_LOCKEDThe lock could not be acquired. The channel is busy.
SSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.

See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Configure module to receive data from a SPI device.

◆ R_SCI_SPI_VersionGet()

ssp_err_t R_SCI_SPI_VersionGet ( ssp_version_t p_version)

Get the version information of the underlying driver. Implements spi_api_t::versionGet.

Return values
SSP_SUCCESSSuccessful version get.
SSP_ERR_ASSERTIONThe parameter p_version is NULL.
Note
This function is reentrant.

◆ R_SCI_SPI_Write()

ssp_err_t R_SCI_SPI_Write ( spi_ctrl_t *const  p_api_ctrl,
void const *  p_src,
uint32_t const  length,
spi_bit_width_t const  bit_width 
)

Transmit data to a SPI device. Implements spi_api_t::write.

  • The function performs the following tasks:
  • Performs parameter checking and processes error conditions.
  • Disable Interrupts.
  • Setup data bit width per user request.
  • Enable transmitter.
  • Enable receiver.
  • Enable interrupts.
  • Start data transmission with data via transmit buffer empty interrupt.
  • Copy data from source buffer to the SPI data register for transmission.
  • Receive data from receive buffer full interrupt occurs and do nothing with the received data.
  • Complete data transmission via receive buffer full interrupt.
  • Disable transmitter.
  • Disable receiver.
  • Disable interrupts.
Return values
SSP_SUCCESSWrite operation successfully completed.
SSP_ERR_ASSERTIONOne of the following invalid parameters passed
  • Pointer p_api_ctrl is NULL
  • Pointer to source is NULL
  • Length is equal to 0
  • Bit width is not equal to 8 bits
SSP_ERR_HW_LOCKEDThe lock could not be acquired. The channel is busy.
SSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.

See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Configure module to transmit data to a SPI device.

◆ R_SCI_SPI_WriteRead()

ssp_err_t R_SCI_SPI_WriteRead ( spi_ctrl_t *const  p_api_ctrl,
void const *  p_src,
void const *  p_dest,
uint32_t const  length,
spi_bit_width_t const  bit_width 
)

Simultaneously transmit data to SPI device while receiving data from SPI device (full duplex). Implements spi_api_t::writeRead. The function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Disable Interrupts.
  • Setup data bit width per user request.
  • Enable transmitter.
  • Enable receiver.
  • Enable interrupts.
  • Start data transmission using transmit buffer empty interrupt.
  • Copy data from source buffer to the SPI data register for transmission.
  • Receive data from receive buffer full interrupt occurs and copy data to the buffer of destination.
  • Complete data transmission and reception via receive buffer full interrupt.
  • Disable transmitter.
  • Disable receiver.
  • Disable interrupts.
Return values
SSP_SUCCESSWrite operation successfully completed.
SSP_ERR_ASSERTIONOne of the following invalid parameters passed
  • Pointer p_api_ctrl is NULL
  • Pointer to source is NULL
  • Pointer to destination is NULL
  • Length is equal to 0
  • Bit width is not equal to 8 bits
SSP_ERR_HW_LOCKEDThe lock could not be acquired. The channel is busy.
SSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.

See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Configure module for full duplex operation.

Variable Documentation

◆ g_spi_on_sci

const spi_api_t g_spi_on_sci

Filled in Interface API structure for this Instance.