![]() |
RX Flexible Software Package Documentation
Release v1.0.0
|
|
Driver for the XSPI_TARGET peripheral on RX MCUs. This module implements the SPI Flash Interface.
The XSPI_TARGET peripheral supports xSPI access SRAM, and it interfaces with these devices to perform data I/O Operations.
Please note that this document will reference the xSPI protocol to which XSPI is a subset. The XSPI_TARGET peripheral is compatible with a variety of xSPI protocol operating modes.
The XSPI_TARGET driver has the following key features to support the xSPI device:
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| General > Name | Name must be a valid C symbol | g_xspi_target0 | Module name. |
| General > Unit | MCU Specific Options | Specify the hardware unit. | |
| Command Sets > Read > Command Code > Register | Command codes must be positive and fit in the selected command byte length. | 0x13 | Read register command code. |
| Command Sets > Read > Command Code > Memory | Command codes must be positive and fit in the selected command byte length. | 0x13 | Read memory command code. |
| Command Sets > Read > Dummy Cycles | 15 cycles | 15 cycles | The number of latency cycles to insert during read transactions in memory mapped mode. Set Read Dummy Cycles to 0Fh (15 cycles). |
| Command Sets > Write > Command Code > Register | Command codes must be positive and fit in the selected command byte length. | 0x12 | Write register command code. |
| Command Sets > Write > Command Code > Memory | Command codes must be positive and fit in the selected command byte length. | 0x12 | Write memory command code. |
| Command Sets > Write > Dummy Cycles | Dummy cycle counts must be an integer between 0 and 31. | 0 | The number of latency cycles to insert during write transactions in memory mapped mode. |
| Command Sets > Protocol Mode |
| 1S-1S-1S | Signal protocol mode to use for this command set. |
| Command Sets > Frame Format |
| Normal format | Frame format to use with this command set. |
| Command Sets > Address Length |
| 3 bytes (16-Mbyte address space) | Number of bytes used to address data in the address field in memory mapped mode. |
| Size Setting > Maximum write frame size |
| 64 | Maximum data size for the write frame |
| Size Setting > Maximum read frame size |
| 64 | Maximum data size for the read frame |
| Size Setting > Memory size |
| 4 Kbytes | Setting address space of the XSPI target module |
| Timing Setting > Output Assert Delay |
| Disabled | Assertion timing of the output buffer control signal. Setting this bit to 1 delays the start of output from the IO pins and the DS pin by one cycle |
| Write Data Mask |
| Disabled | Disable/Enable Write Data Mask |
The signals to the xSPI target device are derived from OCTACLK. OCTACLK must be set to twice the desired xSPI_CLK signal frequency. This allows data to be latched on either clock edge for Dual-Data-Rate modes (4S-4D-4D or 8D-8D-8D).
Please refer to the Hardware User Manual for the clocks which control the XSPI_TARGET registers. These along with OCTACLK can be set on the Clocks tab of the RA Configuration editor.
The following pins are available to connect to an external XSPI device:
XSPI Controller module will access SRAM via the XSPI Target module. So the protocol-specific configuration of the XSPI Target module must be mapped to XSPI Controller module.
Protocol mode supported:
XSPI Target module can config can configure itself, or it can be configured by the XSPI Controller module.
Access mode:
The command of XSPI Target has 4 types:
The command of XSPI Target module can be modified. If a command set is not found, an FSP_ERR_INVALID_MODE error code will be returned.
This is a basic example of minimal use of the XSPI Target in an application.
Data Structures | |
| struct | xspi_target_timing_setting_t |
| struct | xspi_target_command_set_t |
| struct | xspi_target_instance_ctrl_t |
| struct | xspi_target_extended_cfg_t |
Enumerations | |
| enum | xspi_target_frame_format_t |
| enum | xspi_target_maximum_frame_size_t |
| enum | xspi_target_memory_size_t |
| enum | xspi_target_output_assert_delay_t |
| enum | xspi_target_write_data_mask_enable_t |
| struct xspi_target_timing_setting_t |
Fixed timing configuration for bus signals.
| Data Fields | ||
|---|---|---|
| xspi_target_output_assert_delay_t | output_assert_delay | Delays the assertion timing of IO[7:0] and DS signals by one cycle. |
| struct xspi_target_command_set_t |
Command set used for a protocol mode.
| Data Fields | ||
|---|---|---|
| xspi_target_frame_format_t | frame_format | Frame format to use for this command set. |
| uint8_t | read_register_command | Read register command. |
| uint8_t | read_memory_command | Read memory command. |
| uint8_t | write_register_command | Write register command. |
| uint8_t | write_memory_command | Write memory command. |
| uint8_t | read_dummy_cycles | Dummy cycles to be inserted for read commands. |
| uint8_t | program_dummy_cycles | Dummy cycles to be inserted for page program commands. |
| struct xspi_target_instance_ctrl_t |
Instance control block. DO NOT INITIALIZE. Initialization occurs when spi_flash_api_t::open is called
| Data Fields | ||
|---|---|---|
| spi_flash_cfg_t const * | p_cfg | Pointer to initial configuration. |
| uint32_t | open | Whether or not driver is open. |
| spi_flash_protocol_t | spi_protocol | Current XSPI protocol selected. |
| R_XSPI_TARGET0_Type * | p_reg | Address for the XSPI peripheral associated with this channel. |
| struct xspi_target_extended_cfg_t |
XSPI_TARGET Extended configuration.
| Data Fields | ||
|---|---|---|
| uint8_t | unit | XSPI_TARGET instance number. |
|
xspi_target_timing_setting_t const * |
p_timing_settings | Fixed protocol timing settings. |
| xspi_target_maximum_frame_size_t | max_read_frame_size | |
| xspi_target_maximum_frame_size_t | max_write_frame_size | |
| xspi_target_memory_size_t | memory_size | Determine address space of XSPI Target module. |
| xspi_target_write_data_mask_enable_t | write_data_mask | Mask signal for each byte in the write data;. |
| xspi_target_command_set_t const * | p_cmd_set | Command set for the active protocol mode. |
Format of data frames used for communicating with the target device.
Memory size of XSPI Target module
| fsp_err_t R_XSPI_TARGET_Open | ( | spi_flash_ctrl_t *const | p_ctrl, |
| spi_flash_cfg_t const *const | p_cfg | ||
| ) |
Open the xSPI device. After the driver is open, the xSPI device can be accessed like internal flash memory.
Implements spi_flash_api_t::open.
| FSP_SUCCESS | Configuration was successful. |
| FSP_ERR_ASSERTION | The parameter p_ctrl or p_cfg is NULL. |
| FSP_ERR_ALREADY_OPEN | Driver has already been opened with the same p_ctrl. |
| FSP_ERR_INVALID_MODE | Invalid configuration for p_cmd_set. |
| fsp_err_t R_XSPI_TARGET_Close | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Close the XSPI driver module.
Implements spi_flash_api_t::close.
| FSP_SUCCESS | Configuration was successful. |
| FSP_ERR_ASSERTION | p_instance_ctrl is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |
| fsp_err_t R_XSPI_TARGET_DirectWrite | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint8_t const *const | p_src, | ||
| uint32_t const | bytes, | ||
| bool const | read_after_write | ||
| ) |
Writes raw data directly to the OctaFlash. API not supported. Use R_XSPI_TARGET_DirectTransfer
Implements spi_flash_api_t::directWrite.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_DirectRead | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint8_t *const | p_dest, | ||
| uint32_t const | bytes | ||
| ) |
Reads raw data directly from the OctaFlash. API not supported. Use R_XSPI_TARGET_DirectTransfer.
Implements spi_flash_api_t::directRead.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_DirectTransfer | ( | spi_flash_ctrl_t * | p_ctrl, |
| spi_flash_direct_transfer_t *const | p_transfer, | ||
| spi_flash_direct_transfer_dir_t | direction | ||
| ) |
Read/Write a transfer to XSPI Target.
Implements spi_flash_api_t::directTransfer.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_SpiProtocolSet | ( | spi_flash_ctrl_t * | p_ctrl, |
| spi_flash_protocol_t | spi_protocol | ||
| ) |
Sets the SPI protocol.
Implements spi_flash_api_t::spiProtocolSet.
| FSP_SUCCESS | SPI protocol updated on MPU peripheral. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |
| fsp_err_t R_XSPI_TARGET_XipEnter | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Enters XIP (execute in place) mode.
Implements spi_flash_api_t::xipEnter.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_XipExit | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Exits XIP (execute in place) mode.
Implements spi_flash_api_t::xipExit.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_Write | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint8_t const *const | p_src, | ||
| uint8_t *const | p_dest, | ||
| uint32_t | byte_count | ||
| ) |
Program a page of data to the flash.
Implements spi_flash_api_t::write.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_Erase | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint8_t *const | p_device_address, | ||
| uint32_t | byte_count | ||
| ) |
Erase a block or sector of flash. The byte_count must exactly match one of the erase sizes defined in spi_flash_cfg_t. For chip erase, byte_count must be SPI_FLASH_ERASE_SIZE_CHIP_ERASE.
Implements spi_flash_api_t::erase.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_StatusGet | ( | spi_flash_ctrl_t * | p_ctrl, |
| spi_flash_status_t *const | p_status | ||
| ) |
Gets the write or erase status of the flash.
Implements spi_flash_api_t::statusGet.
| FSP_ERR_UNSUPPORTED | API not supported by XSPI Target module. |
| fsp_err_t R_XSPI_TARGET_BankSet | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint32_t | bank | ||
| ) |
Selects the bank to access. Use XSPI_TARGET_bank_select_t as the bank value.
Implements spi_flash_api_t::bankSet.
| FSP_ERR_UNSUPPORTED | This function is unsupported. |
| fsp_err_t R_XSPI_TARGET_AutoCalibrate | ( | spi_flash_ctrl_t *const | p_ctrl | ) |
AutoCalibrate the XSPI_TARGET DS signal.
Implements spi_flash_api_t::autoCalibrate.
| FSP_ERR_UNSUPPORTED | This function is unsupported. |