HAL FLASH Functions

HAL FLASH Initialization and De-initialization functions

group FLASH_Exported_Functions_Group1

This subsection provides a set of functions allowing initialization and de-initialization of the FLASH peripheral:

  • Call the function HAL_FLASH_Init() to initialize the FLASH handle and associate a physical FLASH instance. (As optional, FLASH clock is enabled inside the function)

  • Call the function HAL_FLASH_DeInit() to de-initialize the FLASH handle.

Functions

hal_status_t HAL_FLASH_Init ( hal_flash_handle_t * hflash , hal_flash_t instance )

Initialize the FLASH handle and associate a physical FLASH instance.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when hflash pointer is NULL.

  • HAL_OK – FLASH is successfully initialized.

void HAL_FLASH_DeInit ( hal_flash_handle_t * hflash )

De-initialize the FLASH handle.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

HAL FLASH Configuration functions

group FLASH_Exported_Functions_Group2

This subsection provides a set of functions allowing configuration of the FLASH peripheral:

Functions

hal_status_t HAL_FLASH_SetProgrammingMode ( hal_flash_handle_t * hflash , hal_flash_program_mode_t programming_mode )

Set the FLASH programming mode configuration.

Parameters :
Return values :

HAL_OK – Programming mode is successfully configured.

hal_flash_program_mode_t HAL_FLASH_GetProgrammingMode ( const hal_flash_handle_t * hflash )

Get the FLASH programming mode configuration.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

hal_flash_program_mode_t – Programming mode value.

HAL FLASH Process Operations functions

group FLASH_Exported_Functions_Group3

This subsection provides a set of functions allowing programming and erasing of the FLASH memory:

Functions

hal_status_t HAL_FLASH_ProgramByAddr ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte , uint32_t timeout_ms )

Program the FLASH memory at specified user address in polling mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash to be programmed.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

  • timeout_ms – Timeout value for programming.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_ProgramByAddr_IT ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte )

Program the FLASH memory at specified address in interrupt mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash to be programmed.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_ProgramByAddrAdapt ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte , uint32_t timeout_ms )

Program the FLASH memory at specified user address using adaptive width in polling mode.

Note

The adaptive mode optimizes FLASH programming access based on the remaining data size, ignoring the programming mode selected by the HAL_FLASH_SetProgrammingMode() API.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash to be programmed.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

  • timeout_ms – Timeout value for programming.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_ProgramByAddrAdapt_IT ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte )

Program the FLASH memory at specified address using adaptive width in interrupt mode.

Note

The adaptive mode optimizes FLASH programming access based on the remaining data size, ignoring the programming mode selected by the HAL_FLASH_SetProgrammingMode() API.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash to be programmed.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_OTP_ProgramByAddr ( hal_flash_handle_t * hflash , uint32_t otp_addr , const uint32_t * p_data , uint32_t size_byte , uint32_t timeout_ms )

Program the OTP area at specified address in polling mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • otp_addr – OTP address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

  • timeout_ms – Timeout value for programming.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked or when the TrustZone enabled.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_OTP_ProgramByAddr_IT ( hal_flash_handle_t * hflash , uint32_t otp_addr , const uint32_t * p_data , uint32_t size_byte )

Program the OTP area at specified address in interrupt mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • otp_addr – OTP address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked or when the TrustZone enabled.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_OTP_ProgramByAddrAdapt ( hal_flash_handle_t * hflash , uint32_t otp_addr , const uint32_t * p_data , uint32_t size_byte , uint32_t timeout_ms )

Program the OTP area at specified address using adaptive width in polling mode.

Note

The adaptive mode optimizes FLASH programming access based on the remaining data size, ignoring the programming mode selected by the HAL_FLASH_SetProgrammingMode() API.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • otp_addr – OTP address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

  • timeout_ms – Timeout value for programming.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked or when the TrustZone enabled.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_OTP_ProgramByAddrAdapt_IT ( hal_flash_handle_t * hflash , uint32_t otp_addr , const uint32_t * p_data , uint32_t size_byte )

