RZT Flexible Software Package Documentation
Release v2.2.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 |
---|---|---|---|
Custom Address Space > Unit0 > CS0 > Start Address | MCU Specific Options | Start address of xSPI Unit0 CS0 in memory mapping mode. | |
Custom Address Space > Unit0 > CS0 > End Address | Address should be within xspi unit0 external address space | 0x600FFFFF | End address of xSPI Unit0 CS1 in memory mapping mode. |
Custom Address Space > Unit0 > CS1 > Start Address | Address should be within xspi unit0 external address space | 0x64000000 | Start address of xSPI Unit0 CS1 in memory mapping mode. |
Custom Address Space > Unit0 > CS1 > End Address | Address should be within xspi unit0 external address space | 0x640FFFFF | End address of xSPI Unit0 CS1 in memory mapping mode. |
Custom Address Space > Unit1 > CS0 > Start Address | MCU Specific Options | Start address of xSPI Unit1 CS0 in memory mapping mode. | |
Custom Address Space > Unit1 > CS0 > End Address | Address should be within xspi unit1 external address space | 0x680FFFFF | End address of xSPI Unit1 CS0 in memory mapping mode. |
Custom Address Space > Unit1 > CS1 > Start Address | Address should be within xspi unit1 external address space | 0x6C000000 | Start address of xSPI Unit1 CS1 in memory mapping mode. |
Custom Address Space > Unit1 > CS1 > End Address | Address should be within xspi unit1 external address space | 0x6C0FFFFF | End address of xSPI Unit1 CS1 in memory mapping mode. |
Custom Address Space > Custom Address Space Enable | MCU Specific Options | When disabled, Custom Address Space is not applied and address space is set according to Flash Size. When enabled, Flash Size is disabled and Custom Address Space settings are applied. | |
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 Unit0. | |
Unit 1 IO voltage | MCU Specific Options | Voltage setting of xSPI Unit1. | |
OTFD Support |
| Disabled | 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 |
| 1MB | Specify the SerialFlash 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 > 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 address 0x60000000(External address space xSPIn) or 0x40000000(Mirror space of external address space xSPIn) and can be read like on-chip flash.
When not using the cache, access the memory via the mirror space.
The address map details for the external address space xSPI in RZ/T2M and RZ/T2L is as follows:
Address | Space |
---|---|
0x40000000 to 0x43FFFFFF | unit 0 CS0 mirror space |
0x44000000 to 0x47FFFFFF | unit 0 CS1 mirror space |
0x48000000 to 0x4BFFFFFF | unit 1 CS0 mirror space |
0x4C000000 to 0x4FFFFFFF | unit 1 CS1 mirror space |
0x60000000 to 0x63FFFFFF | unit 0 CS0 |
0x64000000 to 0x67FFFFFF | unit 0 CS1 |
0x68000000 to 0x6BFFFFFF | unit 1 CS0 |
0x6C000000 to 0x6FFFFFFF | unit 1 CS1 |
The address map for the external address space xSPI in RZ/T2ME is as follows:
Address | Space |
---|---|
0x40000000 to 0x47FFFFFF | unit 0 CS0 mirror space + unit 0 CS1 mirror space |
0x48000000 to 0x4FFFFFFF | unit 1 CS0 mirror space + unit 1 CS1 mirror space |
0x60000000 to 0x67FFFFFF | unit 0 CS0 + unit 0 CS1 |
0x68000000 to 0x6FFFFFFF | unit 1 CS0 + unit 1 CS1 |
The address map for the external address space xSPI in RZ/T2H is as follows:
| Address | Space | | 0x40000000 to 0x4FFFFFFF | unit 0 CS0 + unit 0 CS1 | | 0x50000000 to 0x5FFFFFFF | unit 1 CS0 + unit 1 CS1 |
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_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 starting at address 0x60000000 or 0x40000000.
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_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_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 |