VSF Documented
Macros | Functions
flash_common.c File Reference
#include "hal/driver/driver.h"

Macros

#define VSF_FLASH_CFG_FUNCTION_RENAME   DISABLED
 

Functions

vsf_err_t vsf_flash_init (vsf_flash_t *flash_ptr, vsf_flash_cfg_t *cfg_ptr)
 Initialize a FLASH instance.
 
void vsf_flash_fini (vsf_flash_t *flash_ptr)
 Finalize a FLASH instance.
 
fsm_rt_t vsf_flash_enable (vsf_flash_t *flash_ptr)
 Enable a FLASH instance.
 
fsm_rt_t vsf_flash_disable (vsf_flash_t *flash_ptr)
 Disable a FLASH instance.
 
void vsf_flash_irq_enable (vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t irq_mask)
 Enable interrupt masks of FLASH instance.
 
void vsf_flash_irq_disable (vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t irq_mask)
 Disable interrupt masks of FLASH instance.
 
vsf_flash_irq_mask_t vsf_flash_irq_clear (vsf_flash_t *flash_ptr, vsf_flash_irq_mask_t irq_mask)
 Clear interrupt flags of FLASH instance and return previous state.
 
vsf_flash_status_t vsf_flash_status (vsf_flash_t *flash_ptr)
 Get the status of FLASH instance.
 
vsf_flash_capability_t vsf_flash_capability (vsf_flash_t *flash_ptr)
 Get the capabilities of FLASH instance.
 
vsf_err_t vsf_flash_erase_one_sector (vsf_flash_t *flash_ptr, uint_fast32_t offset)
 FLASH erase one sector.
 
vsf_err_t vsf_flash_erase_multi_sector (vsf_flash_t *flash_ptr, uint_fast32_t offset, uint_fast32_t size)
 Flash erase a continuous range.
 
vsf_err_t vsf_flash_erase_all (vsf_flash_t *flash_ptr)
 Flash chip erase.
 
vsf_err_t vsf_flash_write_one_sector (vsf_flash_t *flash_ptr, uint_fast32_t offset, uint8_t *buffer, uint_fast32_t size)
 Flash write one sector.
 
vsf_err_t vsf_flash_write_multi_sector (vsf_flash_t *flash_ptr, uint_fast32_t offset, uint8_t *buffer, uint_fast32_t size)
 Flash write multi sector.
 
vsf_err_t vsf_flash_read_one_sector (vsf_flash_t *flash_ptr, uint_fast32_t offset, uint8_t *buffer, uint_fast32_t size)
 flash read one sector
 
vsf_err_t vsf_flash_read_multi_sector (vsf_flash_t *flash_ptr, uint_fast32_t offset, uint8_t *buffer, uint_fast32_t size)
 flash read multi sector
 
vsf_err_t vsf_flash_get_configuration (vsf_flash_t *flash_ptr, vsf_flash_cfg_t *cfg_ptr)
 Get current configuration of a FLASH instance.
 
vsf_err_t vsf_flash_ctrl (vsf_flash_t *flash_ptr, vsf_flash_ctrl_t ctrl, void *param)
 Execute a control command on the Flash instance.
 

Macro Definition Documentation

◆ VSF_FLASH_CFG_FUNCTION_RENAME

#define VSF_FLASH_CFG_FUNCTION_RENAME   DISABLED

Function Documentation

◆ vsf_flash_init()

vsf_err_t vsf_flash_init ( vsf_flash_t flash_ptr,
vsf_flash_cfg_t cfg_ptr 
)

Initialize a FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]cfg_ptra pointer to configuration structure vsf_flash_cfg_t
Returns
vsf_err_t: VSF_ERR_NONE if initialization successful, otherwise returns error code
Note
It is not necessary to call vsf_flash_fini() to deinitialization.
vsf_flash_init() should be called before any other FLASH API except vsf_flash_capability().

