![]() |
RZT Flexible Software Package Documentation
Release v3.0.0
|
|
Driver for the xSPI peripheral on RZ microprocessor. This module implements the SPI Flash Interface.
The xSPI QSPI driver has the following key features:
Configuration | Options | Default | Description |
---|---|---|---|
Memory Mapping Address Space > Unit 0 > Chip Select 0 > Start Address | Address should be the start address of xspi unit 0 external address space | 0x60000000 | Start address of xSPI Unit 0 Chip Select 0 in memory mapping mode. |
Memory Mapping Address Space > Unit 0 > Chip Select 0 > End Address | Address should be within xspi unit 0 external address space | 0x600FFFFF | End address of xSPI Unit 0 Chip Select 1 in memory mapping mode. |
Memory Mapping Address Space > Unit 0 > Chip Select 1 > Start Address | Address should be within xspi unit 0 external address space | 0x64000000 | Start address of xSPI Unit 0 Chip Select 1 in memory mapping mode. |
Memory Mapping Address Space > Unit 0 > Chip Select 1 > End Address | Address should be within xspi unit 0 external address space | 0x640FFFFF | End address of xSPI Unit 0 Chip Select 1 in memory mapping mode. |
Memory Mapping Address Space > Unit 1 > Chip Select 0 > Start Address | Address should be the start address of xspi unit 1 external address space | 0x68000000 | Start address of xSPI Unit 1 Chip Select 0 in memory mapping mode. |
Memory Mapping Address Space > Unit 1 > Chip Select 0 > End Address | Address should be within xspi unit 1 external address space | 0x680FFFFF | End address of xSPI Unit 1 Chip Select 0 in memory mapping mode. |
Memory Mapping Address Space > Unit 1 > Chip Select 1 > Start Address | Address should be within xspi unit 1 external address space | 0x6C000000 | Start address of xSPI Unit 1 Chip Select 1 in memory mapping mode. |
Memory Mapping Address Space > Unit 1 > Chip Select 1 > End Address | Address should be within xspi unit 1 external address space | 0x6C0FFFFF | End address of xSPI Unit 1 Chip Select 1 in memory mapping mode. |
Memory Mapping Address Space > Memory Mapping Address Space Configuration Support | MCU Specific Options | Support status of Memory Mapping Address Space setting on this MCU. If Not supported, the address space set in Memory Mapping Address Space is invalid. | |
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Unit 0 Prefetch Function |
| Disable | Enable prefetch function on memory-mapped reads of xSPI Unit 0. |
Unit 1 Prefetch Function |
| Disable | Enable prefetch function on memory-mapped reads of xSPI Unit 1. |
Unit 0 IO voltage | MCU Specific Options | Voltage setting of xSPI Unit 0. | |
Unit 1 IO voltage | MCU Specific Options | Voltage setting of xSPI Unit 1. | |
DMAC Support |
| Disable | Enable DMAC support for the QSPI module. |
OTFD Support | MCU Specific Options | Enable OTFD support for the xSPI module. |
Configuration | Options | Default | Description |
---|---|---|---|
General > Name | Name must be a valid C symbol | g_qspi0 | Module name. |
General > unit | Unit should be 0 or 1 | 0 | Specify the xSPI unit number. |
General > Chip Select |
| Chip Select 0 | Specify the XSPI chip select line to use. |
General > Flash Size | MCU Specific Options | Specify the QSPI Flash size. | |
General > SPI Protocol |
| 1S-1S-1S | Select the initial SPI protocol. SPI protocol can be changed in R_XSPI_QSPI_SpiProtocolSet(). |
General > Address Bytes |
| 3 | Select the number of address bytes. If 4-byte mode is selected, the application must issue the EN4B command using R_XSPI_QSPI_DirectTransfer(). |
General > Dummy Clocks for Read | Refer to the RZT Configuration tool for available options. | 8 | Select the number of dummy clocks for read operations. |
Command Definitions > Page Program Command | Must be an 8-bit QSPI command | 0x02 | The command to program a page. |
Command Definitions > Read Command | Must be an 8-bit QSPI command | 0x03 | The command to read. |
Command Definitions > Write Enable Command | Must be an 8-bit QSPI command | 0x06 | The command to enable write. |
Command Definitions > Status Command | Must be an 8-bit QSPI command | 0x05 | The command to query the status of a write or erase command. |
Command Definitions > Write Status Bit | Must be an integer between 0 and 7 | 0 | Which bit contains the write in progress status returned from the Write Status Command. |
Command Definitions > Write Enable Bit | Must be an integer between 0 and 7 | 1 | Which bit contains the write enable status returned from the Write Status Command. |
Command Definitions > Sector Erase Command | Must be an 8-bit QSPI command | 0x20 | The command to erase a sector. Set Sector Erase Size to 0 if unused. |
Command Definitions > Sector Erase Size | Must be an integer greater than or equal to 0 | 4096 | The sector erase size. Set Sector Erase Size to 0 if Sector Erase is not supported. |
Command Definitions > Block Erase Command | Must be an 8-bit QSPI command | 0xD8 | The command to erase a block. Set Block Erase Size to 0 if unused. |
Command Definitions > Block Erase Size | Must be an integer greater than or equal to 0 | 65536 | The block erase size. Set Block Erase Size to 0 if Block Erase is not supported. |
Command Definitions > Block Erase 32KB Command | Must be an 8-bit QSPI command | 0x52 | The command to erase a 32KB block. Set Block Erase Size to 0 if unused. |
Command Definitions > Block Erase 32KB Size | Must be an integer greater than or equal to 0 | 32768 | The block erase 32KB size. Set Block Erase 32KB Size to 0 if Block Erase 32KB is not supported. |
Command Definitions > Chip Erase Command | Must be an 8-bit QSPI command | 0xC7 | The command to erase the entire chip. Set Chip Erase Command to 0 if unused. |
Command Definitions > XIP Enter M7-M0 | Must be an 8-bit QSPI command | 0x20 | How to set M7-M0 to enter XIP mode. |
Command Definitions > XIP Exit M7-M0 | Must be an 8-bit QSPI command | 0xFF | How to set M7-M0 exit XIP mode. |
Bus Timing > CS minimum idle term | Refer to the RZT Configuration tool for available options. | 7 CYCLES | Define the CS minimum idle term. |
Bus Timing > CS asserting extension |
| No Extension | Define the CS asserting extension |
Bus Timing > CS negating extension |
| No Extension | Define the CS negating extension |
OTFD > OTFD Support for Unit |
| Disabled | Enable OTFD support for the unit. |
OTFD > Name | Name must be a valid C symbol | g_qspi0_otfd | OTFD Configuration name. |
OTFD > AES Key | Name must be a valid C symbol | g_qspi0_otfd_key | Name of Key variable. |
OTFD > AES IV | Name must be a valid C symbol | g_qspi0_otfd_iv | Name of IV variable. |
OTFD > AES Key Length |
| 128 | Select AES key length. |
OTFD > Decryption start address | Value must be an integer between 0x60000000 and 0x6FFFFFFF | 0x60000000 | xSPI decryption start address. Do not select mirror area. |
OTFD > Decryption end address | Value must be an integer between 0x60000000 and 0x6FFFFFFF | 0x60001FFF | xSPI decryption end address. Do not select mirror area. |
The QSPI clock is derived from XSPI_CLKn. You can set the clock frequency using the Clocks tab of the FSP Configuration editor or by using the CGC Interface at run-time.
The following pins are available to connect to an external QSPI device:
After R_XSPI_QSPI_Open() completes successfully, the QSPI Flash device contents are mapped to External Address Space xSPIn or their mirror spaces and can be read like on-chip flash. Please refer to xSPI "Overview" section in your device's manual on address map details.
In the configurator properties, 'Memory Mapping Address Space Configuration Support' is set to either 'Supported' or 'Not Supported' depending on your device. The method of memory mapped access address configuration depends on the value of 'Memory Mapping Address Space Configuration Support'.
If 'Memory Mapping Address Space Configuration Support' is 'Supported', 'Memory Mapping Address Space' should be set appropriately for your device. The table below shows an example of 'Memory Mapping Address Space' configurations when 64MB flash is used as a slave device in each Chip Select.
Properties | RZ/T2ME | RZ/T2H |
---|---|---|
Memory Mapping Address Space > Unit 0 > Chip Select 0 > Start Address | 0x60000000 (Fixed) | 0x40000000 (Fixed) |
Memory Mapping Address Space > Unit 0 > Chip Select 0 > End Address | 0x63FFFFFF | 0x43FFFFFF |
Memory Mapping Address Space > Unit 0 > Chip Select 1 > Start Address | 0x64000000 | 0x48000000 |
Memory Mapping Address Space > Unit 0 > Chip Select 1 > End Address | 0x67FFFFFF | 0x4BFFFFFF |
Memory Mapping Address Space > Unit 1 > Chip Select 0 > Start Address | 0x68000000 (Fixed) | 0x50000000 (Fixed) |
Memory Mapping Address Space > Unit 1 > Chip Select 0 > End Address | 0x6BFFFFFF | 0x53FFFFFF |
Memory Mapping Address Space > Unit 1 > Chip Select 1 > Start Address | 0x6C000000 | 0x58000000 |
Memory Mapping Address Space > Unit 1 > Chip Select 1 > End Address | 0x6FFFFFFF | 0x5BFFFFFF |
Memory Mapping Address Space > Memory Mapping Address Space Configuration Support | Supported | Supported |
The address space of each chip select set by the above configuration is as follows.
Address Space of Each Chip Select | RZ/T2ME | RZ/T2H |
---|---|---|
Unit 0 Chip Select 0 Start Address | 0x60000000 (Fixed) | 0x40000000 (Fixed) |
Unit 0 Chip Select 0 End Address | 0x63FFFFFF | 0x43FFFFFF |
Unit 0 Chip Select 1 Start Address | 0x64000000 | 0x48000000 |
Unit 0 Chip Select 1 End Address | 0x67FFFFFF | 0x4BFFFFFF |
Unit 1 Chip Select 0 Start Address | 0x68000000 (Fixed) | 0x50000000 (Fixed) |
Unit 1 Chip Select 0 End Address | 0x6BFFFFFF | 0x53FFFFFF |
Unit 1 Chip Select 1 Start Address | 0x6C000000 | 0x58000000 |
Unit 1 Chip Select 1 End Address | 0x6FFFFFFF | 0x5BFFFFFF |
If 'Memory Mapping Address Space Configuration Support' is 'Not Supported' for your device, 'Memory Mapping Address Space' configurations are invalid. In this case, the start address of each chip select is fixed by device, and only the size of the address space is configured in 'Flash Size' property. The table below shows an example of the address space configuration when 64MB flash is used as a slave device in Unit 0 Chip Select 0.
Properties | RZ/T2M | RZ/T2L |
---|---|---|
Memory Mapping Address Space > Memory Mapping Address Space Configuration Support | Not Supported | Not Supported |
General > Unit | 0 | 0 |
General > Chip Select | 0 | 0 |
General > Flash Size | 64MB | 64MB |
The address space of each chip select set by the above configuration is as follows.
Address Space of Each Chip Select | RZ/T2M | RZ/T2L |
---|---|---|
Unit 0 Chip Select 0 Start Address | 0x60000000 (Fixed) | 0x60000000 (Fixed) |
Unit 0 Chip Select 0 End Address | 0x63FFFFFF (64MB Size) | 0x63FFFFFF (64MB Size) |
Unit 0 Chip Select 1 Start Address | 0x64000000 (Fixed) | 0x64000000 (Fixed) |
Unit 0 Chip Select 1 End Address | 0x640FFFFF (default) | 0x640FFFFF (default) |
Unit 1 Chip Select 0 Start Address | 0x68000000 (Fixed) | 0x68000000 (Fixed) |
Unit 1 Chip Select 0 End Address | 0x680FFFFF (default) | 0x680FFFFF (default) |
Unit 1 Chip Select 1 Start Address | 0x6C000000 (Fixed) | 0x6C000000 (Fixed) |
Unit 1 Chip Select 1 End Address | 0x6C0FFFFF (default) | 0x6C0FFFFF (default) |
This is a basic example of minimal use of the QSPI in an application. When using the section definition in the example below, the user must define it separately in the linker configuration file.
This is an example of the types of commands that can be used to initialize the QSPI.
This is an example of using R_XSPI_QSPI_DirectTransfer to send the read status register command and read back the status register from the device.
This is an example of using R_XSPI_QSPI_DirectTransfer to query the device size.
This is an example of using R_XSPI_QSPI_Write() to write a page of data to memory space for RZ/T2M and RZ/T2L. In these MCU environments, R_XSPI_QSPI_Write() attempts memory mapping accesses. (In other MCU environments, attempts manual command access.) In this case, the memory access attribute of the External Address Space xSPIn should be device-nGnRnE, because write access to flash memory needs to be in the right order. Therefore, R_BSP_MpuRegionDynamicConfig() and R_BSP_MpuRegionRestoreConfig() are used to temporarily change the memory access attribute.
This is an example of using R_XSPI_QSPI_DirectTransfer() to write a page of data to memory space. If two memories are connected on the same unit's xSPI bus, memory mapping write may not be possible due to bus collisions caused by simultaneous accesses to the xSPI area. In this case, it is recommended to write data using R_XSPI_QSPI_DirectTransfer() instead of R_XSPI_QSPI_Write().
Data Structures | |
struct | xspi_qspi_instance_ctrl_t |
Enumerations | |
enum | xspi_qspi_chip_select_t |
enum | xspi_qspi_memory_size_t |
enum | xspi_qspi_command_interval_clocks_t |
enum | xspi_qspi_cs_pullup_clocks_t |
enum | xspi_qspi_cs_pulldown_clocks_t |
enum | xspi_qspi_prefetch_function_t |
enum | xspi_qspi_io_voltage_t |
struct xspi_qspi_instance_ctrl_t |
Instance control block. DO NOT INITIALIZE. Initialization occurs when spi_flash_api_t::open is called
fsp_err_t R_XSPI_QSPI_Open | ( | spi_flash_ctrl_t * | p_ctrl, |
spi_flash_cfg_t const *const | p_cfg | ||
) |
Open the QSPI driver module. After the driver is open, the QSPI can be accessed like internal flash memory.
Implements spi_flash_api_t::open.
FSP_SUCCESS | Configuration was successful. |
FSP_ERR_ASSERTION | The parameter p_instance_ctrl or p_cfg is NULL. |
FSP_ERR_ALREADY_OPEN | Driver has already been opened with the same p_instance_ctrl. |
FSP_ERR_IP_CHANNEL_NOT_PRESENT | The requested channel does not exist on this MCU. |
fsp_err_t R_XSPI_QSPI_Close | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Close the QSPI 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_QSPI_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 QSPI.
Implements spi_flash_api_t::directWrite.
FSP_ERR_UNSUPPORTED | API not supported. |
fsp_err_t R_XSPI_QSPI_DirectRead | ( | spi_flash_ctrl_t * | p_ctrl, |
uint8_t *const | p_dest, | ||
uint32_t const | bytes | ||
) |
Reads raw data directly from the QSPI.
Implements spi_flash_api_t::directRead.
FSP_ERR_UNSUPPORTED | API not supported. |
fsp_err_t R_XSPI_QSPI_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 MCU peripheral. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_INVALID_ARGUMENT | Invalid SPI protocol requested. |
fsp_err_t R_XSPI_QSPI_XipEnter | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Enters XIP (execute in place) mode.
Implements spi_flash_api_t::xipEnter.
FSP_SUCCESS | The flash was programmed successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_XSPI_QSPI_XipExit | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Exits XIP (execute in place) mode.
Implements spi_flash_api_t::xipExit.
FSP_SUCCESS | The flash was programmed successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_XSPI_QSPI_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_SUCCESS | The flash was programmed successfully. |
FSP_ERR_ASSERTION | p_instance_ctrl, p_dest or p_src is NULL, or byte_count crosses a page boundary. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_INVALID_MODE | This function can't be called when XIP mode is enabled. |
FSP_ERR_DEVICE_BUSY | The device is busy. |
FSP_ERR_WRITE_FAILED | Write operation failed. |
fsp_err_t R_XSPI_QSPI_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_SUCCESS | The command to erase the flash was executed successfully. |
FSP_ERR_ASSERTION | p_instance_ctrl or p_device_address is NULL, or byte_count doesn't match an erase size defined in spi_flash_cfg_t, or device is in XIP mode. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_INVALID_MODE | This function can't be called when XIP mode is enabled. |
FSP_ERR_DEVICE_BUSY | The device is busy. |
FSP_ERR_WRITE_FAILED | Write operation failed. |
fsp_err_t R_XSPI_QSPI_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_SUCCESS | The write status is in p_status. |
FSP_ERR_ASSERTION | p_instance_ctrl or p_status is NULL. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_INVALID_MODE | This function can't be called when XIP mode is enabled. |
fsp_err_t R_XSPI_QSPI_BankSet | ( | spi_flash_ctrl_t * | p_ctrl, |
uint32_t | bank | ||
) |
Selects the bank to access.
Implements spi_flash_api_t::bankSet.
FSP_ERR_UNSUPPORTED | API not supported. |
fsp_err_t R_XSPI_QSPI_DirectTransfer | ( | spi_flash_ctrl_t * | p_ctrl, |
spi_flash_direct_transfer_t *const | p_transfer, | ||
spi_flash_direct_transfer_dir_t | direction | ||
) |
Read/Write raw data directly with the SerialFlash.
Implements spi_flash_api_t::directTransfer.
FSP_SUCCESS | The flash was programmed successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_INVALID_MODE | This function must be called after R_XSPI_QSPI_DirectWrite with read_after_write set to true. |
FSP_ERR_DEVICE_BUSY | The device is busy. |
fsp_err_t R_XSPI_QSPI_AutoCalibrate | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Auto-calibrate the OctaRAM device using the preamble pattern. Unsupported by XSPI_QSPI. Implements spi_flash_api_t::autoCalibrate.
FSP_ERR_UNSUPPORTED | API not supported by XSPI_QSPI |