RX Flexible Software Package Documentation  Release v1.0.0

 
XSPI (r_xspi_target)

Functions

fsp_err_t R_XSPI_TARGET_Open (spi_flash_ctrl_t *const p_ctrl, spi_flash_cfg_t const *const p_cfg)
 
fsp_err_t R_XSPI_TARGET_Close (spi_flash_ctrl_t *const p_ctrl)
 
fsp_err_t R_XSPI_TARGET_DirectWrite (spi_flash_ctrl_t *const p_ctrl, uint8_t const *const p_src, uint32_t const bytes, bool const read_after_write)
 
fsp_err_t R_XSPI_TARGET_DirectRead (spi_flash_ctrl_t *const p_ctrl, uint8_t *const p_dest, uint32_t const bytes)
 
fsp_err_t R_XSPI_TARGET_DirectTransfer (spi_flash_ctrl_t *const p_ctrl, spi_flash_direct_transfer_t *const p_transfer, spi_flash_direct_transfer_dir_t direction)
 
fsp_err_t R_XSPI_TARGET_SpiProtocolSet (spi_flash_ctrl_t *const p_ctrl, spi_flash_protocol_t spi_protocol)
 
fsp_err_t R_XSPI_TARGET_XipEnter (spi_flash_ctrl_t *const p_ctrl)
 
fsp_err_t R_XSPI_TARGET_XipExit (spi_flash_ctrl_t *const p_ctrl)
 
fsp_err_t R_XSPI_TARGET_Write (spi_flash_ctrl_t *const p_ctrl, uint8_t const *const p_src, uint8_t *const p_dest, uint32_t byte_count)
 
fsp_err_t R_XSPI_TARGET_Erase (spi_flash_ctrl_t *const p_ctrl, uint8_t *const p_device_address, uint32_t byte_count)
 
fsp_err_t R_XSPI_TARGET_StatusGet (spi_flash_ctrl_t *const p_ctrl, spi_flash_status_t *const p_status)
 
fsp_err_t R_XSPI_TARGET_BankSet (spi_flash_ctrl_t *const _ctrl, uint32_t bank)
 
fsp_err_t R_XSPI_TARGET_AutoCalibrate (spi_flash_ctrl_t *const p_ctrl)
 

Detailed Description

Driver for the XSPI_TARGET peripheral on RX MCUs. This module implements the SPI Flash Interface.

Overview

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.

Features

The XSPI_TARGET driver has the following key features to support the xSPI device:

Configuration

XSPI_TARGET:

Build Time Configurations for r_xspi_target

The following build time configurations are defined in fsp_cfg/r_xspi_target_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Storage > XSPI Target (r_xspi_target)

This module can be added to the Stacks tab via New Stack > Storage > XSPI Target (r_xspi_target).

ConfigurationOptionsDefaultDescription
General > NameName must be a valid C symbolg_xspi_target0 Module name.
General > UnitMCU Specific OptionsSpecify the hardware unit.
Command Sets > Read > Command Code > RegisterCommand codes must be positive and fit in the selected command byte length.0x13 Read register command code.
Command Sets > Read > Command Code > MemoryCommand codes must be positive and fit in the selected command byte length.0x13 Read memory command code.
Command Sets > Read > Dummy Cycles15 cycles15 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 > RegisterCommand codes must be positive and fit in the selected command byte length.0x12 Write register command code.
Command Sets > Write > Command Code > MemoryCommand codes must be positive and fit in the selected command byte length.0x12 Write memory command code.
Command Sets > Write > Dummy CyclesDummy 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
  • 4S-4D-4D
  • 8D-8D-8D
1S-1S-1S Signal protocol mode to use for this command set.
Command Sets > Frame Format
  • Normal format
  • 8D-8D-8D profile 1.0 format
  • 8D-8D-8D profile 2.0 command modifier format
  • 8D-8D-8D profile 2.0 extended command modifier format
Normal format Frame format to use with this command set.
Command Sets > Address Length
  • 2 bytes (64-Kbyte address space)
  • 3 bytes (16-Mbyte address space)
  • 4 bytes (4-Gbyte address space)
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
  • 8
  • 16
  • 32
  • 64
  • 128
  • 256
  • 512
64 Maximum data size for the write frame
Size Setting > Maximum read frame size
  • 8
  • 16
  • 32
  • 64
  • 128
  • 256
  • 512
64 Maximum data size for the read frame
Size Setting > Memory size
  • 4 Kbytes
  • 8 Kbytes
  • 16 Kbytes
  • 32 Kbytes
  • 64 Kbytes
  • 128 Kbytes
  • 256 Kbytes
  • 512 Kbytes
  • 1 Mbytes
4 Kbytes Setting address space of the XSPI target module
Timing Setting > Output Assert Delay
  • Disabled
  • Enabled
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
  • Enabled
Disabled Disable/Enable Write Data Mask

Note
The user is expected to modify the command definitions based on the xSPI chip and SPI communication mode.

Clock Configuration

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.

Pin Configuration

The following pins are available to connect to an external XSPI device:

Note
Data pins can be configured with IOPORT_CFG_DRIVE_6 or IOPORT_CFG_DRIVE_8 according to the Electrical Characteristics chapter.
Chip Select pins should be configured with at least IOPORT_CFG_DRIVE_4.

Usage Notes

Usage Notes for xSPI support

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:

xSPI Commands

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.

Examples

XSPI Target Basic Example

This is a basic example of minimal use of the XSPI Target in an application.

