![]() |
RAFW Flexible Software Package Documentation
Release v2.1.0
|
|
Functions | |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_DirectWrite (spi_flash_ctrl_t *p_ctrl, uint8_t const *const p_src, uint32_t const bytes, bool const read_after_write) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_DirectRead (spi_flash_ctrl_t *p_ctrl, uint8_t *const p_dest, uint32_t const bytes) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_DirectTransfer (spi_flash_ctrl_t *p_ctrl, spi_flash_direct_transfer_t *const p_transfer, spi_flash_direct_transfer_dir_t direction) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_XipEnter (spi_flash_ctrl_t *p_ctrl) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_XipExit (spi_flash_ctrl_t *p_ctrl) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_Write (spi_flash_ctrl_t *p_ctrl, uint8_t const *const p_src, uint8_t *const p_dest, uint32_t byte_count) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_Erase (spi_flash_ctrl_t *p_ctrl, uint8_t *const p_device_address, uint32_t byte_count) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_StatusGet (spi_flash_ctrl_t *p_ctrl, spi_flash_status_t *const p_status) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_BankSet (spi_flash_ctrl_t *p_ctrl, uint32_t bank) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_SpiProtocolSet (spi_flash_ctrl_t *p_ctrl, spi_flash_protocol_t spi_protocol) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_AutoCalibrate (spi_flash_ctrl_t *p_ctrl) |
| BSP_PLACE_CODE_IN_RAM fsp_err_t | R_OSPI_W_Close (spi_flash_ctrl_t *p_ctrl) |
Driver for the OSPI peripheral on RRQ MCUs. This module implements the SPI Flash Interface.
The OSPI 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. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| General | |||
| Name | Name must be a valid C symbol | g_ospi_w0 | Module name. |
| Channel | Value must be a non-negative integer | 0 | Module Channel. |
| 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_OSPI_W_Direct(). |
| Page Size Bytes | Must be an integer greater than 0 | 256 | The maximum number of bytes allowed for a single write. |
| Select Mode | MCU Specific Options | Select OSPI Mode. | |
| Drive Current | MCU Specific Options | Set the Drive Strength of the OSPI Controller. | |
| Slew Rate | MCU Specific Options | Set the Slew Rate of the OSPI Controller. | |
| SPI Clock Mode |
| High | Select the polarity of OSPI_W_CLK when OSPI_W_CS is high. |
| Wrap Mode | MCU Specific Options | Select if Wrapping Burst is enabled. | |
| Memory Burst Length | MCU Specific Options | Set the external memory burst length of the OSPI Controller. | |
| Instructions Bus Lines |
| 1 | Select the number of lines to use for instructions during operations. This can be determined by referencing the datasheet for the external flash. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Address and Data Bus Lines |
| 4 | Select the number of lines to use for the address and data bytes during operations. This can be determined by referencing the datasheet for the external flash. It should either be 1 or match the number of data lines used for memory mapped fast read operations. |
| Flash Boot Configuration Command | |||
| Flash Boot Configuration Command > Command definition | |||
| Flash Boot Configuration Command > Command definition > Command0 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x31 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x02 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 2 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command1 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command2 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command3 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command4 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command5 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command6 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Flash Boot Configuration Command > Command definition > Command7 | |||
| Opcode | Must be an 8-bit command under Command Definitions | 0x00 | An operation code for a command sent to the FLASH connected at boot time. |
| Data0-3 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (0–3 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Data4-7 | Must be an 8-bit array and 4 bytes or less in size. | 0x00 | Command data (4–7 bytes). These are byte arrays, not integers. Example: 0x001234 -> [0x00, 0x12, 0x34], 0x001 -> [0x00, 0x01]. |
| Opcode+Data Length | The valid range is 0 to 9. | 0 | Number of command bytes to be send to the FLASH.(Opcode+Data) If set to 0, this command is disabled. |
| Command Definitions | |||
| Command Definitions > Read Command | |||
| Read Mode Opcode | Must be an integer between 0 and 255 | 0xEB | Select the read mode for memory mapped access. |
| Read Mode Wrapping Burst Opcode | Must be an integer between 0 and 255 | 0 | Enter the read opcode for wrapping burst memory mapped access. |
| Extra Byte Value | Must be an integer between 0 and 255 | 0xFF | Enter the value for the extra byte. The extra byte value is overwritten by the XIP Enter and XIP Exit commands when the xipEnter and xipExit APIs are called. |
| Extra Byte Enable |
| Enabled | Enable the transmission of the extra byte. |
| CS High Minimum Cycles | Must be an integer between 0 and 31 | 1 | Between the transmissions of two different instructions to the memory device, the SPI bus stays in idle state (OSPI_CS high) for at least this number of OSPI_SCK clock cycles. |
| Dummy Clocks | MCU Specific Options | Select the number of dummy clocks including extra byte for fast read operations. | |
| Instruction Mode |
| TX Instr Only At First Access (Enter XIP mode by default) | Select whether you want to transmit instruction at any burst access or only in the first access after the selection of Auto Mode. |
| Length of Wrapping Burst | MCU Specific Options | Select Length of Wrapping Burst. | |
| Data Size of Wrapping Burst | MCU Specific Options | Select Data Size of Wrapping Burst. | |
| Command Definitions > Page Program Command | |||
| Page Program Command Opcode | Must be an integer between 0 and 255 | 0x32 | The command to program a page. If 'Support Multiple Line Program in Extended SPI Mode' is Enabled, this command must use the same number of data lines as the selected read mode. |
| Page Program Command Wrapping Burst Opcode | Must be an integer between 0 and 255 | 0 | Enter the page program opcode for wrapping burst memory mapped access. |
| Address Lines |
| 1 | Select the number of lines to use for the address bytes during page program operations. |
| Dummy Clock Lines |
| 1 | Select the number of lines to use for the dummy clock during page program operations. |
| Data Lines |
| 4 | Select the number of lines to use for the data bytes during page program operations. |
| CS High Minimum Cycles | Must be an integer between 0 and 31 | 1 | After the execution of the write command, the OSPI_CS remains high for at least this number of OSPI_SCK clock cycles. |
| Dummy Clocks | MCU Specific Options | Select the number of dummy clocks for page program operations. | |
| Command Definitions > Status Command | |||
| Opcode | Must be an integer between 0 and 255 | 0x05 | The command to query the status of a write or erase command. |
| Write Status Bit Pos | Must be an integer between 0 and 7 | 0 | Which bit contains the write in progress status returned from the Write Status Command. |
| Write Status Level |
| 1 | Select the Write Status bit value indicating a busy state. |
| Command Definitions > Write Enable Command | |||
| Opcode | Must be an integer between 0 and 255 | 0x06 | The command to enable write. |
| Write Enable Bit Pos | Must be an integer between 0 and 7 | 1 | This bit will wait until the write data to be available before to start sending the write command sequence. |
| Command Definitions > Erase Command | |||
| Sector Erase Opcode | Must be an integer between 0 and 255 | 0x20 | The command to erase a sector. Set Sector Erase Size to 0 if unused. |
| 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. |
| Block Erase Opcode | Must be an integer between 0 and 255 | 0xD8 | The command to erase a block. Set Block Erase Size to 0 if unused. |
| 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. |
| Block Erase 32KB Opcode | Must be an integer between 0 and 255 | 0x52 | The command to erase a 32KB block. Set Block Erase Size to 0 if unused. |
| 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. |
| Chip Erase Opcode | Must be an integer between 0 and 255 | 0xC7 | The command to erase the entire chip. Set Chip Erase Command to 0 if unused. |
| Command Definitions > XIP Command | |||
| Enter Command | Must be an integer between 0 and 255 | 0xA5 | How to set M7-M0 to enter XIP mode. |
| Exit Command | Must be an integer between 0 and 255 | 0xFF | How to set M7-M0 exit XIP mode. |
| Command Definitions > QPI Command | |||
| QPI Enter Opcode | Must be an 8-bit OSPI QPI Enter command under Command Definitions | 0x38 | The command to enter QPI mode. |
| QPI Exit Opcode | Must be an 8-bit OSPI QPI Exit command under Command Definitions | 0xFF | The command to exit QPI mode. |
The OSPI clock is derived from SYS_CLK.
The following pins are available to connect to an external OSPI device:
The contents of the external flash device are mapped to the address defined by BSP_FEATURE_OSPI_DEVICE_0_START_ADDRESS and can be read.
The OSPI driver does not support Octa flash yet. It supports QSPI and SPI flash.
This is a basic example of minimal use of the OSPI in an application.
This is an example of the types of commands that can be used to initialize the OSPI.
This is an example of using R_OSPI_W_DirectTransfer to send the read status register command and read back the status register from the device.
This is an example of using R_OSPI_W_DirectTransfer to query the device size.
Data Structures | |
| struct | ospi_w_read_instr_cfg_t |
| struct | ospi_w_read_status_instr_cfg_t |
| struct | ospi_w_erase_instr_cfg_t |
| struct | ospi_w_suspend_resume_instr_cfg_t |
| struct | ospi_w_break_instr_cfg_t |
| struct | ospi_w_memblen_cfg_t |
| struct | ospi_w_write_instr_cfg_t |
| struct | ospi_w_write_enable_instr_cfg_t |
| struct | ospi_w_ctrl_ddr_cfg_t |
| struct | ospi_w_extra_registers_cfg_t |
| struct | ospi_w_qpi_instr_cfg_t |
| struct | ospi_w_flash_cfg_t |
| struct | ospi_w_extended_cfg_t |
| struct | ospi_w_instance_ctrl_t |
Enumerations | |
| enum | ospi_w_access_mode_t |
| enum | ospi_w_bus_mode_t |
| enum | ospi_w_clk_div_t |
| enum | ospi_w_ers_t |
| enum | ospi_w_clk_mode_t |
| enum | ospi_w_drive_current_t |
| enum | ospi_w_read_pipe_t |
| enum | ospi_w_read_pipe_delay_t |
| enum | ospi_w_slew_rate_t |
| enum | ospi_w_hready_mode_t |
| enum | ospi_w_instr_md_t |
| enum | ospi_w_wrap_md_t |
| enum | ospi_w_wrap_wr_en_t |
| enum | ospi_w_rd_bend_md_t |
| enum | ospi_w_rd_rdb_en_t |
| enum | ospi_w_extra_byte_t |
| enum | ospi_w_extra_byte_half_t |
| enum | ospi_w_break_t |
| enum | ospi_w_break_sec_hf_t |
| enum | ospi_w_t_cem_t |
| enum | ospi_w_memblen_burst_t |
| enum | ospi_w_sampling_edge_t |
| enum | ospi_w_mode_t |
| enum | ospi_w_busy_level_t |
| enum | ospi_w_stsdly_sel_t |
| enum | ospi_w_dummy_value_t |
| enum | ospi_w_idx_bus_mode_t |
| struct ospi_w_read_instr_cfg_t |
Read instruction configuration structure (auto access mode).
| Data Fields | ||
|---|---|---|
| uint8_t | opcode | Read command opcode for Incremental Burst or Single read access. |
| uint8_t | opcode_wb | Read command opcode for Wrapping Burst. |
| uint8_t | extra_byte_value | Extra Byte value. |
| ospi_w_bus_mode_t | opcode_bus_mode: 2 | Bus mode of the opcode phase. |
| ospi_w_bus_mode_t | addr_bus_mode: 2 | Bus mode of the address phase. |
| ospi_w_bus_mode_t | extra_byte_bus_mode: 2 | Bus mode of the extra byte phase. |
| ospi_w_bus_mode_t | dummy_bus_mode: 2 | Bus mode of the dummy phase. |
| ospi_w_bus_mode_t | data_bus_mode: 2 | Bus mode of the data phase. |
| ospi_w_extra_byte_t | extra_byte_en: 1 | Enable Extra Byte. |
| ospi_w_extra_byte_half_t | extra_byte_half_cfg: 1 | Enable Extra Byte Half. |
| uint8_t | dummy_bytes: 5 | The number of dummy bytes. Valid values are 0..31 i.e. 1..32 dummy bytes. |
| bool | dummy_en | Enable dummy bytes. |
| ospi_w_instr_md_t | instr_md: 1 | Instruction mode. |
| ospi_w_wrap_md_t | wrap_md: 1 | Wrap mode enable bit. |
| uint8_t | wrap_blen: 3 | It describes the length in number of bytes of the selected wrapping burst(see also the register OSPIC_WRAP_MD). |
| uint8_t | wrap_size: 2 | Selected data size of a wrapping burst. |
| ospi_w_wrap_wr_en_t | wrap_wr_en: 1 | By setting (1) this bit, any write wrapping burst will be implemented by using a special write instruction. |
| uint8_t | cs_high_min_cycles: 5 | The SPI bus stays in idle state (OSPI_CS high) for at least this number of OSPI_SCK clock cycles between two consecutive read commands. |
| ospi_w_rd_bend_md_t | rd_bend_md: 1 | Defines the behavior of the controller when a read burst is terminated early in the AMBA bus. |
| ospi_w_rd_rdb_en_t | rd_rdb_en: 1 | Write 1 to set the read pipeline in burst mode while are retrieved the data of the memory device. |
| struct ospi_w_read_status_instr_cfg_t |
OSPIF read status instruction configuration structure (auto access mode).
| Data Fields | ||
|---|---|---|
| uint8_t | opcode | Read Status command opcode. |
| ospi_w_bus_mode_t | opcode_bus_mode: 2 | The bus mode of the opcode phase. |
| ospi_w_bus_mode_t | receive_bus_mode: 2 | The bus mode of the receive data phase. |
| uint32_t | busy_pos: 3 | The position of the Busy bit in the status register (0 - 7). |
| uint8_t | delay_cycles: 7 | The minimum delay in clock cycles between a Read Status command and the previous Erase command. Usually NOT needed thus is set equal to 0. |
| ospi_w_stsdly_sel_t | stsdly_sel: 1 | Select the timer which is used to count the delay before reading the flash status register, after an erase or an erase resume command. |
| ospi_w_busy_level_t | busy_level: 1 | Busy bit level. |
| uint8_t | rstat_dmy_num: 4 | Number of dummy bytes (minus 1). |
| ospi_w_bus_mode_t | dummy_bus_mode: 2 | The bus mode of the dummy data phase. |
| ospi_w_dummy_value_t | dummy_value: 1 | Define the value that is transferred on the SPI bus during the phase of the dummy bytes. |
| bool | rstat_dmy_en | Enables the transmission of dummy bytes, immediately after the instruction code of the read status command. |
| bool | rstat_rdb_en | If enabled, sets the read pipeline in burst mode while is retrieved the status of the memory device. |
| bool | rstat_split_en | If enabled, a long sequence for the continuous reading of the status register will be divided into individual accesses. |
| bool | rstat_req | If enabled, the value of the status register of the memory device will be retrieved. |
| struct ospi_w_erase_instr_cfg_t |
OSPIF Erase instruction configuration structure (auto access mode).
| Data Fields | ||
|---|---|---|
| ospi_w_bus_mode_t | opcode_bus_mode: 2 | Bus mode of the opcode phase. |
| ospi_w_bus_mode_t | addr_bus_mode: 2 | Bus mode of the address phase. |
| uint32_t | hclk_cycles: 4 | The number of AMBA AHB hclk cycles (0..15) without memory read requests before executing an erase or erase resume command. Use this setting to delay one of the aforementioned commands otherwise keep it 0. |
| uint8_t | opcode | Erase command opcode. |
| uint8_t | cs_idle_delay_cycles: 5 | The minimum CS idle delay in clock cycles (< 32) between a Write Enable, Erase, Erase Suspend or Erase Resume command and the next consecutive command. |
| struct ospi_w_suspend_resume_instr_cfg_t |
OSPIF Erase suspend/resume instruction structure (auto access mode).
| Data Fields | ||
|---|---|---|
| ospi_w_bus_mode_t | suspend_bus_mode: 2 | Bus mode during the erase suspend command phase. |
| ospi_w_bus_mode_t | resume_bus_mode: 2 | Bus mode during the erase resume command phase. |
| uint8_t | suspend_opcode | Erase suspend instruction code. |
| uint8_t | resume_opcode | Erase resume instruction code. |
| uint8_t | res_sus_latency_clk_cycles: 6 | The minimum required latency (clock cycles) between an erase resume and the next consequent erase suspend command. |
| uint8_t | sussts_dly: 6 | Defines a timer that counts the minimum allowed delay between an erase suspend command and the next read status command. |
| struct ospi_w_break_instr_cfg_t |
OSPIF Read break sequence structure (auto access mode).
| Data Fields | ||
|---|---|---|
| uint16_t | break_opcode | The code value of the read break instruction. |
| uint8_t | break_sz: 4 | The size of Burst Break Sequence 1..16 bytes. |
| ospi_w_bus_mode_t | break_tx_md: 2 | The mode of the OSPI Bus during the transmission of the burst break sequence. |
| ospi_w_break_sec_hf_t | break_sec_hf: 1 | Disable output during the transmission of the second half. |
| ospi_w_break_t | break_en: 1 | Controls the application of a special command (read burst break sequence) that is used in order to force the device to abandon the continuous read mode. |
| struct ospi_w_memblen_cfg_t |
OSPIF External memory burst length configuration.
| Data Fields | ||
|---|---|---|
| ospi_w_memblen_burst_t | memblen: 4 | In this register is defined the expected behavior of the external memory device regarding the length of a burst operation. |
| uint16_t | tcem_cc: 12 | Defines the maximum allowed time tCEM for which the OSPIC_CS can stay active (when tcem_en=1). |
| ospi_w_t_cem_t | tcem_en: 1 | This bit enables the controlling of the maximum time tCEM for which the OSPI_CS remains active (auto mode and PSRAM). |
| bool | rd_lin_en: 1 | By setting (1) in this bit the access limits that are set with the OSPIC_MEMBLEN are ignored for the read operation. |
| bool | keep_active: 1 | By setting (1) in this bit the controller will keep the access active in order to serve consecutive accesses, without toggling the chip select of the memory,when this is possible. |
| bool | wcmd_hybrid: 1 | By setting (1) in this bit, the special commands that used during wrap bursts. |
| uint8_t | dielen: 4 | The size of each die from which the memory device is consisted. |
| uint8_t | active_thr: 4 | Defines the maximum number of AHB clock cycles for which the memory should stay without access, before the active access to be aborted. |
| struct ospi_w_write_instr_cfg_t |
OSPIF Write instruction structure (manual & auto access mode).
| Data Fields | ||
|---|---|---|
| uint8_t | write_opcode | The code value of the write instruction. |
| uint8_t | write_opcode_wb | The code value of the write instruction in wrapping burst. |
| ospi_w_bus_mode_t | opcode_bus_mode: 2 | Bus mode of the opcode phase. |
| ospi_w_bus_mode_t | addr_bus_mode: 2 | Bus mode of the address phase. |
| ospi_w_bus_mode_t | data_bus_mode: 2 | Bus mode of the data phase. |
| ospi_w_bus_mode_t | dummy_bus_mode: 2 | Bus mode of the dummy data phase. |
| uint8_t | dummy_bytes: 5 | The number of dummy bytes. Valid values are 0..31 i.e. 1..32 dummy bytes. |
| bool | dummy_en | Enable dummy bytes. |
| bool | wdex_en | If enabled wait until the write data to be available before to start sending the write command sequence. |
| uint8_t | cs_hi_min_clk_cycles: 5 | After the execution of the write command, the OSPI_CS remains high for at least this number of OSPI_SCK clock cycles. |
| bool | send_wen_req | If enabled the controller will apply the write enable command. |
| struct ospi_w_write_enable_instr_cfg_t |
OSPIF write enable instruction configuration structure (auto access mode).
| Data Fields | ||
|---|---|---|
| ospi_w_bus_mode_t | opcode_bus_mode: 2 | Bus mode of the opcode phase. |
| uint8_t | opcode | Write Enable command opcode. |
| struct ospi_w_ctrl_ddr_cfg_t |
| struct ospi_w_extra_registers_cfg_t |
| struct ospi_w_qpi_instr_cfg_t |
| struct ospi_w_flash_cfg_t |
OSPI memory configuration structure.
This struct is used to define a driver for a specific OSPI memory.
| Data Fields | ||
|---|---|---|
| ospi_w_clk_mode_t | clk_mode: 1 | Clock Mode. |
| ospi_w_read_instr_cfg_t const * | p_read_instr_cfg | Read instruction configuration struct. |
| ospi_w_erase_instr_cfg_t const * | p_erase_instr_cfg | Erase instruction configuration struct. |
|
ospi_w_suspend_resume_instr_cfg_t const * |
p_suspend_resume_instr_cfg | Program and erase suspend/resume instruction. |
|
ospi_w_write_enable_instr_cfg_t const * |
p_write_enable_instr_cfg | Write enable instruction configuration. |
|
ospi_w_read_status_instr_cfg_t const * |
p_read_status_instr_cfg | Read status register instruction. |
| ospi_w_write_instr_cfg_t const * | p_write_instr_cfg | Write instruction configuration struct. |
| ospi_w_break_instr_cfg_t const * | p_break_instr_cfg | Burst break instruction configuration struct. |
| ospi_w_memblen_cfg_t const * | p_memblen_cfg | External memory burst length configuration struct. |
| ospi_w_ctrl_ddr_cfg_t const * | p_ctrl_ddr | OSPI DDR Control registers configuration struct. |
|
ospi_w_extra_registers_cfg_t const * |
p_extra_regs | OSPI Extra registers configuration struct. |
| ospi_w_qpi_instr_cfg_t const * | p_qpi_instr_cfg | Enter/Exit QPI instruction configuration struct. |
| struct ospi_w_extended_cfg_t |
Extended configuration for OSPIF.
| Data Fields | ||
|---|---|---|
| uint8_t | channel | Channel number to be used (0..1). |
| ospi_w_mode_t | ospi_mode | OSPI DDR or SDR mode. |
| ospi_w_clk_div_t | ospi_clk_div | CLK divider. |
| ospi_w_drive_current_t | ospi_drive_current | Set the Drive Strength of the OSPI Controller. |
| ospi_w_slew_rate_t | ospi_slew_rate | Set the Slew Rate of the OSPI Controller. |
| ospi_w_flash_cfg_t const * | p_ospi_flash_cfg | Pointer to ospi controller configuration struct. |
| struct ospi_w_instance_ctrl_t |
Instance control block. DO NOT INITIALIZE. Initialization occurs when spi_flash_api_t::open is called.
| Data Fields | ||
|---|---|---|
| spi_flash_cfg_t const * | p_cfg | Pointer to initial configuration. |
| spi_flash_data_lines_t | data_lines | Data lines. |
| uint32_t | total_size_bytes | Total size of the flash in bytes. |
| uint32_t | open | Whether or not driver is open. |
| ospi_w_bus_mode_t | flash_opcode_bus_mode | Opcode Bus mode of flash. |
| ospi_w_bus_mode_t | manual_access_bus_mode[2] | Bus mode for mannual access. |
| uint8_t | manual_command_length | Command length for mannual access mode. |
| bool | xip_mode_is_enabled | XiP mode is enabled or disabled. |
| enum ospi_w_access_mode_t |
| enum ospi_w_bus_mode_t |
| enum ospi_w_clk_div_t |
| enum ospi_w_ers_t |
| enum ospi_w_clk_mode_t |
OSPIF pads drive current strength. The current value depends on the device.
| enum ospi_w_read_pipe_t |
OSPIF Read pipe clock delay in relation to the falling edge of OSPI_SCK.
The read pipe delay should be set based on the voltage level of the power rail V12.
| enum ospi_w_slew_rate_t |
| enum ospi_w_hready_mode_t |
OSPIF HREADY signal mode when accessing the WRITEDATA, READDATA and DUMMYDATA registers.
This configuration is useful when the frequency of the OSPI clock is much lower than the clock of the AMBA bus, in order to avoid locking the AMBA bus for a long time. When is set to OSPI_W_HREADY_MODE_WAIT there is no need to check the OSPIC_BUSY for detecting completion of the requested access.
| enum ospi_w_instr_md_t |
| enum ospi_w_wrap_md_t |
| enum ospi_w_wrap_wr_en_t |
| enum ospi_w_rd_bend_md_t |
OSPIF behavior when a read burst is terminated early in the AMBA bus.
| enum ospi_w_rd_rdb_en_t |
Set the read pipeline in burst mode while retrieving the data of the memory device.
| enum ospi_w_extra_byte_t |
OSPIF extra byte half setting in auto access mode.
This setting is out of scope if the extra byte is disabled.
| Enumerator | |
|---|---|
| OSPI_W_EXTRA_BYTE_HALF_DISABLE | Transmit the complete extra byte. |
| OSPI_W_EXTRA_BYTE_HALF_ENABLE | The output switches to Hi-Z during the transmission of the low nibble of the extra byte. |
| enum ospi_w_break_t |
OSPIF Disable output during the transmission of the second half (OSPIC_BRK_WRD[3:0]).
Setting this bit is only useful if OSPIC_BRK_EN =1 and OSPIC_BRK_SZ= 1.
| enum ospi_w_t_cem_t |
Length of a burst operation for a OSPI RAM device.
OSPI clock edge setting for the sampling of the incoming data when the read pipe is disabled.
| enum ospi_w_mode_t |
| enum ospi_w_busy_level_t |
| enum ospi_w_stsdly_sel_t |
OSPIF timer which is used to count the delay that it has to wait before to read the Flash status register, after an erase or an erase resume command.
| enum ospi_w_dummy_value_t |
OSPIF value that is transferred on the SPI bus during the phase of the dummy bytes.
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_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 OSPI_W. Unsupported by OSPI_W.
Implements spi_flash_api_t::directWrite.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [in] | p_src | Pointer to the data to write. |
| [in] | bytes | Number of bytes to write. |
| [in] | read_after_write | Whether or not to close the SPI bus cycle. |
| FSP_ERR_UNSUPPORTED | API not supported by OSPI_W. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_DirectRead | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint8_t *const | p_dest, | ||
| uint32_t const | bytes | ||
| ) |
Reads raw data directly from the OSPI_W. This API can only be called after R_OSPI_W_DirectWrite with read_after_write set to true. Unsupported by OSPI_W.
Implements spi_flash_api_t::directRead.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [out] | p_dest | Pointer to the destination buffer. |
| [in] | bytes | Number of bytes to read. |
| FSP_ERR_UNSUPPORTED | API not supported by OSPI_W. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_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/OctaRAM device.
Implements spi_flash_api_t::directTransfer.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [in] | p_transfer | Pointer to spi_flash_direct_transfer_t. |
| [in] | direction | Direct read or write direction. |
| FSP_SUCCESS | Directly read raw data successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |
| FSP_ERR_DEVICE_BUSY | The device is busy. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_XipEnter | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Enters XiP (execute in place) mode.
Implements spi_flash_api_t::xipEnter.
| [in] | p_ctrl | Pointer to the instance control structure. |
| FSP_SUCCESS | The flash enters XiP mode successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_XipExit | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Exits XiP (execute in place) mode.
Implements spi_flash_api_t::xipExit.
| [in] | p_ctrl | Pointer to the instance control structure. |
| FSP_SUCCESS | The flash exits XiP mode successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_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.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [in] | p_src | Pointer to the source data. |
| [out] | p_dest | Pointer to the destination. |
| [in] | byte_count | Number of bytes to 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 | The device is busy. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_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.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [in] | p_device_address | Pointer to the device address. |
| [in] | byte_count | Number of bytes to be erased. |
| 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_DEVICE_BUSY | The device is busy. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_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.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [out] | p_status | Pointer to the status spi_flash_status_t. |
| 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. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_BankSet | ( | spi_flash_ctrl_t * | p_ctrl, |
| uint32_t | bank | ||
| ) |
Selects the bank to access.
Implements spi_flash_api_t::bankSet.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [in] | bank | The bank which need to access. |
| FSP_ERR_UNSUPPORTED | API not supported by OSPI_W. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_SpiProtocolSet | ( | spi_flash_ctrl_t * | p_ctrl, |
| spi_flash_protocol_t | spi_protocol | ||
| ) |
Sets the SPI protocol in R_OSPI_W_DirectTransfer API.
Implements spi_flash_api_t::spiProtocolSet.
| [in] | p_ctrl | Pointer to the instance control structure. |
| [in] | spi_protocol | The type of SPI Flash protocol. |
| FSP_SUCCESS | SPI protocol updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |
| FSP_ERR_UNSUPPORTED | Protocol is not supported by OSPI_W. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_AutoCalibrate | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Auto-calibrate the OctaRAM device using the preamble pattern. Implements spi_flash_api_t::autoCalibrate.
| [in] | p_ctrl | Pointer to the instance control structure. |
| FSP_ERR_UNSUPPORTED | API not supported by OSPI_W. |
| BSP_PLACE_CODE_IN_RAM fsp_err_t R_OSPI_W_Close | ( | spi_flash_ctrl_t * | p_ctrl | ) |
Close the OSPI_W driver module.
Implements spi_flash_api_t::close.
| [in] | p_ctrl | Pointer to the instance control structure. |
| FSP_SUCCESS | Close module successfully. |
| FSP_ERR_ASSERTION | p_instance_ctrl is NULL. |
| FSP_ERR_NOT_OPEN | Driver is not opened. |