Program the OTP area at specified address using adaptive width in interrupt mode.

Note

The adaptive mode optimizes FLASH programming access based on the remaining data size, ignoring the programming mode selected by the HAL_FLASH_SetProgrammingMode() API.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • otp_addr – OTP address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked or when the TrustZone enabled.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_EDATA_ProgramByAddr ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte , uint32_t timeout_ms )

Program the EDATA area at specified address in polling mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – FLASH EDATA address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

  • timeout_ms – Timeout value for programming.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_EDATA_ProgramByAddr_IT ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte )

Program the EDATA area at specified address in interrupt mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – FLASH EDATA address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_EDATA_ProgramByAddrAdapt ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte , uint32_t timeout_ms )

Program the EDATA area at specified address using adaptive width in polling mode.

Note

The adaptive mode optimizes FLASH programming access based on the remaining data size, ignoring the programming mode selected by the HAL_FLASH_SetProgrammingMode() API.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – FLASH EDATA address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

  • timeout_ms – Timeout value for programming.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_EDATA_ProgramByAddrAdapt_IT ( hal_flash_handle_t * hflash , uint32_t flash_addr , const uint32_t * p_data , uint32_t size_byte )

Program the EDATA area at specified address using adaptive width in interrupt mode.

Note

The adaptive mode optimizes FLASH programming access based on the remaining data size, ignoring the programming mode selected by the HAL_FLASH_SetProgrammingMode() API.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – FLASH EDATA address.

  • p_data – Pointer to the data to be programmed.

  • size_byte – Size of the data to be programmed (in bytes).

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new programming operation.

  • HAL_OK – Returned when the programming operation completes successfully.

hal_status_t HAL_FLASH_EraseByAddr ( hal_flash_handle_t * hflash , uint32_t flash_addr , uint32_t size_byte , uint32_t timeout_ms )

Erase the FLASH memory at specified address in polling mode.

Warning

Since the smallest erase granularity is at page level, this function will erase a greater area than the one defined by flash_addr and size_byte if these parameters do not represent an area aligned with the start and the end of flash pages.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash page to be erased. This parameter must be aligned with the start of a page.

  • size_byte – Size of the area to be erased (in bytes). This parameter must be a multiple of the page size.

  • timeout_ms – Timeout value for erasing.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EraseByAddr_IT ( hal_flash_handle_t * hflash , uint32_t flash_addr , uint32_t size_byte )

Erase the FLASH memory at specified address in interrupt mode.

Warning

Since the smallest erase granularity is at page level, this function will erase a greater area than the one defined by flash_addr and size_byte if these parameters do not represent an area aligned with the start and the end of flash pages.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash page to be erased. This parameter must be aligned with the start of a page.

  • size_byte – Size of the data to be erased (in bytes). This parameter must be a multiple of the page size.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EDATA_EraseByAddr ( hal_flash_handle_t * hflash , uint32_t flash_addr , uint32_t size_byte , uint32_t timeout_ms )

Erase the FLASH EDATA memory at specified address in polling mode.

Warning

Since the smallest erase granularity is at page level, this function will erase a greater area than the one defined by flash_addr and size_byte if these parameters do not represent an area aligned with the start and the end of flash pages.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash page to be erased. This parameter must be aligned with the start of a page.

  • size_byte – Size of the area to be erased (in bytes). This parameter must be a multiple of the page size.

  • timeout_ms – Timeout value for erasing.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EDATA_EraseByAddr_IT ( hal_flash_handle_t * hflash , uint32_t flash_addr , uint32_t size_byte )

Erase the FLASH EDATA memory at specified address in interrupt mode.

Warning

Since the smallest erase granularity is at page level, this function will erase a greater area than the one defined by flash_addr and size_byte if these parameters do not represent an area aligned with the start and the end of flash pages.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Start address of flash page to be erased. This parameter must be aligned with the start of a page.

  • size_byte – Size of the data to be erased (in bytes). This parameter must be a multiple of the page size.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_ErasePage ( hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page , uint32_t page_nbr , uint32_t timeout_ms )

