Functions
IO operation functions
Peripheral Driver » HAL Driver » EXFLASH » Functions

Data transfers functions. More...

## Functions
void | hal_exflash_timing_set (exflash_timing_param_t *p_time)
| Configure flash electrical characteristic parameters. More...
void | hal_exflash_get_info (uint32_t *id, uint32_t *size)
| Get flash id and size. More...
uint32_t | hal_exflash_config (uint32_t configure, uint32_t value)
| flash parameter configuration More...
uint32_t | hal_exflash_enable_quad (ll_xqspi_hp_init_t hp_init)
| Enable Quad mode to allow Quad operation. More...
uint32_t | hal_exflash_write (uint32_t addr, uint8_t *p_data, uint32_t size)
| Write an amount of data with specified instruction and address to flash. More...
uint32_t | hal_exflash_read (uint32_t addr, uint8_t *p_data, uint32_t size)
| Read an amount of data with specified instruction and address from flash. More...
uint32_t | hal_exflash_erase (uint32_t erase_type, uint32_t addr, uint32_t size)
| Erase flash region. More...
uint32_t | hal_exflash_block_protect (uint32_t cmp, uint32_t bp)
| Lock area of flash to be software protected against Write and Erase operation.. More...
uint32_t | hal_exflash_deepsleep (void)
| the exFlash will go to the Deep Power-Down Mode. More...
uint32_t | hal_exflash_wakeup (void)
| exFlash will be released from Deep Power-Down Mode. More...
uint32_t | hal_exflash_sr_erase (uint32_t addr)
| Erase single flash security register. More...
uint32_t | hal_exflash_sr_program (uint32_t addr, uint8_t *p_data, uint32_t size)
| Write an amount of data into flash security register. More...
uint32_t | hal_exflash_sr_read (uint32_t addr, uint8_t *p_data, uint32_t size)
| Read an amount of data from flash security register. More...
uint32_t | hal_exflash_sr_protect (uint32_t lb)
| This function provide the write protect control and status to the Security Registers. More...
hal_status_t | hal_exflash_read_status_reg (uint16_t *p_reg_status)
| This function reads the status register of a flash. More...
hal_status_t | hal_exflash_write_status_reg (uint16_t reg_status)
| This function writes the status register of a flash. More...
hal_status_t | hal_exflash_read_uid (uint8_t *uid)
| This function serves to read UID of flash. More...

## Detailed Description

