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

Data transfers functions. More...

Collaboration diagram for IO operation functions:

## Functions
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 base_priority in the system. More...
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. More...
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. More...
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. More...
hal_status_t | hal_exflash_erase (exflash_handle_t *p_exflash, uint32_t erase_type, uint32_t addr, uint32_t size)
| Erase flash region. More...
hal_status_t | hal_exflash_suspend (exflash_handle_t *p_exflash)
| Suspend flash pragram/erase. More...
hal_status_t | hal_exflash_resume (exflash_handle_t *p_exflash)
| Resume flash pragram/erase. More...
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. More...
hal_status_t | hal_exflash_unlock (exflash_handle_t *p_exflash)
| Unlock write/erase protected in flash. More...
hal_status_t | hal_exflash_deepsleep (exflash_handle_t *p_exflash)
| the exFlash will go to the Deep Power-Down Mode. More...
hal_status_t | hal_exflash_wakeup (exflash_handle_t *p_exflash)
| exFlash will be released from Deep Power-Down Mode. More...
hal_status_t | hal_exflash_reset (exflash_handle_t *p_exflash)
| Reset exFlash. 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_deepsleep()

hal_status_t hal_exflash_deepsleep | ( | exflash_handle_t * | p_exflash | ) |

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

Note
  This function is used only in Indirect Write Mode.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.

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 | ( | exflash_handle_t * | p_exflash,
|  | 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] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.
  [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_lock()

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.

Note
  Locked area only to be read.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.
  [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 | ( | 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 base_priority in the system.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.
  [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_read()

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.

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

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.
  [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_align_word()

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.

Note
  This function is used only in non-encrypted Indirect Read Mode. Data content needs to be processed in 4-byte reverse order. And all parameters need to be aligned with 4 bytes.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.
  [in] | addr | Address to read data in flash, start at EXFLASH_START_ADDR.(Aligned with 4 bytes)
  [out] | p_data | Pointer to data buffer.(Pointer aligned with 4 bytes)
  [in] | size | Size of buffer bytes.number of bytes to read.(A multiple of 4)

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

hal_status_t hal_exflash_reset | ( | exflash_handle_t * | p_exflash | ) |

Reset exFlash.

exFlash will return to its default power-on state and lose all the current volatile settings.

Note
  This function is used only in Indirect Write Mode.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.

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 | ( | exflash_handle_t * | p_exflash | ) |

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.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.

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

hal_status_t hal_exflash_suspend | ( | exflash_handle_t * | p_exflash | ) |

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.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.

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

hal_status_t hal_exflash_unlock | ( | exflash_handle_t * | p_exflash | ) |

Unlock write/erase protected in flash.

Note
  This function will unlock all chip.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.

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 | ( | exflash_handle_t * | p_exflash | ) |

exFlash will be released from Deep Power-Down Mode.

Note
  This function is used only in Indirect Write Mode.

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.

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

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

Parameters

  [in] | p_exflash | Pointer to an exFlash handle which contains the configuration information for the specified exFlash module.
  [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.