Erase the FLASH memory by page in polling mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • bank – This parameter can be one of the following values:

  • page – First page to be erased.

  • page_nbr – Number of pages to be erased.

  • timeout_ms – Timeout value for page erasing.

Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_ErasePage_IT ( hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page , uint32_t page_nbr )

Erase the FLASH memory by page in interrupt mode.

Parameters :
Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EDATA_ErasePage ( hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page , uint32_t page_nbr , uint32_t timeout_ms )

Erase the FLASH EDATA memory by page in polling mode.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • bank – This parameter can be one of the following values:

  • page – First page to be erased.

  • page_nbr – Number of pages to be erased.

  • timeout_ms – Timeout value for page erasing.

Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EDATA_ErasePage_IT ( hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page , uint32_t page_nbr )

Erase the FLASH EDATA memory by page in interrupt mode.

Parameters :
Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EraseBank ( hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t timeout_ms )

Erase the FLASH memory by bank in polling mode.

Warning

This function will erase a specific Flash bank, thus it must not be mapped in this bank.

Parameters :
Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_EraseBank_IT ( hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Erase the FLASH memory by bank in interrupt mode.

Warning

This function will erase a specific Flash bank, thus it must not be mapped in this bank.

Parameters :
Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_MassErase ( hal_flash_handle_t * hflash , uint32_t timeout_ms )

Mass erase the FLASH memory in polling mode.

Warning

This function will erase the whole Flash, thus it must not be mapped in the Flash area.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • timeout_ms – Timeout value for mass erasing.

Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_TIMEOUT – Internal processing exceeded the timeout.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

hal_status_t HAL_FLASH_MassErase_IT ( hal_flash_handle_t * hflash )

Mass erase the FLASH memory in interrupt mode.

Warning

This function will erase the whole Flash, thus it must not be mapped in the Flash area.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :
  • HAL_ERROR – Returned when the FLASH access registers locked.

  • HAL_BUSY – Returned when the FLASH is busy and cannot start a new erase operation.

  • HAL_OK – Returned when the erasing operation completes successfully.

void HAL_FLASH_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

void HAL_FLASH_ProgramByAddr_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH program by address interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

void HAL_FLASH_EraseByAddr_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH erase by address interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

void HAL_FLASH_ErasePage_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH erase page interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

void HAL_FLASH_EraseBank_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH erase bank interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

void HAL_FLASH_MassErase_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH mass erase interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

hal_status_t HAL_FLASH_NMI_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH ITF NMI interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :
  • HAL_ERROR – Returned when the NMI has not been handled by this function.

  • HAL_OK – Returned when the NMI has been handled by this function.

void HAL_FLASH_ECC_IRQHandler ( hal_flash_handle_t * hflash )

Handle the FLASH ITF ECC correction interrupt request.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

HAL FLASH Callback functions

group FLASH_Exported_Functions_Group4

This subsection provides a set of functions allowing management of the FLASH callbacks:

Functions

void HAL_FLASH_ProgramCpltCallback ( hal_flash_handle_t * hflash , uint32_t flash_addr , uint32_t size_byte )

FLASH program complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Programmed address.

  • size_byte – Programmed size in byte.

void HAL_FLASH_EraseByAddrCpltCallback ( hal_flash_handle_t * hflash , uint32_t flash_addr , uint32_t size_byte )

FLASH erase by address complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • flash_addr – Erased address.

  • size_byte – Erased size in byte.

void HAL_FLASH_ErasePageCpltCallback ( hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page , uint32_t page_nbr )

FLASH erase by page complete callback.

Parameters :
void HAL_FLASH_EraseBankCpltCallback ( hal_flash_handle_t * hflash , hal_flash_bank_t bank )

FLASH bank erase complete callback.

Parameters :
void HAL_FLASH_MassEraseCpltCallback ( hal_flash_handle_t * hflash )

FLASH mass erase complete callback.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

void HAL_FLASH_ErrorCallback ( hal_flash_handle_t * hflash , hal_flash_bank_t bank )

FLASH error callback.

Parameters :
hal_status_t HAL_FLASH_ECC_ErrorCallback ( hal_flash_handle_t * hflash , hal_flash_bank_t bank )

FLASH error code correction callback.

Parameters :
Return values :
  • HAL_ERROR – Returned when this callback did not manage the ECC interrupt.

  • HAL_OK – Returned when this callback managed the ECC interrupt.

hal_status_t HAL_FLASH_RegisterProgramCpltCallback ( hal_flash_handle_t * hflash , hal_flash_program_cplt_cb_t callback )

Register the FLASH program complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the program complete callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

hal_status_t HAL_FLASH_RegisterEraseByAddrCpltCallback ( hal_flash_handle_t * hflash , hal_flash_erase_by_addr_cplt_cb_t callback )

Register the FLASH erase by address complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the erase by address complete callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

hal_status_t HAL_FLASH_RegisterErasePageCpltCallback ( hal_flash_handle_t * hflash , hal_flash_erase_page_cplt_cb_t callback )

Register the FLASH erase by page complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the erase by page complete callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

hal_status_t HAL_FLASH_RegisterEraseBankCpltCallback ( hal_flash_handle_t * hflash , hal_flash_erase_bank_cplt_cb_t callback )

Register the FLASH bank erase complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the bank erase complete callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

hal_status_t HAL_FLASH_RegisterMassEraseCpltCallback ( hal_flash_handle_t * hflash , hal_flash_mass_erase_cplt_cb_t callback )

Register the FLASH mass erase complete callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the mass erase complete callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

hal_status_t HAL_FLASH_RegisterErrorCallback ( hal_flash_handle_t * hflash , hal_flash_error_cb_t callback )

Register the FLASH error callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the error callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

hal_status_t HAL_FLASH_RegisterECCErrorCallback ( hal_flash_handle_t * hflash , hal_flash_ecc_error_cb_t callback )

Register the FLASH ECC error callback.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • callback – Specifies the error callback.

Return values :
  • HAL_INVALID_PARAM – Returned when an invalid input parameter selected.

  • HAL_OK – Returned when the register of the callback completes successfully.

HAL FLASH Status functions

group FLASH_Exported_Functions_Group5

This subsection provides a set of functions allowing access to FLASH data information and status:

Functions

hal_flash_operation_t HAL_FLASH_GetCurrentOperation ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the current operation on the given bank.

Parameters :
Return values :

hal_flash_operation_t – Operation ongoing.

uint32_t HAL_FLASH_GetCurrentProgrammedAddr ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the last programming operation information.

Note

This function must be called during or directly after a ProgramByAddr operation, otherwise the returned information could not be true anymore.

Parameters :
Return values :

uint32_t – FLASH address currently being programmed. 0xFFFFFFFF if no program by address operation is ongoing on the given bank.

uint32_t HAL_FLASH_GetCurrentErasedAddr ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the last address erase operation information.

Note

This function must be called during or directly after a EraseByAddr operation, otherwise the returned information could not be true anymore.

Parameters :
Return values :

uint32_t – Address of the FLASH page currently being erased. 0xFFFFFFFF if no erase page by address operation is ongoing on the given bank.

uint32_t HAL_FLASH_GetCurrentErasedPage ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the last page erase operation information.

Note

This function must be called during or directly after an ErasePage operation, otherwise the returned information could not be true anymore.

Parameters :
Return values :

uint32_t – FLASH page currently being erased. 0xFFFFFFFF if no erase page operation is ongoing on the given bank.

void HAL_FLASH_GetInterruptedByResetOperationInfo ( const hal_flash_handle_t * hflash , hal_flash_interrupted_by_reset_operation_info_t * p_info )

Get the interrupted operation information.

Warning

Be aware that if the interrupted operation is either in the EDATA (with EDATA_EN set to 1) or OTP areas, the reported address is not always accurate due to a hardware limitation. Indeed, in this case, the correct address can be one of the following:

  • Reported address + 0x400

  • Reported address + 0x200

  • Reported address

Parameters :
void HAL_FLASH_GetInfo ( const hal_flash_handle_t * hflash , hal_flash_info_t * p_info )

Get the user FLASH info (size, number and size of banks, number and size of pages).

Parameters :
uint32_t HAL_FLASH_GetSizeByte ( const hal_flash_handle_t * hflash )

Get the total FLASH size.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

The – size in bytes of total FLASH.

uint8_t HAL_FLASH_GetBankNbr ( const hal_flash_handle_t * hflash )

Get the number of FLASH banks.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

The – number of bank.

uint32_t HAL_FLASH_GetBankSizeByte ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the total size in bytes of the given FLASH bank.

Parameters :
Return values :

The – total size in bytes of the given bank.

uint32_t HAL_FLASH_GetUserFlashSizeByte ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the size in bytes of the user flash area of the given bank.

Parameters :
Return values :

The – size in bytes of the user flash area of the given bank.

uint32_t HAL_FLASH_EDATA_GetSizeByte ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the size in bytes of the EDATA flash area of the given bank.

Parameters :
Return values :

The – size in bytes of the EDATA flash area of the given bank.

uint16_t HAL_FLASH_GetUserFlashPageNbr ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the number of pages of the user flash area of the given bank.

Parameters :
Return values :

The – number of pages of the user flash area of the given bank.

uint16_t HAL_FLASH_EDATA_GetPageNbr ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank )

