17 #ifndef MBED_OSPI_TEST_UTILS_H 18 #define MBED_OSPI_TEST_UTILS_H 20 #include "flash_configs/flash_configs.h" 21 #include "unity/unity.h" 22 #include "hal/ospi_api.h" 23 #define OSPI_NONE (-1) 34 void configure(ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width,
35 ospi_bus_width_t alt_width, ospi_address_size_t addr_size, ospi_alt_size_t alt_size,
36 int dummy_cycles = 0);
38 void set_dummy_cycles(
int dummy_cycles);
40 void build(
int instruction,
int address = OSPI_NONE,
int alt = OSPI_NONE);
42 ospi_command_t *
get();
54 #define MODE_1_1_1 OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_SINGLE 55 #define MODE_1_1_2 OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_DUAL, OSPI_CFG_BUS_DUAL 56 #define MODE_1_2_2 OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_DUAL, OSPI_CFG_BUS_DUAL, OSPI_CFG_BUS_DUAL 57 #define MODE_2_2_2 OSPI_CFG_BUS_DUAL, OSPI_CFG_BUS_DUAL, OSPI_CFG_BUS_DUAL, OSPI_CFG_BUS_DUAL 58 #define MODE_1_1_4 OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_QUAD, OSPI_CFG_BUS_QUAD 59 #define MODE_1_4_4 OSPI_CFG_BUS_SINGLE, OSPI_CFG_BUS_QUAD, OSPI_CFG_BUS_QUAD, OSPI_CFG_BUS_QUAD 60 #define MODE_4_4_4 OSPI_CFG_BUS_QUAD, OSPI_CFG_BUS_QUAD, OSPI_CFG_BUS_QUAD, OSPI_CFG_BUS_QUAD 61 #define MODE_8_8_8 OSPI_CFG_BUS_OCTA, OSPI_CFG_BUS_OCTA, OSPI_CFG_BUS_OCTA, OSPI_CFG_BUS_OCTA 62 #define MODE_8D_8D_8D OSPI_CFG_BUS_OCTA_DTR, OSPI_CFG_BUS_OCTA_DTR, OSPI_CFG_BUS_OCTA_DTR, OSPI_CFG_BUS_OCTA_DTR 65 #define WRITE_1_1_1 MODE_1_1_1, OSPI_CMD_WRITE_1IO 66 #ifdef OSPI_CMD_WRITE_2IO 67 #define WRITE_1_2_2 MODE_1_2_2, OSPI_CMD_WRITE_2IO 69 #ifdef OSPI_CMD_WRITE_1I4O // Quad page program - command: 0x32 70 #define WRITE_1_1_4 MODE_1_1_4, OSPI_CMD_WRITE_1I4O 72 #ifdef OSPI_CMD_WRITE_4IO 73 #define WRITE_1_4_4 MODE_1_4_4, OSPI_CMD_WRITE_4IO 75 #ifdef OSPI_CMD_WRITE_DPI 76 #define WRITE_2_2_2 MODE_2_2_2, OSPI_CMD_WRITE_DPI 78 #ifdef OSPI_CMD_WRITE_QPI 79 #define WRITE_4_4_4 MODE_4_4_4, OSPI_CMD_WRITE_QPI 81 #ifdef OSPI_CMD_WRITE_OPI 82 #define WRITE_8_8_8 MODE_8_8_8, OSPI_CMD_WRITE_OPI 84 #ifdef OSPI_CMD_WRITE_OPI 85 #define WRITE_8D_8D_8D MODE_8D_8D_8D, OSPI_CMD_WRITE_OPI 88 #define READ_1_1_1 MODE_1_1_1, OSPI_CMD_READ_1IO, OSPI_READ_1IO_DUMMY_CYCLE 89 #ifdef OSPI_CMD_READ_1I2O 90 #define READ_1_1_2 MODE_1_1_2, OSPI_CMD_READ_1I2O, OSPI_READ_1I2O_DUMMY_CYCLE 92 #ifdef OSPI_CMD_READ_2IO 93 #define READ_1_2_2 MODE_1_2_2, OSPI_CMD_READ_2IO, OSPI_READ_2IO_DUMMY_CYCLE 95 #ifdef OSPI_CMD_READ_1I4O 96 #define READ_1_1_4 MODE_1_1_4, OSPI_CMD_READ_1I4O, OSPI_READ_1I4O_DUMMY_CYCLE 98 #ifdef OSPI_CMD_READ_4IO 99 #define READ_1_4_4 MODE_1_4_4, OSPI_CMD_READ_4IO, OSPI_READ_4IO_DUMMY_CYCLE 101 #ifdef OSPI_CMD_READ_OPI 102 #define READ_8_8_8 MODE_8_8_8, OSPI_CMD_READ_OPI, OSPI_READ_8IO_DUMMY_CYCLE 104 #ifdef OSPI_CMD_READ_DOPI 105 #define READ_8D_8D_8D MODE_8D_8D_8D, OSPI_CMD_READ_DOPI, OSPI_READ_8IO_DUMMY_CYCLE 108 #ifdef OSPI_CMD_READ_DPI 109 #define READ_2_2_2 MODE_2_2_2, OSPI_CMD_READ_DPI, OSPI_READ_2IO_DUMMY_CYCLE 111 #ifdef OSPI_CMD_READ_QPI 112 #define READ_4_4_4 MODE_4_4_4, OSPI_CMD_READ_QPI, OSPI_READ_4IO_DUMMY_CYCLE 115 #define ADDR_SIZE_8 OSPI_CFG_ADDR_SIZE_8 116 #define ADDR_SIZE_16 OSPI_CFG_ADDR_SIZE_16 117 #define ADDR_SIZE_24 OSPI_CFG_ADDR_SIZE_24 118 #define ADDR_SIZE_32 OSPI_CFG_ADDR_SIZE_32 120 #define ALT_SIZE_8 OSPI_CFG_ALT_SIZE_8 121 #define ALT_SIZE_16 OSPI_CFG_ALT_SIZE_16 122 #define ALT_SIZE_24 OSPI_CFG_ALT_SIZE_24 123 #define ALT_SIZE_32 OSPI_CFG_ALT_SIZE_32 125 #define STATUS_REG OSPI_CMD_RDSR 126 #define CONFIG_REG0 OSPI_CMD_RDCR0 127 #ifdef OSPI_CMD_RDCR1 128 #define CONFIG_REG1 OSPI_CMD_RDCR1 130 #ifdef OSPI_CMD_RDCR2 131 #define CONFIG_REG2 OSPI_CMD_RDCR2 133 #define SECURITY_REG OSPI_CMD_RDSCUR 135 #ifndef OSPI_CONFIG_REG_1_SIZE 136 #define OSPI_CONFIG_REG_1_SIZE 0 139 #ifndef OSPI_CONFIG_REG_2_SIZE 140 #define OSPI_CONFIG_REG_2_SIZE 0 144 #define SECTOR_ERASE OSPI_CMD_ERASE_SECTOR 145 #define BLOCK_ERASE OSPI_CMD_ERASE_BLOCK_64 148 #define SECTOR_ERASE_MAX_TIME OSPI_ERASE_SECTOR_MAX_TIME 149 #define BLOCK32_ERASE_MAX_TIME OSPI_ERASE_BLOCK_32_MAX_TIME 150 #define BLOCK64_ERASE_MAX_TIME OSPI_ERASE_BLOCK_64_MAX_TIME 151 #define PAGE_PROG_MAX_TIME OSPI_PAGE_PROG_MAX_TIME 152 #define WRSR_MAX_TIME OSPI_WRSR_MAX_TIME 153 #define WAIT_MAX_TIME OSPI_WAIT_MAX_TIME 157 ospi_status_t read_register(uint32_t cmd, uint8_t *buf, uint32_t size,
Ospi &q);
158 ospi_status_t write_register(uint32_t cmd, uint8_t *buf, uint32_t size,
Ospi &q);
160 OspiStatus flash_wait_for(uint32_t time_us,
Ospi &ospi);
164 ospi_status_t write_enable(
Ospi &ospi);
165 ospi_status_t write_disable(
Ospi &ospi);
167 void log_register(uint32_t cmd, uint32_t reg_size,
Ospi &ospi,
const char *str = NULL);
169 ospi_status_t mode_enable(
Ospi &ospi, ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
170 ospi_status_t mode_disable(
Ospi &ospi, ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
172 ospi_status_t fast_mode_enable(
Ospi &ospi);
173 ospi_status_t fast_mode_disable(
Ospi &ospi);
175 ospi_status_t erase(uint32_t erase_cmd, uint32_t flash_addr,
Ospi &ospi);
177 bool is_extended_mode(ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
178 bool is_dual_mode(ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
179 bool is_quad_mode(ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
180 bool is_octa_mode(ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
181 bool is_octa_dtr_mode(ospi_bus_width_t inst_width, ospi_bus_width_t addr_width, ospi_bus_width_t data_width);
183 #define WAIT_FOR(timeout, q) TEST_ASSERT_EQUAL_MESSAGE(sOK, flash_wait_for(timeout, q), "flash_wait_for failed!!!") 186 #endif // MBED_OSPI_TEST_UTILS_H
int32_t flash_init(flash_t *obj)
Initialize the flash peripheral and the flash_t object.