◆ vsf_flash_fini()

void vsf_flash_fini ( vsf_flash_t flash_ptr)

Finalize a FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
Returns
none

◆ vsf_flash_enable()

fsm_rt_t vsf_flash_enable ( vsf_flash_t flash_ptr)

Enable a FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
Returns
fsm_rt_t: fsm_rt_cpl if FLASH was enabled, fsm_rt_on_going if FLASH is still enabling

◆ vsf_flash_disable()

fsm_rt_t vsf_flash_disable ( vsf_flash_t flash_ptr)

Disable a FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
Returns
fsm_rt_t: fsm_rt_cpl if FLASH was disabled, fsm_rt_on_going if FLASH is still disabling

◆ vsf_flash_irq_enable()

void vsf_flash_irq_enable ( vsf_flash_t flash_ptr,
vsf_flash_irq_mask_t  irq_mask 
)

Enable interrupt masks of FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]irq_maskone or more value of enum vsf_flash_irq_mask_t
Returns
none
Note
All pending interrupts should be cleared before interrupts are enabled.

◆ vsf_flash_irq_disable()

void vsf_flash_irq_disable ( vsf_flash_t flash_ptr,
vsf_flash_irq_mask_t  irq_mask 
)

Disable interrupt masks of FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]irq_maskone or more value of enum vsf_flash_irq_mask_t, vsf_flash_irq_mask_t
Returns
none

◆ vsf_flash_irq_clear()

vsf_flash_irq_mask_t vsf_flash_irq_clear ( vsf_flash_t flash_ptr,
vsf_flash_irq_mask_t  irq_mask 
)

Clear interrupt flags of FLASH instance and return previous state.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]irq_maskone or more values of enum vsf_flash_irq_mask_t to clear
Returns
vsf_flash_irq_mask_t: the interrupt mask state before clearing (0 if no flags were set)
Note
This function attempts to clear the specified interrupt flags if they are set, and returns the state of those flags before clearing. This is useful for polling operations and determining if interrupts occurred. Note that if interrupts are enabled and an interrupt handler is active, the interrupt handler may clear the interrupt flags automatically. In such cases, this function will return 0 even if interrupts occurred.

◆ vsf_flash_status()

vsf_flash_status_t vsf_flash_status ( vsf_flash_t flash_ptr)

Get the status of FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
Returns
vsf_flash_status_t: All status of current FLASH vsf_flash_status_t

◆ vsf_flash_capability()

vsf_flash_capability_t vsf_flash_capability ( vsf_flash_t flash_ptr)

Get the capabilities of FLASH instance.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
Returns
vsf_flash_capability_t: All capabilities of current FLASH vsf_flash_capability_t

◆ vsf_flash_erase_one_sector()

vsf_err_t vsf_flash_erase_one_sector ( vsf_flash_t flash_ptr,
vsf_flash_size_t  offset_of_bytes 
)

FLASH erase one sector.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]offset_of_bytesThe address of the sector to be erased, needs to be an integer multiple of the smallest erasable sector size
Returns
vsf_err_t: VSF_ERR_NONE if FLASH starts to perform the erase, otherwise returns error code

◆ vsf_flash_erase_multi_sector()

vsf_err_t vsf_flash_erase_multi_sector ( vsf_flash_t flash_ptr,
vsf_flash_size_t  offset_of_bytes,
vsf_flash_size_t  size_of_bytes 
)

Flash erase a continuous range.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]offset_of_bytesThe address of the sector to be erased, needs to be an integer multiple of the smallest erasable sector size
[in]size_of_bytesSize in bytes to erase, needs to be an integer multiple of the smallest erasable sector size
Returns
vsf_err_t: VSF_ERR_NONE if flash starts to perform the erase, or a negative error code

◆ vsf_flash_erase_all()

vsf_err_t vsf_flash_erase_all ( vsf_flash_t flash_ptr)

