RZA Flexible Software Package Documentation  Release v1.1.0

 
Renesas Serial Peripheral Interface (r_rspi)

Functions

fsp_err_t R_RSPI_Open (spi_ctrl_t *p_api_ctrl, spi_cfg_t const *const p_cfg)
 
fsp_err_t R_RSPI_Read (spi_ctrl_t *const p_api_ctrl, void *p_dest, uint32_t const length, spi_bit_width_t const bit_width)
 
fsp_err_t R_RSPI_Write (spi_ctrl_t *const p_api_ctrl, void const *p_src, uint32_t const length, spi_bit_width_t const bit_width)
 
fsp_err_t R_RSPI_WriteRead (spi_ctrl_t *const p_api_ctrl, void const *p_src, void *p_dest, uint32_t const length, spi_bit_width_t const bit_width)
 
fsp_err_t R_RSPI_Close (spi_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_RSPI_CalculateBitrate (uint32_t bitrate, rspi_rspck_div_setting_t *spck_div)
 
fsp_err_t R_RSPI_CallbackSet (spi_ctrl_t *const p_api_ctrl, void(*p_callback)(spi_callback_args_t *), void const *const p_context, spi_callback_args_t *const p_callback_memory)
 

Detailed Description

Driver for the RSPI peripheral on RZ MPUs. This module implements the SPI Interface.

Data Structures

struct  rspi_rspck_div_setting_t
 
struct  rspi_extended_cfg_t
 
struct  rspi_instance_ctrl_t
 

Enumerations

enum  rspi_ssl_polarity_t
 
enum  rspi_mosi_idle_value_fixing_t
 
enum  rspi_delay_count_t
 
enum  rspi_tx_trigger_level_t
 
enum  rspi_rx_trigger_level_t
 

Data Structure Documentation

◆ rspi_rspck_div_setting_t

struct rspi_rspck_div_setting_t

RSPI Clock Divider settings.

Data Fields
uint8_t spbr SPBR register setting.
uint8_t brdv: 2 BRDV setting in SPCMD0.

◆ rspi_extended_cfg_t

struct rspi_extended_cfg_t

Extended RSPI interface configuration

Data Fields
rspi_ssl_polarity_t ssl_polarity Select SSLn signal polarity.
rspi_mosi_idle_value_fixing_t mosi_idle Select MOSI idle fixed value and selection.
rspi_rspck_div_setting_t spck_div Register values for configuring the RSPI Clock Divider.
rspi_delay_count_t spck_delay SPI Clock Delay Register Setting.
rspi_delay_count_t ssl_negation_delay SPI Slave Select Negation Delay Register Setting.
rspi_delay_count_t next_access_delay SPI Next-Access Delay Register Setting.
rspi_rx_trigger_level_t rx_trigger_level Receiver FIFO trigger level.
rspi_tx_trigger_level_t tx_trigger_level Transmitter FIFO trigger level.

◆ rspi_instance_ctrl_t

struct rspi_instance_ctrl_t

Channel control block. DO NOT INITIALIZE. Initialization occurs when spi_api_t::open is called.

Data Fields

uint32_t open
 Indicates whether the open() API has been successfully called.
 
spi_cfg_t const * p_cfg
 Pointer to instance configuration.
 
rspi_extended_cfg_tp_ext
 Pointer to extended configuration.
 
R_RSPI0_Type * p_regs
 Base register for this channel.
 
void const * p_tx_data
 Buffer to transmit.
 
void * p_rx_data
 Buffer to receive.
 
uint32_t tx_count
 Number of Data Frames to transfer (8-bit, 16-bit, 32-bit)
 
uint32_t rx_count
 Number of Data Frames to transfer (8-bit, 16-bit, 32-bit)
 
spi_bit_width_t bit_width
 Bits per Data frame (8-bit, 16-bit, 32-bit)
 
uint32_t rxfifo_trigger_bytes
 Receive buffer data triggering number.
 
uint32_t reg_spcr
 Backup SPCR register content.
 
uint32_t reg_spdcr
 Backup SPDCR register content.
 
uint32_t reg_spcmd0
 Backup SPCMD0 register content.
 
uint32_t reg_spbfcr
 Backup SPBFCR register content.
 
volatile bool transfer_is_pending
 Transfer is pending.
 

Enumeration Type Documentation

◆ rspi_ssl_polarity_t

Slave Select Polarity.

Enumerator
RSPI_SSLP_LOW 

SSLP signal polarity active low.

RSPI_SSLP_HIGH 

SSLP signal polarity active high.

◆ rspi_mosi_idle_value_fixing_t

MOSI Idle Behavior.

Enumerator
RSPI_MOSI_IDLE_VALUE_FIXING_DISABLE 

MOSI output value=value set in MOIFV bit.

RSPI_MOSI_IDLE_VALUE_FIXING_LOW 

MOSIn level low during MOSI idling.

RSPI_MOSI_IDLE_VALUE_FIXING_HIGH 

MOSIn level high during MOSI idling.

◆ rspi_delay_count_t

Delay count for SPI delay settings.

Enumerator
RSPI_DELAY_COUNT_1 

Set RSPCK delay count to 1 RSPCK.

RSPI_DELAY_COUNT_2 

Set RSPCK delay count to 2 RSPCK.

RSPI_DELAY_COUNT_3 

Set RSPCK delay count to 3 RSPCK.

RSPI_DELAY_COUNT_4 

Set RSPCK delay count to 4 RSPCK.

RSPI_DELAY_COUNT_5 

Set RSPCK delay count to 5 RSPCK.

RSPI_DELAY_COUNT_6 

Set RSPCK delay count to 6 RSPCK.

RSPI_DELAY_COUNT_7 

Set RSPCK delay count to 7 RSPCK.

RSPI_DELAY_COUNT_8 

Set RSPCK delay count to 8 RSPCK.

◆ rspi_tx_trigger_level_t

Transmitter FIFO trigger level.

Enumerator
RSPI_TX_TRIGGER_7 

Trigger when 7 or less bytes in TX FIFO.

RSPI_TX_TRIGGER_6 

Trigger when 6 or less bytes in TX FIFO.

RSPI_TX_TRIGGER_4 

Trigger when 4 or less bytes in TX FIFO.

RSPI_TX_TRIGGER_0 

Trigger when TX FIFO is empty.

◆ rspi_rx_trigger_level_t

Receiver FIFO trigger level.

Enumerator
RSPI_RX_TRIGGER_1 

Trigger when 1 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_2 

Trigger when 2 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_4 

Trigger when 4 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_8 

Trigger when 8 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_16 

Trigger when 16 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_24 

Trigger when 24 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_32 

Trigger when 32 or more bytes in RX FIFO.

RSPI_RX_TRIGGER_5 

Trigger when 5 or more bytes in RX FIFO.

Function Documentation

◆ R_RSPI_Open()

fsp_err_t R_RSPI_Open ( spi_ctrl_t p_api_ctrl,
spi_cfg_t const *const  p_cfg 
)

This functions initializes a channel for SPI communication mode. Implements spi_api_t::open.

This function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Configures the pperipheral registers acording to the configuration.
  • Initialize the control structure for use in other SPI Interface functions.
Return values
FSP_SUCCESSChannel initialized successfully.
FSP_ERR_ALREADY_OPENInstance was already initialized.
FSP_ERR_ASSERTIONAn invalid argument was given in the configuration structure.
FSP_ERR_IP_CHANNEL_NOT_PRESENTThe channel number is invalid.
Returns
See Common Error Codes or functions called by this function for other possible return codes.
Note
This function is reentrant.

◆ R_RSPI_Read()

fsp_err_t R_RSPI_Read ( spi_ctrl_t *const  p_api_ctrl,
void *  p_dest,
uint32_t const  length,
spi_bit_width_t const  bit_width 
)

This function receives data from a SPI device. Implements spi_api_t::read.

The function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Sets up the instance to complete a SPI read operation.
Return values
FSP_SUCCESSRead operation successfully completed.
FSP_ERR_ASSERTIONNULL pointer to control or destination parameters or transfer length is zero.
FSP_ERR_NOT_OPENThe channel has not been opened. Open channel first.
FSP_ERR_IN_USEA transfer is already in progress.
FSP_ERR_INVALID_ARGUMENTA bit length not supported by this device was assigned to the argument.

◆ R_RSPI_Write()

fsp_err_t R_RSPI_Write ( spi_ctrl_t *const  p_api_ctrl,
void const *  p_src,
uint32_t const  length,
spi_bit_width_t const  bit_width 
)

This function transmits data to a SPI device using the TX Only Communications Operation Mode. Implements spi_api_t::write.

The function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Sets up the instance to complete a SPI write operation.
Return values
FSP_SUCCESSWrite operation successfully completed.
FSP_ERR_ASSERTIONNULL pointer to control or source parameters or transfer length is zero.
FSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.
FSP_ERR_IN_USEA transfer is already in progress.
FSP_ERR_INVALID_ARGUMENTA bit length not supported by this device was assigned to the argument.

◆ R_RSPI_WriteRead()

fsp_err_t R_RSPI_WriteRead ( spi_ctrl_t *const  p_api_ctrl,
void const *  p_src,
void *  p_dest,
uint32_t const  length,
spi_bit_width_t const  bit_width 
)

This function simultaneously transmits and receive data. Implements spi_api_t::writeRead.

The function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Sets up the instance to complete a SPI writeRead operation.
Return values
FSP_SUCCESSWrite operation successfully completed.
FSP_ERR_ASSERTIONNULL pointer to control, source or destination parameters or transfer length is zero.
FSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.
FSP_ERR_IN_USEA transfer is already in progress.
FSP_ERR_INVALID_ARGUMENTA bit length not supported by this device was assigned to the argument.

◆ R_RSPI_Close()

fsp_err_t R_RSPI_Close ( spi_ctrl_t *const  p_api_ctrl)

This function manages the closing of a channel by the following task. Implements spi_api_t::close.

Disables SPI operations by disabling the SPI bus.

  • Disables the SPI peripheral.
  • Disables all the associated interrupts.
  • Update control structure so it will not work with SPI Interface functions.
Return values
FSP_SUCCESSChannel successfully closed.
FSP_ERR_ASSERTIONA required pointer argument is NULL.
FSP_ERR_NOT_OPENThe channel has not been opened. Open the channel first.

◆ R_RSPI_CalculateBitrate()

fsp_err_t R_RSPI_CalculateBitrate ( uint32_t  bitrate,
rspi_rspck_div_setting_t spck_div 
)

Calculates the SPBR register value and the BRDV bits for a desired bitrate. If the desired bitrate is faster than the maximum bitrate, than the bitrate is set to the maximum bitrate. If the desired bitrate is slower than the minimum bitrate, than an error is returned.

Parameters
[in]bitrateDesired bitrate
[out]spck_divMemory location to store bitrate register settings.
Return values
FSP_SUCCESSValid spbr and brdv values were calculated
FSP_ERR_UNSUPPORTEDBitrate is not achievable

◆ R_RSPI_CallbackSet()

fsp_err_t R_RSPI_CallbackSet ( spi_ctrl_t *const  p_api_ctrl,
void(*)(spi_callback_args_t *)  p_callback,
void const *const  p_context,
spi_callback_args_t *const  p_callback_memory 
)

Updates the user callback and has option of providing memory for callback structure. Implements spi_api_t::callbackSet

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.
FSP_ERR_NO_CALLBACK_MEMORYp_callback is non-secure and p_callback_memory is either secure or NULL.