Data transfers functions.

      ==============================================================================
                          ##### IO operation functions #####
     ===============================================================================
     [..]
        This subsection provides a set of functions allowing to manage the exFlash
        data transfers.

        [..] The exFlash supports XIP and QSPI mode:

        (#) There are only one modes of transfer:
           (++) Blocking mode: The communication is performed in polling mode.
                The HAL status of all data processing is returned by the same function
                after finishing transfer.

## Function Documentation

## ◆ hal_exflash_block_protect()

uint32_t hal_exflash_block_protect | ( | uint32_t | cmp,
|  | uint32_t | bp
| ) |  |

Lock area of flash to be software protected against Write and Erase operation..

Parameters

  [in] | cmp | It is used in conjunction the BPs bits to provide more flexibility for the array protection.
  [in] | bp | Specifies the value to be written to the selected bit. This parameter can be one of the EXFLASH_PROTECTED_AREA_SIZE values: EXFLASH_PROTECT_AREA_00000 EXFLASH_PROTECT_AREA_00001 EXFLASH_PROTECT_AREA_00010 EXFLASH_PROTECT_AREA_00011 EXFLASH_PROTECT_AREA_01001 EXFLASH_PROTECT_AREA_01010 EXFLASH_PROTECT_AREA_01011 EXFLASH_PROTECT_AREA_00100 EXFLASH_PROTECT_AREA_10001 EXFLASH_PROTECT_AREA_10010 EXFLASH_PROTECT_AREA_10011 EXFLASH_PROTECT_AREA_10100 EXFLASH_PROTECT_AREA_10110 EXFLASH_PROTECT_AREA_11001 EXFLASH_PROTECT_AREA_11010 EXFLASH_PROTECT_AREA_11011 EXFLASH_PROTECT_AREA_11100 EXFLASH_PROTECT_AREA_11110 EXFLASH_PROTECT_AREA_11111

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_config()

uint32_t hal_exflash_config | ( | uint32_t | configure,
|  | uint32_t | value
| ) |  |

flash parameter configuration

Parameters

  [in] | configure | flash parameter configuration item
  [in] | value | flash parameter configuration value

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_deepsleep()

uint32_t hal_exflash_deepsleep | ( | void |  | ) |

the exFlash will go to the Deep Power-Down Mode.

Note
  This function is used only in Mirror Mode.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_enable_quad()

uint32_t hal_exflash_enable_quad | ( | ll_xqspi_hp_init_t | hp_init | ) |

Enable Quad mode to allow Quad operation.

Note
  This function is used only in Mirror Mode.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_erase()

uint32_t hal_exflash_erase | ( | uint32_t | erase_type,
|  | uint32_t | addr,
|  | uint32_t | size
| ) |  |

Erase flash region.

Note
  All sectors that have address in range of [addr, addr+len] will be erased. If addr is not sector aligned, preceding data on the sector that addr belongs to will also be erased. If (addr + size) is not sector aligned, the whole sector will also be erased. If erase_type is EXFLASH_ERASE_CHIP , all data in flash will be erased ignored addr and size.

Parameters

  [in] | erase_type | Erase flash with page/sector/chip. EXFLASH_ERASE_SECTOR EXFLASH_ERASE_CHIP
  [in] | addr | Address to erased data in flash, start at EXFLASH_START_ADDR.
  [in] | size | Size of erased bytes.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_get_info()

void hal_exflash_get_info | ( | uint32_t * | id,
|  | uint32_t * | size
| ) |  |

Get flash id and size.

Parameters

  [out] | id | Pointer to flash id
  [out] | size | Pointer to flash size

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_read()

uint32_t hal_exflash_read | ( | uint32_t | addr,
|  | uint8_t * | p_data,
|  | uint32_t | size
| ) |  |

Read an amount of data with specified instruction and address from flash.

Note
  This function is used only in non-encrypted Indirect Read Mode.

Parameters

  [in] | addr | Address to read data in flash, start at EXFLASH_START_ADDR.
  [out] | p_data | Pointer to data buffer
  [in] | size | Size of buffer bytes

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_read_status_reg()

hal_status_t hal_exflash_read_status_reg | ( | uint16_t * | p_reg_status | ) |

This function reads the status register of a flash.

Note
  The status register is a 16-bit register that provides information about the flash operation status.

Parameters

  [in] | p_reg_status | Pointer of status register.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_read_uid()

hal_status_t hal_exflash_read_uid | ( | uint8_t * | uid | ) |

This function serves to read UID of flash.

Parameters

  [out] | uid | store 16 Byte flash UID

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_sr_erase()

uint32_t hal_exflash_sr_erase | ( | uint32_t | addr | ) |

Erase single flash security register.

Note
  This function erase only single security register. If initial_mode is XIP, it will swich to QSPI mode to execute command and switch to XIP mode finally.

Parameters

  [in] | addr | Security Registers address of flash

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_sr_program()

uint32_t hal_exflash_sr_program | ( | uint32_t | addr,
|  | uint8_t * | p_data,
|  | uint32_t | size
| ) |  |

Write an amount of data into flash security register.

Note
  This function is used only in non-encrypted Indirect Write Mode. If initial_mode is XIP, it will swich to QSPI mode to execute command and switch to XIP mode finally.

Parameters

  [in] | addr | Security Registers address of flash
  [out] | p_data | Pointer to data buffer
  [in] | size | Size of data buffer bytes, and need be smaller than single security register

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_sr_protect()

uint32_t hal_exflash_sr_protect | ( | uint32_t | lb | ) |

This function provide the write protect control and status to the Security Registers.

Note
  The LB3-BL1bits of flash status register are One Time Programmable, once its set to 1, the Security Registers will become read-only permanently.

Parameters

  [in] | lb | Locked security registers. This parameter can be a combination of the following values: EXFLASH_LOCK_OTP1 EXFLASH_LOCK_OTP2 EXFLASH_LOCK_OTP3

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_sr_read()

uint32_t hal_exflash_sr_read | ( | uint32_t | addr,
|  | uint8_t * | p_data,
|  | uint32_t | size
| ) |  |

Read an amount of data from flash security register.

Note
  This function is used only in non-encrypted Indirect Read Mode. If initial_mode is XIP, it will swich to QSPI mode to execute command and switch to XIP mode finally.

Parameters

  [in] | addr | Security Registers address of flash
  [out] | p_data | Pointer to data buffer
  [in] | size | Size of data buffer bytes, and need be smaller than single security register

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_timing_set()

void hal_exflash_timing_set | ( | exflash_timing_param_t * | p_time | ) |

Configure flash electrical characteristic parameters.

Parameters

  [in] | p_time | flash timing characteristics

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_wakeup()

uint32_t hal_exflash_wakeup | ( | void |  | ) |

exFlash will be released from Deep Power-Down Mode.

Note
  This function is used only in Mirror Mode.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_write()

uint32_t hal_exflash_write | ( | uint32_t | addr,
|  | uint8_t * | p_data,
|  | uint32_t | size
| ) |  |

Write an amount of data with specified instruction and address to flash.

Note
  This function is used only in Indirect Write Mode. In secure mode, address alignment requires 4 bytes.

Parameters

  [in] | addr | Address to write data in flash, start at EXFLASH_START_ADDR.
  [in] | p_data | Pointer to data buffer
  [in] | size | Size of buffer bytes

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_exflash_write_status_reg()

hal_status_t hal_exflash_write_status_reg | ( | uint16_t | reg_status | ) |

This function writes the status register of a flash.

Note
  The status register is a 16-bit register that provides information about the flash operation status.

Parameters

  reg_status | An integer value representing the content to be written to the flash status register.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.