bf0_hal_mpi.h
Header file of QSPI HAL module.
- Author
Sifli software development team
Defines
-
SPI_FLASH_OTP_BASE
-
NAND_FLAG_PAGE_DOUBLE
-
NAND_FLAG_BLOCK_DOUBLE
-
__HAL_QSPI_EN_HWI(__HANDLE__)
QSPI Enable Hardware Interface .
- 参数:
__HANDLE__ – SPI FLASH handle
- 返回值:
None –
-
__HAL_QSPI_DIS_HWI(__HANDLE__)
QSPI Disable Hardware Interface .
- 参数:
__HANDLE__ – SPI FLASH handle
- 返回值:
None –
-
__HAL_QSPI_SET_CMD(__HANDLE__, __CMD__)
QSPI Set Command , do not wait TCF.
- 参数:
__HANDLE__ – SPI FLASH handle
__CMD__ – Command for FLASH or PSRAM
- 返回值:
None –
-
__HAL_MPI_GET_CREN(__HANDLE__)
Get MPI CR enable status.
- 参数:
__HANDLE__ – MPI handle
- 返回值:
status –
Typedefs
-
typedef void (*flash_cs_ctrl)(uint32_t pulldown)
SPI_FLASH CS control function type.
-
typedef void (*flash_lock_ctrl)(uint32_t addr, uint32_t lock)
-
typedef struct __FLASH_HandleTypeDef FLASH_HandleTypeDef
SPI_FLASH initial structure definition.
Enums
-
enum SPI_FLASH_CMD_E
SPI_FLASH command index.
Values:
-
enumerator SPI_FLASH_CMD_WREN
write enable, nor+nand
-
enumerator SPI_FLASH_CMD_WRDI
write disable, nor+nand
-
enumerator SPI_FLASH_CMD_RDSR
read status register, nor+nand
-
enumerator SPI_FLASH_CMD_WRSR
write status register, nor+nand
-
enumerator SPI_FLASH_CMD_PREAD
page read, nand
-
enumerator SPI_FLASH_CMD_READ
single line read, nor+nand
-
enumerator SPI_FLASH_CMD_FREAD
fast read , nor + nand
-
enumerator SPI_FLASH_CMD_DREAD
fast read dual output, nor+nand
-
enumerator SPI_FLASH_CMD_QREAD
fast read quad output, nor+nand
-
enumerator SPI_FLASH_CMD_2READ
2 line read, nor+nand
-
enumerator SPI_FLASH_CMD_4READ
4 line read, nor+nand . ==== 10
-
enumerator SPI_FLASH_CMD_RDID
read id, nor+nand
-
enumerator SPI_FLASH_CMD_PLD
load program data, nand
-
enumerator SPI_FLASH_CMD_QPLD
qual program load, nand
-
enumerator SPI_FLASH_CMD_PLDR
randome program load, nand
-
enumerator SPI_FLASH_CMD_QPLDR
qual random program load, nand
-
enumerator SPI_FLASH_CMD_PEXE
program execute, nand
-
enumerator SPI_FLASH_CMD_BE
block erase, nand
-
enumerator SPI_FLASH_CMD_RST
reset, nor+nand
-
enumerator SPI_FLASH_CMD_RST_EN
reset en, nor
-
enumerator SPI_FLASH_CMD_RDSR2
read status register 2, nor ==== 20
-
enumerator SPI_FLASH_CMD_WVSR
write volatile status register, nor
-
enumerator SPI_FLASH_CMD_PP
PAGE PROGRAM, nor
-
enumerator SPI_FLASH_CMD_QPP
QUAL PAGE PROGRAM, nor
-
enumerator SPI_FLASH_CMD_RDEAR
read extended address register, nor
-
enumerator SPI_FLASH_CMD_WREAR
write extended address register, nor
-
enumerator SPI_FLASH_CMD_PE
page erase, nor
-
enumerator SPI_FLASH_CMD_SE
SECTOR erase, nor
-
enumerator SPI_FLASH_CMD_BE32
BLOCK erase 32KB, nor
-
enumerator SPI_FLASH_CMD_BE64
BLOCK erase 64KB, nor
-
enumerator SPI_FLASH_CMD_CE
CHIP ERASE, nor ===== 30
-
enumerator SPI_FLASH_CMD_RDSR3
read status register 3, nor
-
enumerator SPI_FLASH_CMD_WRSR3
WRITE status register 3, nor
-
enumerator SPI_FLASH_CMD_EN4BM
enter 4-byte address mode, nor
-
enumerator SPI_FLASH_CMD_ET4BM
exit 4-byte address mode, nor
-
enumerator SPI_FLASH_CMD_RD4BA
read with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_FR4BA
fast read with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_FQR4BA
fast read quad output with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_4RD4BA
4 IO read with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_PP4BA
page program with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_QPP4BA
quad page program with 4-byte address, nor ==== 40
-
enumerator SPI_FLASH_CMD_SE4BA
sector erase with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_BE4BA
64KB block erase with 4-byte address, nor
-
enumerator SPI_FLASH_CMD_WRSR2
write status register command 2, nor
-
enumerator SPI_FLASH_CMD_LEFPA
Last ECC Failue Page Address, NAND
-
enumerator SPI_FLASH_CMD_BBM
Bad Block Management, NAND
-
enumerator SPI_FLASH_CMD_RBLUT
Read BBM Look Up Table, NAND
-
enumerator SPI_FLASH_CMD_CFREAD
Continue fast read with 1 line, NAND
-
enumerator SPI_FLASH_CMD_C4READ
Continue read with 4 line, NAND
-
enumerator SPI_FLASH_CMD_RUID
Read Unique ID, NOR
-
enumerator SPI_FLASH_CMD_RDSCUR
Read Security Register, NOR ====== 50
-
enumerator SPI_FLASH_CMD_PRSCUR
Program Security Register, NOR
-
enumerator SPI_FLASH_CMD_ERSCUR
Erase Security Registers, NOR
-
enumerator SPI_FLASH_CMD_DPD
Deep Power-Down, NOR
-
enumerator SPI_FLASH_CMD_RDP
Release from Deep Power-Down, NOR
-
enumerator SPI_FLASH_CMD_DTR4R
DTR 4 IO Read, NOR
-
enumerator SPI_FLASH_CMD_RDSFDP
Read SFDP(Serial Flash Discoverable Parameter), NOR
-
enumerator SPI_FLASH_CMD_COUNT
current support flash command
-
enumerator SPI_FLASH_CMD_WREN
-
enum FLASH_MANUF_ID_T
SPI_FLASH manufactory id.
Values:
-
enumerator FLASH_INVALID_ID
Initial id
-
enumerator FLASH_SPANSION
Spansion
-
enumerator FLASH_PUYA
puya
-
enumerator FLASH_EON
EON
-
enumerator FLASH_MXIC
Mxic
-
enumerator FLASH_GIGA
Giga device
-
enumerator FLASH_WINBOND
winbond
-
enumerator FLASH_FIDELIX
Fidelix
-
enumerator FLASH_ESMT
Esmt
-
enumerator FLASH_NUMONYX
numonyx
-
enumerator FLASH_MICRON
micro
-
enumerator FLASH_PM25L
pm25l
-
enumerator FLASH_FUDAN
fudan
-
enumerator FLASH_HYF
fudan
-
enumerator FLASH_UNKNOW_ID
Invalid
-
enumerator FLASH_INVALID_ID
-
enum HAL_FLASH_StateTypeDef
SPI_FLASH status define.
Values:
-
enumerator HAL_FLASH_STATE_RESET
Peripheral not Initialized
-
enumerator HAL_FLASH_STATE_READY
Peripheral Initialized and ready for use
-
enumerator HAL_FLASH_STATE_BUSY
an internal process is ongoing
-
enumerator HAL_FLASH_STATE_ERROR
FLASH error state
-
enumerator HAL_FLASH_STATE_ABORT
FLASH abort is ongoing
-
enumerator HAL_FLASH_STATE_RESET
-
enum HAL_FLASH_ModeDef
SPI_FLASH spi line mode.
Values:
-
enumerator HAL_FLASH_NOR_MODE
Flash single spi mode
-
enumerator HAL_FLASH_DMODE
Flash dual spi mode
-
enumerator HAL_FLASH_QMODE
Flash qual spi mode
-
enumerator HAL_FLASH_NOR_MODE
-
enum HAL_FLASH_AES_Mode
SPI_FLASH AES mode.
Values:
-
enumerator HAL_FLASH_AES128
AES 128
-
enumerator HAL_FLASH_AES256
AES 256
-
enumerator HAL_FLASH_AES128
-
enum SPI_FLASH_MODE_E
SPI_FLASH flash type.
Values:
-
enumerator SPI_MODE_NOR
Flash TYPE NOR mode
-
enumerator SPI_MODE_NAND
Flash TYPE NAND mode
-
enumerator SPI_MODE_PSRAM
Flash TYPE QSPI PSRAM mode
-
enumerator SPI_MODE_OPSRAM
Flash TYPE OPI PSRAM mode
-
enumerator SPI_MODE_HPSRAM
Flash TYPE HPI PSRAM mode
-
enumerator SPI_MODE_LEGPSRAM
Flash TYPE LEGACY PSRAM mode
-
enumerator SPI_MODE_HBPSRAM
Flash TYPE Hyper Bus PSRAM mode
-
enumerator SPI_MODE_COUNT
-
enumerator SPI_MODE_NOR
Functions
-
HAL_StatusTypeDef HAL_FLASH_SET_AHB_RCMD(FLASH_HandleTypeDef *hflash, uint8_t cmd)
SPI_FLASH set ahb read command.
- 参数:
hflash – SPI_FLASH handle
cmd – read command index
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_AHB_WCMD(FLASH_HandleTypeDef *hflash, uint8_t cmd)
SPI_FLASH set ahb write command.
- 参数:
hflash – SPI_FLASH handle
cmd – write command index
- 返回值:
HAL – status
-
void HAL_FLASH_CFG_AHB_RCMD(FLASH_HandleTypeDef *hflash, int8_t data_mod, int8_t dum_cyc, int8_t ab_size, int8_t ab_mod, int8_t addr_size, int8_t addr_mod, int8_t cmd_mode)
SPI_FLASH configure AHB read command.
- 参数:
hflash – SPI_FLASH handle
data_mod – data mode, 1 for single line, 2 for dual line, 3 for 4line
dum_cyc – dummy cycle
ab_size – ab size in bit
ab_mod – ab mode, 1/2/4 line
addr_size – address size, 0 for 1 byte … 3 for 4 bytes
addr_mod – address mode, 1/2/4 line, 1 for single line, 2 for dual line, 3 for 4line
cmd_mode – command mode, it should be 1
- 返回值:
None –
-
void HAL_FLASH_CFG_AHB_WCMD(FLASH_HandleTypeDef *hflash, int8_t data_mod, int8_t dum_cyc, int8_t ab_size, int8_t ab_mod, int8_t addr_size, int8_t addr_mod, int8_t cmd_mode)
SPI_FLASH config AHB write command.
- 参数:
hflash – SPI_FLASH handle
data_mod – data mode, 1 for single line, 2 for dual line, 3 for 4line
dum_cyc – dummy cycle
ab_size – ab size in bit
ab_mod – ab mode, 1/2/4 line
addr_size – address size, 0 for 1 byte … 3 for 4 bytes
addr_mod – address mode, 1/2/4 line, 1 for single line, 2 for dual line, 3 for 4line
cmd_mode – command mode, it should be 1
- 返回值:
None –
-
HAL_StatusTypeDef HAL_FLASH_ENABLE_QSPI(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH enable QSPI mode.
- 参数:
hflash – SPI_FLASH handle
en – enable QSPI mode
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_ENABLE_OPI(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH enable OPI mode.
- 参数:
hflash – SPI_FLASH handle
en – enable OPI mode
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_ENABLE_HYPER(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH for HyperBus psram.
- 参数:
hflash – FLASH handle
en – enable hyper
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_CMD(FLASH_HandleTypeDef *hflash, uint8_t cmd, uint32_t addr)
SPI_FLASH set flash command to register.
- 参数:
hflash – SPI_FLASH handle
cmd – command index
addr – address
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_CFG_CMD(FLASH_HandleTypeDef *hflash, uint8_t cmd, uint32_t addr, uint8_t is_cmd2)
Configure FLASH command but do not need wait TCF.
- 参数:
hflash – SPI_FLASH handle
cmd – command index
addr – address
is_cmd2 – set command 2 or command 1
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_WRITE_DLEN(FLASH_HandleTypeDef *hflash, uint32_t len)
SPI_FLASH write data length.
- 参数:
hflash – FLASH handle
len – data length
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_WRITE_DLEN2(FLASH_HandleTypeDef *hflash, uint16_t len)
SPI_FLASH write data length to command 2.
- 参数:
hflash – FLASH handle
len – data length
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_WRITE_WORD(FLASH_HandleTypeDef *hflash, uint32_t data)
SPI_FLASH write a word to fifo.
- 参数:
hflash – FLASH handle
data – u32 data
- 返回值:
HAL – status
-
void HAL_FLASH_WRITE_ABYTE(FLASH_HandleTypeDef *hflash, uint32_t ab)
SPI_FLASH write alternate byte.
- 参数:
hflash – FLASH handle
ab – u32 data
- 返回值:
none –
-
bool HAL_FLASH_IS_RX_EMPTY(FLASH_HandleTypeDef *hflash)
SPI_FLASH is rx fifo empty.
- 参数:
hflash – FLASH handle
- 返回值:
fifo – status
-
bool HAL_FLASH_IS_TX_FULL(FLASH_HandleTypeDef *hflash)
SPI_FLASH is tx fifo full.
- 参数:
hflash – FLASH handle
- 返回值:
fifo – status
-
bool HAL_FLASH_IS_TX_EMPTY(FLASH_HandleTypeDef *hflash)
SPI_FLASH is tx fifo empty.
- 参数:
hflash – FLASH handle
- 返回值:
fifo – status
-
bool HAL_FLASH_IS_BUSY(FLASH_HandleTypeDef *hflash)
SPI_FLASH is busy.
- 参数:
hflash – FLASH handle
- 返回值:
flash – status
-
bool HAL_FLASH_STATUS_MATCH(FLASH_HandleTypeDef *hflash)
SPI_FLASH status match previous setting.
- 参数:
hflash – FLASH handle
- 返回值:
flash – status
-
bool HAL_FLASH_IS_CMD_DONE(FLASH_HandleTypeDef *hflash)
SPI_FLASH if command finish.
- 参数:
hflash – FLASH handle
- 返回值:
flash – status
-
void HAL_FLASH_CLR_CMD_DONE(FLASH_HandleTypeDef *hflash)
SPI_FLASH clear command done status.
- 参数:
hflash – FLASH handle
- 返回值:
none –
-
bool HAL_FLASH_IS_PROG_DONE(FLASH_HandleTypeDef *hflash)
SPI_FLASH check if program done.
- 参数:
hflash – FLASH handle
- 返回值:
flash – status
-
uint32_t HAL_FLASH_READ32(FLASH_HandleTypeDef *hflash)
SPI_FLASH read 32 bits data from fifo.
- 参数:
hflash – FLASH handle
- 返回值:
data – in fifo
-
uint8_t HAL_FLASH_GET_RX_CNT(FLASH_HandleTypeDef *hflash)
SPI_FLASH get received count.
- 参数:
hflash – FLASH handle
- 返回值:
rx – count
-
void HAL_FLASH_SET_CLK_rom(FLASH_HandleTypeDef *hflash, uint8_t div)
SPI_FLASH set clock divider.
- 参数:
hflash – FLASH handle
div – clock divider
- 返回值:
none –
-
void HAL_FLASH_CLEAR_FIFO(FLASH_HandleTypeDef *hflash, HAL_FLASH_ClearFifo mode)
SPI_FLASH flush flash fifo.
- 参数:
hflash – FLASH handle
mode – RX or tx OR ALL
- 返回值:
none –
-
void HAL_FLASH_SET_TXSLOT(FLASH_HandleTypeDef *hflash, uint8_t slot)
SPI_FLASH set tx slot to meet DMA request.
- 参数:
hflash – FLASH handle
slot – burst width
- 返回值:
none –
-
void HAL_FLASH_MANUAL_CMD(FLASH_HandleTypeDef *hflash, int8_t func_mod, int8_t data_mod, int8_t dum_cyc, int8_t ab_size, int8_t ab_mod, int8_t addr_size, int8_t addr_mod, int8_t cmd_mode)
SPI_FLASH config command parameter.
- 参数:
hflash – SPI_FLASH handle
func_mod – function mode, read or write
data_mod – data mode, 1 for single line, 2 for dual line, 3 for 4line
dum_cyc – dummy cycle
ab_size – ab size in bit
ab_mod – ab mode, 1/2/4 line
addr_size – address size, 0 for 1 byte … 3 for 4 bytes
addr_mod – address mode, 1/2/4 line, 1 for single line, 2 for dual line, 3 for 4line
cmd_mode – command mode, it should be 1
- 返回值:
None –
-
void HAL_FLASH_MANUAL_CMD2(FLASH_HandleTypeDef *hflash, int8_t func_mod, int8_t data_mod, int8_t dum_cyc, int8_t ab_size, int8_t ab_mod, int8_t addr_size, int8_t addr_mod, int8_t cmd_mode)
SPI_FLASH config command parameter for command 2.
- 参数:
hflash – SPI_FLASH handle
func_mod – function mode, read or write
data_mod – data mode, 1 for single line, 2 for dual line, 3 for 4line
dum_cyc – dummy cycle
ab_size – ab size in bit
ab_mod – ab mode, 1/2/4 line
addr_size – address size, 0 for 1 byte … 3 for 4 bytes
addr_mod – address mode, 1/2/4 line, 1 for single line, 2 for dual line, 3 for 4line
cmd_mode – command mode, it should be 1
- 返回值:
None –
-
HAL_StatusTypeDef HAL_FLASH_ENABLE_CMD2(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH enable/disable command 2.
- 参数:
hflash – FLASH handle
en – enable
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_STAUS_MATCH_CMD2(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH command 2 match status en.
- 参数:
hflash – FLASH handle
en – enable
- 返回值:
HAL – status
-
void HAL_FLASH_CLR_STATUS(FLASH_HandleTypeDef *hflash, uint32_t status)
SPI_FLASH clear flash status.
- 参数:
hflash – FLASH handle
status – value
- 返回值:
none –
-
HAL_StatusTypeDef HAL_FLASH_SET_ALIAS_RANGE(FLASH_HandleTypeDef *hflash, uint32_t start, uint32_t len)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
start – start address
len – data length
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_ALIAS_OFFSET(FLASH_HandleTypeDef *hflash, uint32_t offset)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
offset – alias offset
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_CTR(FLASH_HandleTypeDef *hflash, uint32_t start, uint32_t end)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
start – start address
end – end address
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_NONCE(FLASH_HandleTypeDef *hflash, uint8_t *data)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
data – data buffer
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_AES(FLASH_HandleTypeDef *hflash, HAL_FLASH_AES_Mode mode)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
mode – AES mode
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_ENABLE_AES(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
en – enable
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_CS_TIME(FLASH_HandleTypeDef *hflash, uint16_t cslmax, uint16_t cslmin, uint16_t cshmin, uint16_t trcmin)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
cslmax – cs low max
cslmin – cs low min
cshmin – cs high min
trcmin – Write/Read cycle minimum time
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_ROW_BOUNDARY(FLASH_HandleTypeDef *hflash, uint8_t rb_size)
SPI_FLASH for boot mode.
- 参数:
hflash – FLASH handle
rb_size – row boundary
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_LEGACY(FLASH_HandleTypeDef *hflash, uint8_t en)
SPI_FLASH for legacy psram.
- 参数:
hflash – FLASH handle
en – enable legacy
- 返回值:
HAL – status
-
uint8_t HAL_FLASH_GET_DIV(FLASH_HandleTypeDef *hflash)
SPI_FLASH get clock divider.
- 参数:
hflash – FLASH handle
- 返回值:
clock – divider
-
HAL_StatusTypeDef HAL_FLASH_SET_DUAL_MODE(FLASH_HandleTypeDef *hflash, uint8_t dual)
SPI_FLASH set dual flash mode.
- 参数:
hflash – FLASH handle
dual – 1 for dual flash, 0 for single
- 返回值:
HAL – status
-
int HAL_FLASH_GET_DUAL_MODE(FLASH_HandleTypeDef *hflash)
SPI_FLASH get dual flash mode.
- 参数:
hflash – FLASH handle
- 返回值:
0 – for single and 1 for dual flash mode
-
HAL_StatusTypeDef HAL_FLASH_SET_X16_MODE(FLASH_HandleTypeDef *hflash, uint8_t en)
Set MPI to X16 mode.
- 参数:
hflash – FLASH handle
en – enable X16 mode if 1
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_EN_FIXLAT(FLASH_HandleTypeDef *hflash, uint8_t fix)
MPI Indicate PSRAM is fixed latency or variable latency.
- 参数:
hflash – FLASH handle
fix – fixed latency or variable latency
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_SET_HYPER(FLASH_HandleTypeDef *hflash, uint8_t hyper)
MPI HyperBus protocol.
- 参数:
hflash – FLASH handle
hyper – hyperbus protocol
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_ENABLE_DQS(FLASH_HandleTypeDef *hflash, uint8_t dqs)
MPI DQS enable.
- 参数:
hflash – FLASH handle
dqs – Setting to 1 indicates device provides DQS signal for Rx data latching
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_SET_DQS_DELAY(FLASH_HandleTypeDef *hflash, uint8_t delay)
MPI select delayed version of DQS.
- 参数:
hflash – FLASH handle
delay – delay version
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_SET_SCK(FLASH_HandleTypeDef *hflash, uint8_t delay, uint8_t inv)
MPI set SCK info.
- 参数:
hflash – FLASH handle
delay – Add delay on SCK (fine tune)
inv – Invert FCLK as SCK (coarse tune)
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_CFG_DTR(FLASH_HandleTypeDef *hflash, uint8_t en, uint8_t rclk_inv_delay)
MPI Enable pre-sampling for DTR.
- 参数:
hflash – FLASH handle
en – enable dtr
rclk_inv_delay – high 4 bits for rx clock invert, low 4 bits for rx clock delay
- 返回值:
HAL – status
-
void HAL_MPI_MODIFY_RCMD_DELAY(FLASH_HandleTypeDef *hflash, int8_t dum_cyc)
MPI modify AHB read delay cycle.
- 参数:
hflash – FLASH handle
dum_cyc – dummy cycle
- 返回值:
HAL – status
-
void HAL_MPI_MODIFY_WCMD_DELAY(FLASH_HandleTypeDef *hflash, int8_t dum_cyc)
MPI modify AHB write delay cycle.
- 参数:
hflash – FLASH handle
dum_cyc – dummy cycle
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_WDT(FLASH_HandleTypeDef *hflash, uint16_t timeout)
SPI_FLASH set watch dog timeout.
- 参数:
hflash – FLASH handle
timeout – timeout value in cycle
- 返回值:
HAL – status
-
int HAL_FLASH_GET_WDT_VALUE(FLASH_HandleTypeDef *hflash)
SPI_FLASH get wdt timeout configure value.
- 参数:
hflash – FLASH handle
- 返回值:
timeout – value in cycle
-
int HAL_FLASH_GET_WDT_STATUS(FLASH_HandleTypeDef *hflash)
SPI_FLASH get wdt timeout flag.
- 参数:
hflash – FLASH handle
- 返回值:
1 – if timout
-
HAL_StatusTypeDef HAL_FLASH_CONFIG_AHB_READ(FLASH_HandleTypeDef *hflash, bool qmode)
SPI_FLASH config default ahb read command.
- 参数:
hflash – FLASH handle
qmode – qual spi mode
- 返回值:
HAL – status
-
int HAL_FLASH_PRE_CMD(FLASH_HandleTypeDef *handle, SPI_FLASH_CMD_E cmd)
SPI_FLASH set command parameter but not set command.
- 参数:
handle – FLASH handle
cmd – flash command
- 返回值:
0 – if success
-
int HAL_FLASH_ISSUE_CMD(FLASH_HandleTypeDef *handle, SPI_FLASH_CMD_E cmd, uint32_t addr)
SPI_FLASH issue flash command.
- 参数:
handle – FLASH handle
cmd – flash command
addr – flash address
- 返回值:
0 – if success
-
int HAL_FLASH_ISSUE_CMD_SEQ(FLASH_HandleTypeDef *handle, SPI_FLASH_CMD_E cmd1, uint32_t addr, SPI_FLASH_CMD_E cmd2, uint32_t param)
SPI_FLASH issue command 1 and command 2 in sequence.
- 参数:
handle – FLASH handle
cmd1 – flash command 1
addr – address for command 1
cmd2 – flash command 2
param – status mask value
- 返回值:
0 – if success
-
void HAL_FLASH_SET_QUAL_SPI(FLASH_HandleTypeDef *hflash, bool en)
SPI_FLASH set qual spi mode.
- 参数:
hflash – FLASH handle
en – enable qual spi
- 返回值:
none –
-
void HAL_FLASH_FADDR_SET_QSPI(FLASH_HandleTypeDef *hflash, bool en)
SPI_FLASH set qual spi mode for 4 bytes address mode.
- 参数:
hflash – FLASH handle
en – enable qusl spi
- 返回值:
none –
-
int HAL_FLASH_GET_NOR_ID(FLASH_HandleTypeDef *hflash)
SPI_FLASH get nor flash device id.
- 参数:
hflash – FLASH handle
- 返回值:
nor – flash device id
-
int HAL_FLASH_ID_DUAL_ID(FLASH_HandleTypeDef *hflash)
SPI_FLASH check if duall flash mode by check flash id.
- 参数:
hflash – FLASH handle
- 返回值:
0 – if single and 1 if dual flash mode
-
void HAL_FLASH_CLR_PROTECT(FLASH_HandleTypeDef *hflash)
SPI_FLASH volatile clear protect bits.
- 参数:
hflash – FLASH handle
- 返回值:
none –
-
HAL_StatusTypeDef HAL_QSPI_Init(FLASH_HandleTypeDef *hflash, qspi_configure_t *cfg)
SPI_FLASH initial controller.
- 参数:
hflash – FLASH handle
cfg – configurations
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_PreInit(FLASH_HandleTypeDef *hflash)
SPI_FLASH pre initial, force set to NOR flash single mode. Only support AHB and OTP read after pre init.
- 参数:
hflash – FLASH handle
- 返回值:
HAL – status
-
int HAL_QSPI_GET_PSRAM_ID(FLASH_HandleTypeDef *hqspi)
Get QSPI PSRAM chip id.
备注
Data layout: densiy | KGD | MFID
- 参数:
hqspi – qspi handle
- 返回值:
psram – MFID & KGD & density
-
void HAL_QSPI_SET_RXDELAY(uint8_t qspi_id, uint8_t sen_delay, uint8_t clk_delay)
Set RX delay for high speed flash clock.
- 参数:
qspi_id – [in] id for qspi interface, 0 for qspi1, 1 for qspi2, 2 for qspi3, 3 for qspi4, others reserved.
sen_delay – [in] select delayed version of Rx sample en
clk_delay – [in] Select delayed version of Rx clock in order to achieve higher operating frequency
- 返回值:
none –
-
void HAL_QSPI_SET_CLK_INV(FLASH_HandleTypeDef *hflash, uint8_t clk_inv, uint8_t clk_delay)
Set RX clk invert and delay for high speed flash clock.
- 参数:
hflash – [in] flash handle.
clk_inv – [in] select delayed invert
clk_delay – [in] Select delayed version of Rx clock in order to achieve higher operating frequency
- 返回值:
none –
-
int HAL_FLASH_DEEP_PWRDOWN(FLASH_HandleTypeDef *hflash)
FLASH into deep power down mode.
- 参数:
hflash – flash handle
- 返回值:
0 – if success
-
int HAL_FLASH_RELEASE_DPD(FLASH_HandleTypeDef *hflash)
FLASH release from deep power down mode.
- 参数:
hflash – flash handle
- 返回值:
0 – if success
-
HAL_StatusTypeDef HAL_FLASH_SET_INTERVAL(FLASH_HandleTypeDef *hflash, uint32_t val12, uint32_t val21)
Set comand1/command2 interval timer.
- 参数:
hflash – FLASH handle
val12 – interval between command 1 and command 2
val21 – interval between command 2 and command 1
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_DMA_EN(FLASH_HandleTypeDef *hflash, uint8_t en)
Enable FLASH hardware DMA interface.
- 参数:
hflash – FLASH handle
en – 1 enalbe or 0 disable
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_FLASH_SET_LOOP(FLASH_HandleTypeDef *hflash, uint32_t loop)
Set comand1/command2 auto loop times.
- 参数:
hflash – FLASH handle
loop – loop times
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_CFG_PREFETCH(FLASH_HandleTypeDef *hflash, uint32_t start, uint32_t len)
Set mpi prefetch address.
- 参数:
hflash – mpi handle
start – start address, need 1024 aligned
len – address length, need 1024 aligned
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_MPI_EN_PREFETCH(FLASH_HandleTypeDef *hflash, uint8_t en)
Enable/disable prefetch function.
- 参数:
hflash – mpi handle
en – enable (1) or disable (0) prefetch
- 返回值:
HAL – status
-
struct qspi_configure_t
- #include <bf0_hal_mpi.h>
SPI_FLASH configure tyep.
-
struct FLASH_CMD_CFG_T
- #include <bf0_hal_mpi.h>
SPI_FLASH manual command.
Public Members
-
uint8_t cmd
-
uint8_t func_mode
manual read 0 / write 1
-
uint8_t data_mode
0 no data / 1 single line / 2 dual line / 3 qual line
-
uint8_t dummy_cycle
dummy cycle between command and address/data
-
uint8_t ab_size
alternate byte size,
-
uint8_t ab_mode
alternate byte mode, 0 no, 1, single line, 2, dual line, 3 fouline
-
uint8_t addr_size
address byte count - 1
-
uint8_t addr_mode
0 no, 1 single line / 2 dual lin / 3 four line
-
uint8_t ins_mode
Instruction mode: 0 - No instruction; 1 - single line; 2 - two lines; 3 - four lines; 4/5/6 - reserved; 7 - four lines DDR
-
uint8_t cmd
-
struct SPI_FLASH_FACT_CFG_T
- #include <bf0_hal_mpi.h>
SPI_FLASH command table.
Public Members
-
uint8_t flash_mode
SPI_FLASH_MODE_E
-
uint8_t manuf_id
FLASH_MANUF_ID_T , manufacturer ID
-
uint8_t mem_type
Memory type for NOR, device ID1 for NAND
-
uint8_t dev_id
Memory density for NOR, device ID2 for NAND
-
uint8_t status_reg
status regiser address for nand
-
uint8_t protect_reg
protect register address for nand
-
uint8_t mode_reg
qe/continue/ecc-e(ecc always bit 4) mode register for nand, otp page counter for nor
-
uint8_t ecc_sta_mask
ecc status bits on status_reg for nand, protect bits on reg0 for nor
-
uint8_t qe_mod_mask
qe setting bits on mode_reg for nand, qe register and bit for nor(bit_cnt<<4 | reg_cnt)
-
uint8_t buf_mod_mask
buf/continue mode bits on mode_reg
-
uint8_t ecc_en_mask
ecc enable bits on mode_reg
-
uint8_t oob_size
oob size for nand, otp page size for each otp (size_in_byte>>8)
-
uint32_t erase_base_size
min erase size
-
FLASH_CMD_CFG_T cmd_cfg[SPI_FLASH_CMD_COUNT]
command table
-
uint8_t flash_mode
-
struct __FLASH_HandleTypeDef
- #include <bf0_hal_mpi.h>
SPI_FLASH initial structure definition.
Public Members
-
MPI_TypeDef *Instance
MPI hardware handler
-
uint32_t ErrorCode
MPI error code
-
DMA_HandleTypeDef *dma
DMA handler
-
const SPI_FLASH_FACT_CFG_T *ctable
flash command timeing list
-
uint32_t base
base address in memory map
-
uint32_t size
flash/psram size in bytes
-
uint32_t freq
Flash/Psram running frequency
-
uint8_t *data_buf
nand cache buffer
-
HAL_FLASH_ModeDef Mode
spi, dual spi or qual spi
-
HAL_LockTypeDef Lock
Lock not used
-
HAL_FLASH_StateTypeDef State
MPI status
-
uint8_t isNand
nor, nand or psram
-
uint8_t dualFlash
used for control flag: bit 0 for nand bytes per page: 0 for 2048 bytes, 1 for 4096 bytes. bit 1 for nand pages per block: 0 for 64 pages, 1 for 128 pages bit 4~7: for NAND ECC status mode as NAND_ECC_MODE_T
-
uint8_t ecc_en
enable ecc for nand; configure rxclk inv/delay for nor; read latency for psram
-
uint8_t buf_mode
enable buffer mode for nand; enable DTR for nor; write latency for psram
-
uint8_t wakeup
wake up mode for psram, plane select flag for nand
-
uint32_t reserv1
used as local clock divider for dual flash
-
flash_cs_ctrl cs_ctrl
cs control function pointer
-
flash_lock_ctrl lock
-
MPI_TypeDef *Instance