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

Data transfers functions. More...

Collaboration diagram for EXFLASH operation functions:

## Functions
void | hal_exflash_timing_set (exflash_timing_param_t *p_time)
| According to the model of internal flash, configure AC parameters to meet the requirements of flash operation timing. More...
hal_status_t | hal_exflash_operation_protection (uint32_t base_priority)
| During Flash erase/write operation, Disable external interrupts with a priority less than or equal to base_priority in the system. More...
void | hal_exflash_set_security (hal_exflash_security_t mode)
| Configure the security mode of flash interface. More...
hal_exflash_security_t | hal_exflash_get_security (void)
| Read the security mode of flash interface. More...
hal_status_t | hal_exflash_page_configure (uint32_t size_type)
| Configure page programming buffer size. More...
hal_status_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...
hal_status_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...
hal_status_t | hal_exflash_erase (uint32_t erase_type, uint32_t addr, uint32_t size)
| Erase flash region. More...
hal_status_t | hal_exflash_suspend (void)
| Suspend flash pragram/erase. More...
hal_status_t | hal_exflash_resume (void)
| Resume flash pragram/erase. More...
hal_status_t | hal_exflash_lock (uint32_t lock_type)
| Lock area of flash to be software protected against Write and Erase operation. More...
hal_status_t | hal_exflash_unlock (void)
| Unlock write/erase protected in flash. More...
hal_status_t | hal_exflash_deepsleep (void)
| the exFlash will go to the Deep Power-Down Mode. More...
hal_status_t | hal_exflash_wakeup (void)
| exFlash will be released from Deep Power-Down Mode. More...
hal_status_t | hal_exflash_enable_quad (exflash_hp_init_t *hp_init)
| Enable Quad mode to allow Quad operation. 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.

      ==============================================================================
                          ##### EXFLASH 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_deepsleep()

hal_status_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()

hal_status_t hal_exflash_enable_quad | ( | exflash_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()

hal_status_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 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_security()

hal_exflash_security_t hal_exflash_get_security | ( | void |  | ) |

Read the security mode of flash interface.

Return values

  HAL_EXFLASH_UNENCRYPTED | Secure read / write is not supported
  HAL_EXFLASH_ENCRYPTED | Secure read / write is supported.

## ◆ hal_exflash_lock()

hal_status_t hal_exflash_lock | ( | uint32_t | lock_type | ) |

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

Note
  This function is used only in Mirror Mode.

Parameters

  [in] | lock_type | Area need to lock

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_operation_protection()

hal_status_t hal_exflash_operation_protection | ( | uint32_t | base_priority | ) |

During Flash erase/write operation, Disable external interrupts with a priority less than or equal to base_priority in the system.

Parameters

  [in] | base_priority | Base Priority value to set.

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_page_configure()

hal_status_t hal_exflash_page_configure | ( | uint32_t | size_type | ) |

Configure page programming buffer size.

Note
  This function provides a 256/512/1024 Byte page programming buffer that can increase programming performance. However, in encrypted mode, only support 256 Byte page programming.

Parameters

  [in] | size_type | This parameter can be one of the following values: EXFLASH_SINGLE_PAGE_TYPE EXFLASH_DUAL_PAGE_TYPE EXFLASH_QUAD_PAGE_TYPE

## ◆ hal_exflash_read()

hal_status_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_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_resume()

hal_status_t hal_exflash_resume | ( | void |  | ) |

Resume flash pragram/erase.

Note
  The Resume instruction resumes a suspended Page Program, Sector Erase, or Block Erase operation. Before issuing the Resume instruction to restart a suspended erase operation, make sure that there is no Page Program operation in progress. This function is only used in XIP 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_set_security()

void hal_exflash_set_security | ( | hal_exflash_security_t | mode | ) |

Configure the security mode of flash interface.

Note
  If the security mode of flash interface is set to encrypted. the plaintext data will be stored as cipertext when the hal_exflash_write is called. and the cipertext data stored in flash will be read as plaintext data when the hal_exflash_read is called.

Parameters

  [in] | mode | Specifies the value to be written to the selected enum. HAL_EXFLASH_UNENCRYPTED: Data will be not encrypted and decrypted in write-read operations HAL_EXFLASH_ENCRYPTED: Data will be encrypted and decrypted in write-read operations

## ◆ hal_exflash_suspend()

hal_status_t hal_exflash_suspend | ( | void |  | ) |

Suspend flash pragram/erase.

Note
  The Suspend instruction interrupts a Page Program, Sector Erase, or Block Erase operation to allow access to the memory array. After the program or erase operation has entered the suspended state, the memory array can be read except for the page being programmed or the sector or block being erased. This function is only used in XIP 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_timing_set()

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

According to the model of internal flash, configure AC parameters to meet the requirements of flash operation timing.

Note
  If this function is not called, the flash interface will use default parameters.

Parameters

  [in] | p_time | Pointer to a timing structure which contains the AC parameters information for the specified exFlash module.

## ◆ hal_exflash_unlock()

hal_status_t hal_exflash_unlock | ( | void |  | ) |

Unlock write/erase protected in flash.

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_wakeup()

hal_status_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()

hal_status_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.