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 OSPI peripheral interfaces with an external OctaFlash chip to perform data I/O Operations.
The OSPI 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. |
Configuration | Options | Default | Description |
---|---|---|---|
General > Name | Name must be a valid C symbol | g_ospi0 | Module name. |
General > Unit | Unit should be 0 or 1 | 0 | Specify the XSPI unit number. |
General > Chip Select |
| Chip Select 0 | Specify the OSPI chip select line to use. |
General > Flash Size |
| 64MB | Specify the OctaFlash size. |
General > SPI Protocol |
| 1S-1S-1S (SPI) | Select the initial SPI protocol. SPI protocol can be changed in R_XSPI_OSPI_SpiProtocolSet(). |
General > Address Bytes |
| 4 | Select the number of address bytes. |
8D-8D-8D(OPI) Mode > Auto-Calibration > Data latching delay | Must be a valid non-negative integer | 0x08 | Set this to 0 to enable auto-calibration. 0x08 is the default value |
8D-8D-8D(OPI) Mode > Auto-Calibration > Auto-Calibration Address | Must be a valid non-negative integer | 0x00 | Set the address of the read/write destination to be performed for auto-calibration. |
8D-8D-8D(OPI) Mode > Command Definitions > Page Program Command | Manual Entry | 0x12ED | The command to program a page in 8D-8D-8D(OPI) Mode. |
8D-8D-8D(OPI) Mode > Command Definitions > Dual Read Command | Manual Entry | 0xEE11 | The command to read in 8D-8D-8D(OPI) Mode (8DTRD). |
8D-8D-8D(OPI) Mode > Command Definitions > Write Enable Command | Manual Entry | 0x06F9 | The command to enable write in 8D-8D-8D(OPI) Mode. |
8D-8D-8D(OPI) Mode > Command Definitions > Status Command | Manual Entry | 0x05FA | The command to query the status of a write or erase command in 8D-8D-8D(OPI) Mode. |
8D-8D-8D(OPI) Mode > Command Length Bytes | Must be an integer between 1 and 2 | 2 | Command length in bytes |
8D-8D-8D(OPI) Mode > Memory Read Dummy Cycles | Must be an integer between 0 and 31 | 10 | Memory read dummy cycles |
8D-8D-8D(OPI) Mode > Byte Order |
| Byte0, Byte1, Byte2, Byte3 | Byte order on the external bus. Note: When accesses without API (with memory mapping), the byte order is limited to Byte0, Byte1, Byte2, Byte3. |
1S-1S-1S (SPI) Mode > Command Definitions > Page Program Command | Manual Entry | 0x12 | The command to program a page in 1S-1S-1S (SPI) Mode. |
1S-1S-1S (SPI) Mode > Command Definitions > Read Command | Manual Entry | 0x13 | The command to read in 1S-1S-1S (SPI) Mode. |
1S-1S-1S (SPI) Mode > Command Definitions > Write Enable Command | Manual Entry | 0x06 | The command to enable write in 1S-1S-1S (SPI) Mode. |
1S-1S-1S (SPI) Mode > Command Definitions > Status Command | Manual Entry | 0x05 | The command to query the status of a write or erase command in 1S-1S-1S (SPI) Mode. |
Common Command Definitions > Sector Erase Command | Manual Entry | 0x21DE | The command to erase a sector. Set Sector Erase Size to 0 if unused. |
Common Command Definitions > Block Erase Command | Manual Entry | 0xDC23 | The command to erase a block. Set Block Erase Size to 0 if unused. |
Common Command Definitions > Chip Erase Command | Manual Entry | 0xC738 | The command to erase the entire chip. Set Chip Erase Command to 0 if unused. |
Common 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. |
Common 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. |
Common 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. |
Chip Select Timing Setting > Command Interval | Refer to the RZT Configuration tool for available options. | 7 CYCLES | Define the CS minimum idle term. |
Chip Select Timing Setting > Pull-up Timing |
| No Extension | Define the CS negating extension |
Chip Select Timing Setting > Pull-down Timing |
| No Extension | Define the CS asserting extension |
The XSPI_CLKn frequencies can be set on 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 OSPI device:
After R_XSPI_OSPI_Open() completes successfully, the OctaFlash device contents are mapped to address 0x60000000 (unit 0) or 0x68000000 (unit 1) based on the unit configured and can be read like on-chip flash. When not using the cache, access the OctaFlash device via the mirror space 0x40000000 (unit 0) or 0x48000000 (unit 1). Unit 0 and Unit 1 support 128 MB of address 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 |
Auto-calibration procedure is triggered automatically when the 'Data latching delay' field in the configurator properties is set to 0. The user application is responsible for setting the appropriate preamble pattern before calling R_XSPI_OSPI_Open() with 8D-8D-8D(OPI) mode or changing the SPI protocol to 8D-8D-8D(OPI) using R_XSPI_OSPI_SpiProtocolSet() API. The appropriate preamble pattern can be written to the desired address using the R_XSPI_OSPI_Write() API while in the 1S-1S-1S(SPI) mode. Ensure that the same address is passed through the configurator. If the OctaFlash chip is already in 8D-8D-8D(OPI) mode, the preamble pattern must be programmed using the debugger before calling R_XSPI_OSPI_Open().
Chip select latencies can be set through the configurator. The default settings support 1S-1S-1S(SPI) at minimum latency. In case the driver is opened in 1S-1S-1S(SPI) mode and will be switched to 8D-8D-8D(OPI) mode later using R_XSPI_OSPI_SpiProtocolSet(), please select latencies required for 8D-8D-8D(OPI) before calling R_XSPI_OSPI_Open().
When using the IAR compiler, OSPI data must be const
qualified to be downloaded by the debugger.
This is a basic example of minimal use of the OSPI 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 using R_XSPI_OSPI_DirectTransfer with write direction followed by R_XSPI_OSPI_DirectTransfer with read direction to send the write enable command and read back the status register from the device.
This is an example of using R_XSPI_OSPI_SpiProtocolSet to change the operating mode from 1S-1S-1S(SPI) to 8D-8D-8D(OPI) and the specific configuration procedure for OctaFlash.
This is an example of using R_XSPI_OSPI_SpiProtocolSet to change the operating mode from 1S-1S-1S(SPI) to 8D-8D-8D(OPI) and allow the driver to initiate auto-calibration.
This is an example of using R_CGC_SystemClockSet to change the Octal-SPI clock frequency during run time. The xSPI_CLK frequency must be updated before calling the R_XSPI_OSPI_SpiProtocolSet with appropriate clock source and divider settings required to be set for the new SPI protocol mode. Ensure that the clock source selected is started.
This is an example of using R_XSPI_OSPI_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_OSPI_DirectTransfer() instead of R_XSPI_OSPI_Write().
Data Structures | |
struct | xspi_ospi_instance_ctrl_t |
Enumerations | |
enum | xspi_ospi_chip_select_t |
enum | xspi_ospi_memory_size_t |
enum | xspi_ospi_command_interval_clocks_t |
enum | xspi_ospi_cs_pullup_clocks_t |
enum | xspi_ospi_cs_pulldown_clocks_t |
enum | xspi_ospi_prefetch_function_t |
enum | xspi_ospi_io_voltage_t |
enum | xspi_ospi_byte_order_t |
struct xspi_ospi_instance_ctrl_t |
Instance control block. DO NOT INITIALIZE. Initialization occurs when spi_flash_api_t::open is called
fsp_err_t R_XSPI_OSPI_Open | ( | spi_flash_ctrl_t * | p_ctrl, |
spi_flash_cfg_t const *const | p_cfg | ||
) |
Open the OSPI driver module. After the driver is open, the OSPI 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_CALIBRATE_FAILED | Failed to perform auto-calibrate. |
fsp_err_t R_XSPI_OSPI_Close | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Close the OSPI 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_OSPI_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_OSPI_DirectTransfer
Implements spi_flash_api_t::directWrite.
FSP_ERR_UNSUPPORTED | API not supported by OSPI. |
fsp_err_t R_XSPI_OSPI_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_OSPI_DirectTransfer.
Implements spi_flash_api_t::directRead.
FSP_ERR_UNSUPPORTED | API not supported by OSPI. |
fsp_err_t R_XSPI_OSPI_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_CALIBRATE_FAILED | Failed to perform auto-calibrate. |
fsp_err_t R_XSPI_OSPI_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 OSPI. |
fsp_err_t R_XSPI_OSPI_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 OSPI. |
fsp_err_t R_XSPI_OSPI_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_DEVICE_BUSY | Another Write/Erase transaction is in progress. |
fsp_err_t R_XSPI_OSPI_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, byte_count doesn't match an erase size defined in spi_flash_cfg_t, or byte_count is set to 0. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_DEVICE_BUSY | The device is busy. |
fsp_err_t R_XSPI_OSPI_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_t R_XSPI_OSPI_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 by OSPI. |
fsp_err_t R_XSPI_OSPI_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 OctaFlash.
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_t R_XSPI_OSPI_AutoCalibrate | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Auto-calibrate the OctaRAM device using the preamble pattern. Unsupported by XSPI_OSPI.
Implements spi_flash_api_t::autoCalibrate.
FSP_ERR_UNSUPPORTED | API not supported by XSPI_OSPI |