RZ/A Flexible Software Package Documentation
Release v3.3.0
|
|
Driver for the SPIBSC peripheral on RZ MPUs. This module implements the SPI Flash Interface.
The SPIBSC driver has the following key features:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
SPIBSC initialization |
| Disable | Whether or not to enable initialization of SPIBSC or not. |
Configuration | Options | Default | Description |
---|---|---|---|
General > Name | Name must be a valid C symbol | g_spi_flash0 | Module name. |
General > SPI Protocol | Extended SPI | Extended SPI | Select the initial SPI protocol. |
General > Address Bytes |
| 3 | Select the number of address bytes. Selecting '4 with 4-byte read code' converts the default read code determined in Read Mode to the 4-byte version. If 4-byte mode is selected without using 4-byte commands, the application must issue the EN4B command using R_SPIBSC_Direct(). |
General > Read Mode |
| Fast Read Quad I/O | Select the read mode for memory mapped access. |
General > Dummy Clocks for Fast Read | Refer to the RZA Configuration tool for available options. | Default | Select the number of dummy clocks for fast read operations. Default is 6 clocks for Fast Read Quad I/O, and 8 clocks for other fast read instructions including Fast Read Quad Output, and Fast Read |
General > Page Size Bytes | Must be an integer greater than 0 | 256 | The maximum number of bytes allowed for a single write. |
Command Definitions > Read Command | Must be an 8-bit Read Command under Command Definitions | 0x00 | The Read command. Set Read Command to 0 if selected by Read Mode and Address Bytes. |
Command Definitions > Page Program Command | Must be an 8-bit Page Program Command under Command Definitions | 0x33 | The command to program a page. |
Command Definitions > Page Program Address Lines |
| 4 | Select the number of lines to use for the address bytes during write operations. This can be determined by referencing the datasheet for the flash memory device. |
Command Definitions > Write Enable Command | Must be an 8-bit Write Enable Command under Command Definitions | 0x06 | The command to enable write. |
Command Definitions > Read Status Command | Must be an 8-bit Read Status Command under Command Definitions | 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 Read Status Command. |
Command Definitions > Erase Command #1 | Must be an 8-bit Erase Command under Command Definitions | 0x20 | The command to erase #1. Set Erase Size #1 to 0 if unused. |
Command Definitions > Erase Size #1 | Must be an integer greater than or equal to 0 | 4096 | The erase size #1. Set Erase Size #1 to 0 if Erase #1 is not supported. |
Command Definitions > Erase Command #2 | Must be an 8-bit Erase Command under Command Definitions | 0x52 | The command to erase #2. Set Erase Size #2 to 0 if unused. |
Command Definitions > Erase Size #2 | Must be an integer greater than or equal to 0 | 32768 | The erase size #2. Set Erase Size #2 to 0 if Erase #2 is not supported. |
Command Definitions > Erase Command #3 | Must be an 8-bit Erase Command under Command Definitions | 0xD8 | The command to erase #3. Set Erase Size #3 to 0 if unused. |
Command Definitions > Erase Size #3 | Must be an integer greater than or equal to 0 | 65536 | The erase size #3. Set Erase Size #3 to 0 if Erase #3 is not supported. |
Command Definitions > Chip Erase Command | Must be an 8-bit Chip Erase Command under Command Definitions | 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 XIP Enter M7-M0 command under Command Definitions | 0xa5 | How to set M7-M0 to enter XIP mode. |
Command Definitions > XIP Exit M7-M0 | Must be an 8-bit XIP Exit M7-M0 command under Command Definitions | 0x00 | How to set M7-M0 exit XIP mode. |
Bus Parameter > IO2 Fix Enable |
| Disable | Enable or not the IO2 level will fix during idle state. |
Bus Parameter > IO2 Fix Value |
| 1 (High) | Value for IO2 level fix state. |
Bus Parameter > IO3 Fix Enable |
| Enable | Enable or not the IO3 level will fix during idle state. |
Bus Parameter > IO3 Fix Value |
| 1 (High) | Value for IO3 level fix state. |
Bus Timing > Select to Clock Delay Cycles |
| 1.5 cycle | Define the cycles that begin the SCLK from SSL start. |
Bus Timing > Clock Low to De-select Delay Cycles |
| 1 cycle | Define the cycles that stop the SSL from last SCLK is out. |
Bus Timing > De-select to Select Delay Cycles |
| 5 cycle | Define the cycles that starts the new SSL from previous SSL finished. |
The QSPI clock is derived from SPI1φ.
Desired SPI frequency | 2nd parameter | 3rd parameter |
---|---|---|
66.625MHz | 0 | 1 |
50MHz | 1 | 1 |
33.3125MHz | 0 | 2 |
25MHz | 1 | 2 |
16.65625MHz | 0 | 3 |
12.5MHz | 1 | 3 |
4.1640625MHz | 0 | 4 |
3.125MHz | 1 | 4 |
RZ MPUs provide these pins as dedicated.
The IPL already enables as memory-mapped access. By the default, R_SPIBSC_Open() does nothing to configure and only prepare to erase/write.
Developers should be aware of the following limitations when using the SPIBSC driver:
This is a basic write example in an application.
Some flash memories may be polled alternated ways for the "write in progress" status. In this case, developers implement their StatusGet function. There is an example of implementing the StatusGet function using R_SPIBSC_DirectTransfer API.
This is an example of using R_SPIBSC_DirectTransfer to query the device size.
Data Structures | |
struct | spibsc_instance_ctrl_t |
struct spibsc_instance_ctrl_t |
Instance control block. DO NOT INITIALIZE. Initialization occurs when spi_flash_api_t::open is called
fsp_err_t R_SPIBSC_Open | ( | spi_flash_ctrl_t * | p_api_ctrl, |
spi_flash_cfg_t const *const | p_cfg | ||
) |
Open the SPIBSC driver module.
Implements spi_flash_api_t::open.
FSP_SUCCESS | Configuration was successful. |
FSP_ERR_ASSERTION | The parameter p_api_ctrl or p_cfg is NULL. |
FSP_ERR_UNSUPPORTED | One or more parameters in p_cfg are not supported by this implementation. |
FSP_ERR_OUT_OF_MEMORY | Memory allocation error. |
FSP_ERR_INVALID_SIZE | Page size is not specified. |
FSP_ERR_INVALID_POINTER | Pointer points to invalid memory location. |
FSP_ERR_INVALID_MODE | This function can't be called when XIP mode is enabled. |
FSP_ERR_ALREADY_OPEN | Driver has already been opened with the same p_api_ctrl. |
fsp_err_t R_SPIBSC_Close | ( | spi_flash_ctrl_t * | p_api_ctrl | ) |
Close the SPIBSC driver module.
Implements spi_flash_api_t::close.
FSP_SUCCESS | Configuration was successful. |
FSP_ERR_ASSERTION | p_api_ctrl is NULL. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_SPIBSC_DirectWrite | ( | spi_flash_ctrl_t * | p_api_ctrl, |
uint8_t const *const | p_src, | ||
uint32_t const | bytes, | ||
bool const | read_after_write | ||
) |
DEPRECATED: Writes raw data directly to the flash device.
Implements spi_flash_api_t::directWrite.
FSP_SUCCESS | The flash was programmed successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_UNSUPPORTED | Read-after-write is not supported by this implementation. |
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_SPIBSC_DirectRead | ( | spi_flash_ctrl_t * | p_api_ctrl, |
uint8_t *const | p_dest, | ||
uint32_t const | bytes | ||
) |
Reads raw data directly from the flash device. Unsupported by SPIBSC.
Implements spi_flash_api_t::directRead.
FSP_ERR_UNSUPPORTED | API not supported by SPIBSC. |
fsp_err_t R_SPIBSC_SpiProtocolSet | ( | spi_flash_ctrl_t * | p_api_ctrl, |
spi_flash_protocol_t | spi_protocol | ||
) |
Sets the SPI protocol.
Implements spi_flash_api_t::spiProtocolSet.
FSP_ERR_UNSUPPORTED | API not supported by SPIBSC |
fsp_err_t R_SPIBSC_XipEnter | ( | spi_flash_ctrl_t * | p_api_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_INVALID_MODE | This function can't be called when already enabled or not 4-bit transfer. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_SPIBSC_XipExit | ( | spi_flash_ctrl_t * | p_api_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_INVALID_MODE | This function can't be called when XIP mode is enabled. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_SPIBSC_Write | ( | spi_flash_ctrl_t * | p_api_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_api_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_t R_SPIBSC_Erase | ( | spi_flash_ctrl_t * | p_api_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_api_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_t R_SPIBSC_StatusGet | ( | spi_flash_ctrl_t * | p_api_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_api_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_SPIBSC_BankSet | ( | spi_flash_ctrl_t * | p_api_ctrl, |
uint32_t | bank | ||
) |
Selects the bank to access. A bank is a 256Mega-byte access window into the SPI Multi area. To access device address 0x10000000, select bank 1, then read from address 0x20000000(physical). To access device address 0x20001000, select bank 2, then read from address 0x20001000(physical).
This function is not required for memory devices less than or equal to 256Mega-byte.
Implements spi_flash_api_t::bankSet.
FSP_SUCCESS | Bank successfully selected. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_INVALID_ARGUMENT | "bank" is invalid. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_SPIBSC_DirectTransfer | ( | spi_flash_ctrl_t * | p_api_ctrl, |
spi_flash_direct_transfer_t *const | p_transfer, | ||
spi_flash_direct_transfer_dir_t | direction | ||
) |
Read/Write raw data directly with the flash device.
Implements spi_flash_api_t::directTransfer.
FSP_SUCCESS | The flash was programmed successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_INVALID_MODE | This function can't be called when XIP mode is enabled. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
fsp_err_t R_SPIBSC_AutoCalibrate | ( | spi_flash_ctrl_t * | p_api_ctrl | ) |
Auto-calibrate the OctaRAM device using the preamble pattern. Unsupported by SPIBSC.
Implements spi_flash_api_t::autoCalibrate.
FSP_ERR_UNSUPPORTED | API not supported by SPIBSC |