Get the number of pages of the EDATA flash area of the given bank.

Parameters :
Return values :

The – number of pages of the EDATA flash area of the given bank.

uint32_t HAL_FLASH_GetUserFlashPageSizeByte ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page )

Get the size in bytes of the given user area page.

Parameters :
Return values :

The – size in bytes of the given user area page.

uint32_t HAL_FLASH_EDATA_GetPageSizeByte ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page )

Get the size in bytes of the given EDATA area page.

Parameters :
Return values :

The – size in bytes of the given EDATA area page.

uint32_t HAL_FLASH_GetUserFlashAddrOffset ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page )

Get the offset address of the given user area page.

Parameters :
Return values :

Address – The offset address of the given user area page.

uint32_t HAL_FLASH_EDATA_GetAddrOffset ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank , uint32_t page )

Get the offset address of the given EDATA area page.

Parameters :
Return values :

Address – The offset address of the given EDATA area page.

void HAL_FLASH_ECC_GetInfo ( const hal_flash_handle_t * hflash , hal_flash_bank_t bank , hal_flash_ecc_info_t * p_info )

Get the ECC information.

Warning

Be aware that if the error is a ECC single error located either in the EDATA (with EDATA_EN set to 1) or OTP areas, the reported address is not always accurate due to a hardware limitation. Indeed, in this case, the correct address can be one of the following:

  • Reported address + 0x400

  • Reported address + 0x200

  • Reported address

Parameters :
hal_flash_t HAL_FLASH_GetInstance ( const hal_flash_handle_t * hflash )

Get the HAL FLASH instance.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

The – HAL FLASH instance.

FLASH_TypeDef * HAL_FLASH_GetLLInstance ( const hal_flash_handle_t * hflash )

Get the hardware FLASH instance.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

The – hardware FLASH instance.

hal_flash_state_t HAL_FLASH_GetState ( const hal_flash_handle_t * hflash )

Get the FLASH current state.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

State – The FLASH global state.

uint32_t HAL_FLASH_GetLastErrorCodes ( const hal_flash_handle_t * hflash )

Get the FLASH last error codes.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

Error – codes The FLASH last error codes.

void HAL_FLASH_SetUserData ( hal_flash_handle_t * hflash , const void * p_user_data )

Store User Data pointer within the FLASH handle.

Parameters :
  • hflash – Pointer to a hal_flash_handle_t structure.

  • p_user_data – Pointer to the user data.

const void * HAL_FLASH_GetUserData ( const hal_flash_handle_t * hflash )

Retrieve the user data pointer from the FLASH handle.

Parameters :

hflash – Pointer to a hal_flash_handle_t structure.

Return values :

Pointer – to the user data.