RZV Flexible Software Package Documentation
Release v3.0.0
|
|
Driver for the xSPI peripheral on RZ MPUs. This module implements the SPI Flash Interface.
The xSPI QSPI driver has the following key features:
Configuration | Options | Default | Description |
---|---|---|---|
Memory-mapping Support > Prefetch Function |
| Disable | Enable prefetch function on memory-mapped reads. |
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_qspi0 | Module name. |
General > unit | Unit should be 0 | 0 | Specify the xSPI unit number. |
General > Chip Select |
| Chip Select 0 | Specify the XSPI chip select line to use. |
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 RZV Configuration tool for available options. | 0 | 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 RZV 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 |
Extra > Stop controller on close |
| False | Define to stop controller on close |
Extra > Pre initialize function | Name must be a valid C symbol | NULL | Function name or "NULL" |
Extra > Post initialize function | Name must be a valid C symbol | NULL | Function name or "NULL" |
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 0x70000000(Non-secure External address space) or 0x60000000(Secure External address space).
The address map for the external address space xSPI is as follows:
Address | Space |
---|---|
0x60000000 to 0x67FFFFFF | CS0 Secure space |
0x68000000 to 0x6FFFFFFF | CS1 Secure space |
0x70000000 to 0x77FFFFFF | CS0 Non-secure space |
0x78000000 to 0x7FFFFFFF | CS1 Non-secure space |
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.
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 |
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.
Example:
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.
Example:
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_t R_XSPI_QSPI_AutoCalibrate | ( | spi_flash_ctrl_t * | p_ctrl | ) |
AutoCalibrate the SPI flash driver module.
Implements spi_flash_api_t::autoCalibrate.
FSP_ERR_UNSUPPORTED | API not supported. |