Flash chip erase.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
Returns
vsf_err_t: VSF_ERR_NONE if flash starts to perform the chip erase, or a negative error code

◆ vsf_flash_write_one_sector()

vsf_err_t vsf_flash_write_one_sector ( vsf_flash_t flash_ptr,
vsf_flash_size_t  offset_of_bytes,
uint8_t buffer,
vsf_flash_size_t  size_of_bytes 
)

Flash write one sector.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]offset_of_bytesAddress of the sector to be written, some flash requires an integer multiple of the smallest writable sector size
[in]buffera pointer to data
[in]size_of_bytesa pointer to data
Returns
vsf_err_t: VSF_ERR_NONE if flash starts to perform the write, or a negative error code

◆ vsf_flash_write_multi_sector()

vsf_err_t vsf_flash_write_multi_sector ( vsf_flash_t flash_ptr,
vsf_flash_size_t  offset_of_bytes,
uint8_t buffer,
vsf_flash_size_t  size_of_bytes 
)

Flash write multi sector.

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]offset_of_bytesAddress of the sector to be written, some flash requires an integer multiple of the smallest writable sector size
[in]buffera pointer to data
[in]size_of_bytessize of data to write
Returns
vsf_err_t: VSF_ERR_NONE if flash starts to perform the write, or a negative error code

◆ vsf_flash_read_one_sector()

vsf_err_t vsf_flash_read_one_sector ( vsf_flash_t flash_ptr,
vsf_flash_size_t  offset_of_bytes,
uint8_t buffer,
vsf_flash_size_t  size_of_bytes 
)

flash read one sector

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]offset_of_bytesAddress of the sector to be written, some flash requires an integer multiple of the smallest writable sector size
[in]buffera pointer to data
[in]size_of_bytesa pointer to data
Returns
vsf_err_t: VSF_ERR_NONE if flash starts to perform the chip erase, or a negative error code

◆ vsf_flash_read_multi_sector()

vsf_err_t vsf_flash_read_multi_sector ( vsf_flash_t flash_ptr,
vsf_flash_size_t  offset_of_bytes,
uint8_t buffer,
vsf_flash_size_t  size_of_bytes 
)

flash read multi sector

Parameters
[in]flash_ptra pointer to structure vsf_flash_t
[in]offset_of_bytesAddress of the sector to be written, some flash requires an integer multiple of the smallest writable sector size
[in]buffera pointer to data
[in]size_of_bytesa pointer to data
Returns
vsf_err_t: VSF_ERR_NONE if flash starts to perform the chip erase, or a negative error code

◆ vsf_flash_get_configuration()

vsf_err_t vsf_flash_get_configuration ( vsf_flash_t flash_ptr,
vsf_flash_cfg_t cfg_ptr 
)

Get current configuration of a FLASH instance.

Parameters
[in]flash_ptrPointer to FLASH instance
[out]cfg_ptrPointer to FLASH configuration structure to store current settings
Returns
vsf_err_t VSF_ERR_NONE if successful, otherwise an error code
Note
This function retrieves the current configuration of the FLASH instance

◆ vsf_flash_ctrl()

vsf_err_t vsf_flash_ctrl ( vsf_flash_t flash_ptr,
vsf_flash_ctrl_t  ctrl,
void *  param 
)

Execute a control command on the Flash instance.

Parameters
[in,out]flash_ptrPointer to Flash instance structure vsf_flash_t
[in]ctrlControl command from vsf_flash_ctrl_t enumeration
[in]paramCommand-specific parameter (can be NULL depending on command)
Returns
vsf_err_t: VSF_ERR_NONE if command executed successfully, VSF_ERR_NOT_SUPPORT if command is not supported, other error codes defined by vsf_err_t for specific failures
Note
Available commands and their parameters are hardware-dependent
Some commands may not be supported on all hardware platforms
Generated from commit: vsfteam/vsf@b2e9e8a