Go to the documentation of this file.
52 #ifndef __GR55xx_HAL_EXFLASH_H__
53 #define __GR55xx_HAL_EXFLASH_H__
175 #define HAL_EXFLASH_ERROR_NONE ((uint32_t)0x00000000)
176 #define HAL_EXFLASH_ERROR_TIMEOUT ((uint32_t)0x00000001)
177 #define HAL_EXFLASH_ERROR_TRANSFER ((uint32_t)0x00000002)
178 #define HAL_EXFLASH_ERROR_ID ((uint32_t)0x00000003)
179 #define HAL_EXFLASH_ERROR_QUAD ((uint32_t)0x00000004)
180 #define HAL_EXFLASH_ERROR_INVALID_PARAM ((uint32_t)0x00000008)
186 #define EXFLASH_ERASE_SECTOR 0
187 #define EXFLASH_ERASE_CHIP 1
193 #define EXFLASH_SIZE_PAGE_BYTES ((uint32_t)256)
194 #define EXFLASH_SIZE_SECTOR_BYTES ((uint32_t)4096)
195 #define EXFLASH_SIZE_CHIP_BYTES ((uint32_t)0x800000)
196 #define EXFLASH_START_ADDR FLASH_BASE
197 #define EXFLASH_SIZE (0x00800000UL)
198 #define EXFLASH_END_ADDR (EXFLASH_START_ADDR + EXFLASH_SIZE)
199 #define EXFLASH_ALIAS_OFFSET (0x02000000UL)
200 #define EXFLASH_ALIAS_ADDR (EXFLASH_START_ADDR + EXFLASH_ALIAS_OFFSET)
206 #define EXFLASH_LOCK_AREA_NONE 0
207 #define EXFLASH_LOCK_AREA_UPPER_1_8 1
208 #define EXFLASH_LOCK_AREA_UPPER_1_4 2
209 #define EXFLASH_LOCK_AREA_UPPER_1_2 3
210 #define EXFLASH_LOCK_AREA_LOWER_1_8 9
211 #define EXFLASH_LOCK_AREA_LOWER_1_4 10
212 #define EXFLASH_LOCK_AREA_LOWER_1_2 11
213 #define EXFLASH_LOCK_AREA_ALL 12
214 #define EXFLASH_LOCK_AREA_TOP_4K 17
215 #define EXFLASH_LOCK_AREA_TOP_8K 18
216 #define EXFLASH_LOCK_AREA_TOP_16K 19
217 #define EXFLASH_LOCK_AREA_TOP_32K 20
218 #define EXFLASH_LOCK_AREA_BOTTOM_4K 25
219 #define EXFLASH_LOCK_AREA_BOTTOM_8K 26
220 #define EXFLASH_LOCK_AREA_BOTTOM_16K 27
221 #define EXFLASH_LOCK_AREA_BOTTOM_32K 28
222 #define EXFLASH_LOCK_AREA_LOWER_7_8 33
223 #define EXFLASH_LOCK_AREA_LOWER_3_4 34
224 #define EXFLASH_LOCK_AREA_UPPER_7_8 41
225 #define EXFLASH_LOCK_AREA_UPPER_3_4 42
226 #define EXFLASH_LOCK_AREA_LOWER_127_128 49
227 #define EXFLASH_LOCK_AREA_LOWER_63_64 50
228 #define EXFLASH_LOCK_AREA_LOWER_31_32 51
229 #define EXFLASH_LOCK_AREA_LOWER_15_16 52
230 #define EXFLASH_LOCK_AREA_UPPER_127_128 57
231 #define EXFLASH_LOCK_AREA_UPPER_63_64 58
232 #define EXFLASH_LOCK_AREA_UPPER_31_32 59
233 #define EXFLASH_LOCK_AREA_UPPER_15_16 60
239 #define HAL_EXFLASH_RETRY_DEFAULT_VALUE ((uint32_t)400000)
253 #define __HAL_EXFLASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_EXFLASH_STATE_RESET)
258 #define __HAL_EXFLASH_POWER_ON() ll_xqspi_enable_exflash_power()
263 #define __HAL_EXFLASH_POWER_OFF() ll_xqspi_disable_exflash_power()
277 #define IS_EXFLASH_ERASE_TYPE(__TYPE__) (((__TYPE__) == EXFLASH_ERASE_SECTOR) || \
278 ((__TYPE__) == EXFLASH_ERASE_CHIP))
285 #define IS_EXFLASH_LOCK_AREA(__AREA__) (((__AREA__) == EXFLASH_LOCK_AREA_NONE) || \
286 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_1_8) || \
287 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_1_4) || \
288 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_1_2) || \
289 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_1_8) || \
290 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_1_4) || \
291 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_1_2) || \
292 ((__AREA__) == EXFLASH_LOCK_AREA_ALL) || \
293 ((__AREA__) == EXFLASH_LOCK_AREA_TOP_4K) || \
294 ((__AREA__) == EXFLASH_LOCK_AREA_TOP_8K) || \
295 ((__AREA__) == EXFLASH_LOCK_AREA_TOP_16K) || \
296 ((__AREA__) == EXFLASH_LOCK_AREA_TOP_32K) || \
297 ((__AREA__) == EXFLASH_LOCK_AREA_BOTTOM_4K) || \
298 ((__AREA__) == EXFLASH_LOCK_AREA_BOTTOM_8K) || \
299 ((__AREA__) == EXFLASH_LOCK_AREA_BOTTOM_16K) || \
300 ((__AREA__) == EXFLASH_LOCK_AREA_BOTTOM_32K) || \
301 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_7_8) || \
302 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_3_4) || \
303 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_7_8) || \
304 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_3_4) || \
305 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_127_128) || \
306 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_63_64) || \
307 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_31_32) || \
308 ((__AREA__) == EXFLASH_LOCK_AREA_LOWER_15_16) || \
309 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_127_128) || \
310 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_63_64) || \
311 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_31_32) || \
312 ((__AREA__) == EXFLASH_LOCK_AREA_UPPER_15_16))
636 #if defined(ENCRYPT_ENABLE)
void hal_exflash_msp_deinit(exflash_handle_t *p_exflash)
De-initialize the exFlash MSP.
hal_lock_t
HAL Lock structures definition.
hal_status_t hal_exflash_suspend(exflash_handle_t *p_exflash)
Suspend flash pragram/erase.
hal_status_t hal_exflash_deepsleep(exflash_handle_t *p_exflash)
the exFlash will go to the Deep Power-Down Mode.
hal_status_t hal_exflash_lock(exflash_handle_t *p_exflash, uint32_t lock_type)
Lock area of flash to be software protected against Write and Erase operation.
hal_status_t hal_exflash_reset(exflash_handle_t *p_exflash)
Reset exFlash.
uint32_t hal_exflash_get_error(exflash_handle_t *p_exflash)
Return the exFlash error code.
@ HAL_EXFLASH_STATE_RESET
Peripheral not initialized
__IO uint32_t count
exFlash count for suspend and resume
hal_status_t hal_exflash_read_uid(uint8_t *uid)
This function serves to read UID of flash.
@ HAL_EXFLASH_STATE_ERROR
Peripheral in error
hal_status_t hal_exflash_read_align_word(exflash_handle_t *p_exflash, uint32_t addr, uint8_t *p_data, uint32_t size)
[High speed]Read an amount of data with specified instruction and address from flash.
hal_status_t hal_exflash_deinit(exflash_handle_t *p_exflash)
De-initialize the exFlash peripheral.
struct _exflash_handle exflash_handle_t
exFlash handle Structure definition
void hal_exflash_msp_init(exflash_handle_t *p_exflash)
Initialize the exFlash MSP.
uint32_t retry
Repeat times for the exFlash memory access.
hal_status_t(* exflash_operation_func)(exflash_handle_t *p_exflash)
HAL exFlash operation function.
hal_status_t hal_exflash_operation_protection(exflash_handle_t *p_exflash, uint32_t base_priority)
During Flash erase/write operation, Disable external interrupts with a priority less than or equal to...
hal_status_t hal_exflash_read_status_reg(uint16_t *p_reg_status)
This function reads the status register of a flash.
__IO hal_eflash_security security
exFlash data security
@ HAL_EXFLASH_STATE_BUSY_WRITE
Peripheral in indirect mode with transmission ongoing.
hal_status_t hal_exflash_erase(exflash_handle_t *p_exflash, uint32_t erase_type, uint32_t addr, uint32_t size)
Erase flash region.
@ HAL_EXFLASH_ENCRYPTED
Data will be encrypted and decrypted in write-read operations
@ HAL_EXFLASH_STATE_BUSY_READ
Peripheral in indirect mode with reception ongoing
XQSPI handle Structure definition.
struct _hal_exflash_callback hal_exflash_callback_t
HAL_EXFLASH Callback function definition.
__IO hal_exflash_state_t state
exFlash communication state
hal_status_t hal_exflash_resume(exflash_handle_t *p_exflash)
Resume flash pragram/erase.
__IO uint32_t flash_size
exFlash Size
hal_exflash_state_t hal_exflash_get_state(exflash_handle_t *p_exflash)
Return the exFlash handle state.
xqspi_handle_t * p_xqspi
exFlash XQSPI Handle parameters
@ HAL_EXFLASH_STATE_READY
Peripheral initialized and ready for use
hal_status_t
HAL Status structures definition.
hal_status_t hal_exflash_wakeup(exflash_handle_t *p_exflash)
exFlash will be released from Deep Power-Down Mode.
HAL_EXFLASH Callback function definition.
__IO uint32_t fw_mode
exFlash firmware mode
Header file containing functions prototypes of XQSPI HAL library.
hal_status_t hal_exflash_init(exflash_handle_t *p_exflash)
Initialize the exFlash according to the specified parameters in the exflash_init_t and initialize the...
hal_status_t hal_exflash_write_status_reg(uint16_t reg_status)
This function writes the status register of a flash.
hal_eflash_security
HAL exFlash Security Enumerations definition.
Header file containing functions prototypes of XQSPI LL library.
exFlash handle Structure definition
__IO uint32_t error_code
exFlash Error code
void(* exflash_msp_deinit)(exflash_handle_t *p_exflash)
EXFLASH de-init MSP callback
hal_status_t hal_exflash_read(exflash_handle_t *p_exflash, uint32_t addr, uint8_t *p_data, uint32_t size)
Read an amount of data with specified instruction and address from flash.
hal_status_t hal_exflash_operation(exflash_handle_t *p_exflash, exflash_operation_func p_func_exflash_operation)
Call user XIP Flash operation functon.
void(* exflash_msp_init)(exflash_handle_t *p_exflash)
EXFLASH init MSP callback
@ HAL_EXFLASH_STATE_SUSPEND_WRITE
Peripheral in suspend mode from transmission
__IO hal_lock_t lock
Locking object
hal_exflash_state_t
HAL exFlash State Enumerations definition.
@ HAL_EXFLASH_STATE_BUSY
Peripheral in indirect mode and busy
void hal_exflash_set_retry(exflash_handle_t *p_exflash, uint32_t retry)
Set the exFlash internal process timeout value.
@ HAL_EXFLASH_UNENCRYPTED
Data will not be encrypted and decrypted in write-read operations
__IO uint32_t flash_id
exFlash ID
hal_status_t hal_exflash_write(exflash_handle_t *p_exflash, uint32_t addr, uint8_t *p_data, uint32_t size)
Write an amount of data with specified instruction and address to flash.
hal_status_t hal_exflash_unlock(exflash_handle_t *p_exflash)
Unlock write/erase protected in flash.
This file contains HAL common definitions, enumeration, macros and structures definitions.
@ HAL_EXFLASH_STATE_BUSY_ERASE
Peripheral in indirect mode with erase ongoing
@ HAL_EXFLASH_STATE_SUSPEND_ERASE
Peripheral in suspend mode from erase