void r_xspi_target_basic_example (void)
{
/* Open the XSPI instance. */
fsp_err_t err = R_XSPI_TARGET_Open(&g_xspi_target_ctrl, &g_xspi_target_cfg);
assert(FSP_SUCCESS == err);
/* (Optional) Change SPI to DOPI mode */
assert(FSP_SUCCESS == err);
err = R_XSPI_TARGET_Close(&g_xspi_target_ctrl);
assert(FSP_SUCCESS == err);
}

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
 

Data Structure Documentation

◆ xspi_target_timing_setting_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.

◆ xspi_target_command_set_t

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.

◆ xspi_target_instance_ctrl_t

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.

◆ xspi_target_extended_cfg_t

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.

Enumeration Type Documentation

◆ xspi_target_frame_format_t

Format of data frames used for communicating with the target device.

Enumerator
XSPI_TARGET_FRAME_FORMAT_STANDARD 

Standard frame with command, address, and data phases.

XSPI_TARGET_FRAME_FORMAT_XSPI_PROFILE_1 

JEDEC XSPI 8D-8D-8D Profile 1.0 frame.

XSPI_TARGET_FRAME_FORMAT_XSPI_PROFILE_2 

JEDEC XSPI 8D-8D-8D Profile 2.0 frame.

XSPI_TARGET_FRAME_FORMAT_XSPI_PROFILE_2_EXTENDED 

JEDEC XSPI 8D-8D-8D Profile 2.0 extended 6-byte command-address frame, used with HyperRAM.

◆ xspi_target_maximum_frame_size_t

Enumerator
XSPI_TARGET_MAX_FRAME_SIZE_8 

Maximum supported frame size is 8 bytes.

XSPI_TARGET_MAX_FRAME_SIZE_16 

Maximum supported frame size is 16 bytes.

XSPI_TARGET_MAX_FRAME_SIZE_32 

Maximum supported frame size is 32 bytes.

XSPI_TARGET_MAX_FRAME_SIZE_64 

Maximum supported frame size is 64 bytes.

XSPI_TARGET_MAX_FRAME_SIZE_128 

Maximum supported frame size is 128 bytes.

XSPI_TARGET_MAX_FRAME_SIZE_256 

Maximum supported frame size is 256 bytes.

XSPI_TARGET_MAX_FRAME_SIZE_512 

Maximum supported frame size is 512 bytes.

◆ xspi_target_memory_size_t

Memory size of XSPI Target module

Enumerator
XSPI_TARGET_MEMORY_SIZE_4_KBYTES 

4 KB memory size (address range 0x0000-0x0FFF).

XSPI_TARGET_MEMORY_SIZE_8_KBYTES 

8 KB memory size (address range 0x0000-0x1FFF).

XSPI_TARGET_MEMORY_SIZE_16_KBYTES 

16 KB memory size (address range 0x0000-0x3FFF).

XSPI_TARGET_MEMORY_SIZE_32_KBYTES 

32 KB memory size (address range 0x0000-0x7FFF).

XSPI_TARGET_MEMORY_SIZE_64_KBYTES 

64 KB memory size (address range 0x0000-0xFFFF).

XSPI_TARGET_MEMORY_SIZE_128_KBYTES 

128 KB memory size (address range 0x0000-0x1FFFF).

XSPI_TARGET_MEMORY_SIZE_256_KBYTES 

256 KB memory size (address range 0x0000-0x3FFFF).

XSPI_TARGET_MEMORY_SIZE_512_KBYTES 

512 KB memory size (address range 0x0000-0x7FFFF).

XSPI_TARGET_MEMORY_SIZE_1_MBYTE 

1 MB memory size (address range 0x0000-0xFFFFF).

◆ xspi_target_output_assert_delay_t

Output enable delay settings.

Enumerator
XSPI_TARGET_ASSERTION_DELAY_DISABLED 

Assertion delay disable.

XSPI_TARGET_ASSERTION_DELAY_ENABLED 

Assertion delay enable.

◆ xspi_target_write_data_mask_enable_t

Enumerator
XSPI_TARGET_WRITE_DATA_MASK_DISABLE 

Disable write data mask.

XSPI_TARGET_WRITE_DATA_MASK_ENABLE 

Enable write data mask.

Function Documentation

◆ R_XSPI_TARGET_Open()

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.

Return values
FSP_SUCCESSConfiguration was successful.
FSP_ERR_ASSERTIONThe parameter p_ctrl or p_cfg is NULL.
FSP_ERR_ALREADY_OPENDriver has already been opened with the same p_ctrl.
FSP_ERR_INVALID_MODEInvalid configuration for p_cmd_set.

◆ R_XSPI_TARGET_Close()

fsp_err_t R_XSPI_TARGET_Close ( spi_flash_ctrl_t *  p_ctrl)

Close the XSPI driver module.

Implements spi_flash_api_t::close.

Return values
FSP_SUCCESSConfiguration was successful.
FSP_ERR_ASSERTIONp_instance_ctrl is NULL.
FSP_ERR_NOT_OPENDriver is not opened.

◆ R_XSPI_TARGET_DirectWrite()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_DirectRead()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_DirectTransfer()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_SpiProtocolSet()

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.

Return values
FSP_SUCCESSSPI protocol updated on MPU peripheral.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENDriver is not opened.

◆ R_XSPI_TARGET_XipEnter()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_XipExit()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_Write()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_Erase()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_StatusGet()

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.

Return values
FSP_ERR_UNSUPPORTEDAPI not supported by XSPI Target module.

◆ R_XSPI_TARGET_BankSet()

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.

Return values
FSP_ERR_UNSUPPORTEDThis function is unsupported.

◆ R_XSPI_TARGET_AutoCalibrate()

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.

Return values
FSP_ERR_UNSUPPORTEDThis function is unsupported.