ChibiOS  21.6.0
EFL Driver

Generic Embedded Flash Driver. More...

Collaboration diagram for EFL Driver:

Detailed Description

Generic Embedded Flash Driver.

This module implements a generic embedded flash driver.

Precondition
In order to use the EFL driver the HAL_USE_EFL option must be enabled in halconf.h.

Macros

#define _efl_flash_methods_alone
 EFlashDriver specific methods. More...
 
#define _efl_flash_methods
 EFlashDriver specific methods with inherited ones. More...
 
#define _efl_driver_data
 EFlashDriver specific data. More...
 
#define efl_lld_driver_fields
 Low level fields of the embedded flash driver structure. More...
 
#define efl_lld_config_fields
 Low level fields of the embedded flash configuration structure. More...
 

PLATFORM configuration options

#define PLATFORM_EFL_USE_EFL1   FALSE
 EFL1 driver enable switch. More...
 

Typedefs

typedef struct hal_efl_driver EFlashDriver
 Type of external flash driver class. More...
 
typedef struct hal_efl_config EFlashConfig
 Type of a structure representing a flash driver configuration. More...
 

Data Structures

struct  EFlashDriverVMT
 EFlash virtual methods table. More...
 
struct  hal_efl_config
 Type of a structure representing a flash driver configuration. More...
 
struct  hal_efl_driver
 Structure representing an embedded flash driver. More...
 

Functions

void eflInit (void)
 Embedded Flash Driver initialization. More...
 
void eflObjectInit (EFlashDriver *eflp)
 Initializes a generic EFlashDriver object. More...
 
void eflStart (EFlashDriver *eflp, const EFlashConfig *config)
 Configures and starts the driver. More...
 
void eflStop (EFlashDriver *eflp)
 Stops the driver. More...
 
void efl_lld_init (void)
 Low level Embedded Flash driver initialization. More...
 
void efl_lld_start (EFlashDriver *eflp)
 Configures and activates the Embedded Flash peripheral. More...
 
void efl_lld_stop (EFlashDriver *eflp)
 Deactivates the Embedded Flash peripheral. More...
 
const flash_descriptor_tefl_lld_get_descriptor (void *instance)
 Gets the flash descriptor structure. More...
 
flash_error_t efl_lld_read (void *instance, flash_offset_t offset, size_t n, uint8_t *rp)
 Read operation. More...
 
flash_error_t efl_lld_program (void *instance, flash_offset_t offset, size_t n, const uint8_t *pp)
 Program operation. More...
 
flash_error_t efl_lld_start_erase_all (void *instance)
 Starts a whole-device erase operation. More...
 
flash_error_t efl_lld_start_erase_sector (void *instance, flash_sector_t sector)
 Starts an sector erase operation. More...
 
flash_error_t efl_lld_query_erase (void *instance, uint32_t *msec)
 Queries the driver for erase operation progress. More...
 
flash_error_t efl_lld_verify_erase (void *instance, flash_sector_t sector)
 Returns the erase state of a sector. More...
 

Variables

EFlashDriver EFLD1
 EFL1 driver identifier. More...
 

Macro Definition Documentation

◆ _efl_flash_methods_alone

#define _efl_flash_methods_alone

EFlashDriver specific methods.

Definition at line 58 of file hal_efl.h.

◆ _efl_flash_methods

#define _efl_flash_methods
Value:
_base_flash_methods \
_efl_flash_methods_alone

EFlashDriver specific methods with inherited ones.

Definition at line 63 of file hal_efl.h.

◆ _efl_driver_data

#define _efl_driver_data
Value:
/* Current configuration data.*/ \
const EFlashConfig *config;

EFlashDriver specific data.

Definition at line 70 of file hal_efl.h.

◆ PLATFORM_EFL_USE_EFL1

#define PLATFORM_EFL_USE_EFL1   FALSE

EFL1 driver enable switch.

If set to TRUE the support for EFL1 is included.

Note
The default is FALSE.

Definition at line 48 of file hal_efl_lld.h.

◆ efl_lld_driver_fields

#define efl_lld_driver_fields
Value:
/* Dummy field, it is not needed.*/ \
uint32_t dummy

Low level fields of the embedded flash driver structure.

Definition at line 67 of file hal_efl_lld.h.

◆ efl_lld_config_fields

#define efl_lld_config_fields
Value:
/* Dummy configuration, it is not needed.*/ \
uint32_t dummy

Low level fields of the embedded flash configuration structure.

Definition at line 74 of file hal_efl_lld.h.

Typedef Documentation

◆ EFlashDriver

typedef struct hal_efl_driver EFlashDriver

Type of external flash driver class.

Definition at line 51 of file hal_efl.h.

◆ EFlashConfig

typedef struct hal_efl_config EFlashConfig

Type of a structure representing a flash driver configuration.

Function Documentation

◆ eflInit()

void eflInit ( void  )

Embedded Flash Driver initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:
Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 67 of file hal_efl.c.

References efl_lld_init().

Referenced by halInit().

Here is the call graph for this function:

◆ eflObjectInit()

void eflObjectInit ( EFlashDriver eflp)

Initializes a generic EFlashDriver object.

Parameters
[out]eflppointer to a EFlashDriver structure
Function Class:
Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 79 of file hal_efl.c.

References hal_efl_driver::vmt.

Referenced by efl_lld_init().

◆ eflStart()

void eflStart ( EFlashDriver eflp,
const EFlashConfig config 
)

Configures and starts the driver.

Parameters
[in]eflppointer to a EFlashDriver structure
[in]configpointer to a configuration structure. If this parameter is set to NULL then a default configuration is used.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 95 of file hal_efl.c.

References osalDbgAssert, osalDbgCheck, and osalSysLock().

Here is the call graph for this function:

◆ eflStop()

void eflStop ( EFlashDriver eflp)

Stops the driver.

Parameters
[in]eflppointer to a EFlashDriver structure
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 117 of file hal_efl.c.

References osalDbgAssert, osalDbgCheck, and osalSysLock().

Here is the call graph for this function:

◆ efl_lld_init()

void efl_lld_init ( void  )

Low level Embedded Flash driver initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 78 of file hal_efl_lld.c.

References EFLD1, and eflObjectInit().

Referenced by eflInit().

Here is the call graph for this function:

◆ efl_lld_start()

void efl_lld_start ( EFlashDriver eflp)

Configures and activates the Embedded Flash peripheral.

Parameters
[in]eflppointer to a EFlashDriver structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 93 of file hal_efl_lld.c.

◆ efl_lld_stop()

void efl_lld_stop ( EFlashDriver eflp)

Deactivates the Embedded Flash peripheral.

Parameters
[in]eflppointer to a EFlashDriver structure
Function Class:
Not an API, this function is for internal use only.

Definition at line 114 of file hal_efl_lld.c.

◆ efl_lld_get_descriptor()

const flash_descriptor_t * efl_lld_get_descriptor ( void *  instance)

Gets the flash descriptor structure.

Parameters
[in]instancepointer to a EFlashDriver instance
Returns
A flash device descriptor.
Function Class:
Not an API, this function is for internal use only.

Definition at line 136 of file hal_efl_lld.c.

◆ efl_lld_read()

flash_error_t efl_lld_read ( void *  instance,
flash_offset_t  offset,
size_t  n,
uint8_t *  rp 
)

Read operation.

Parameters
[in]instancepointer to a EFlashDriver instance
[in]offsetflash offset
[in]nnumber of bytes to be read
[out]rppointer to the data buffer
Returns
An error code.
Return values
FLASH_NO_ERRORif there is no erase operation in progress.
FLASH_BUSY_ERASINGif there is an erase operation in progress.
FLASH_ERROR_READif the read operation failed.
FLASH_ERROR_HW_FAILUREif access to the memory failed.
Function Class:
Not an API, this function is for internal use only.

Definition at line 158 of file hal_efl_lld.c.

◆ efl_lld_program()

flash_error_t efl_lld_program ( void *  instance,
flash_offset_t  offset,
size_t  n,
const uint8_t *  pp 
)

Program operation.

Note
The device supports ECC, it is only possible to write erased pages once except when writing all zeroes.
Parameters
[in]instancepointer to a EFlashDriver instance
[in]offsetflash offset
[in]nnumber of bytes to be programmed
[in]pppointer to the data buffer
Returns
An error code.
Return values
FLASH_NO_ERRORif there is no erase operation in progress.
FLASH_BUSY_ERASINGif there is an erase operation in progress.
FLASH_ERROR_PROGRAMif the program operation failed.
FLASH_ERROR_HW_FAILUREif access to the memory failed.
Function Class:
Not an API, this function is for internal use only.

Definition at line 202 of file hal_efl_lld.c.

◆ efl_lld_start_erase_all()

flash_error_t efl_lld_start_erase_all ( void *  instance)

Starts a whole-device erase operation.

Note
This function only erases bank 2 if it is present. Bank 1 is not touched because it is where the program is running on. Pages on bank 1 can be individually erased.
Parameters
[in]instancepointer to a EFlashDriver instance
Returns
An error code.
Return values
FLASH_NO_ERRORif there is no erase operation in progress.
FLASH_BUSY_ERASINGif there is an erase operation in progress.
FLASH_ERROR_HW_FAILUREif access to the memory failed.
Function Class:
Not an API, this function is for internal use only.

Definition at line 243 of file hal_efl_lld.c.

References osalDbgAssert, and osalDbgCheck.

◆ efl_lld_start_erase_sector()

flash_error_t efl_lld_start_erase_sector ( void *  instance,
flash_sector_t  sector 
)

Starts an sector erase operation.

Parameters
[in]instancepointer to a EFlashDriver instance
[in]sectorsector to be erased
Returns
An error code.
Return values
FLASH_NO_ERRORif there is no erase operation in progress.
FLASH_BUSY_ERASINGif there is an erase operation in progress.
FLASH_ERROR_HW_FAILUREif access to the memory failed.
Function Class:
Not an API, this function is for internal use only.

Definition at line 275 of file hal_efl_lld.c.

References osalDbgCheck.

◆ efl_lld_query_erase()

flash_error_t efl_lld_query_erase ( void *  instance,
uint32_t *  msec 
)

Queries the driver for erase operation progress.

Parameters
[in]instancepointer to a EFlashDriver instance
[out]msecrecommended time, in milliseconds, that should be spent before calling this function again, can be NULL
Returns
An error code.
Return values
FLASH_NO_ERRORif there is no erase operation in progress.
FLASH_BUSY_ERASINGif there is an erase operation in progress.
FLASH_ERROR_ERASEif the erase operation failed.
FLASH_ERROR_HW_FAILUREif access to the memory failed.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 312 of file hal_efl_lld.c.

◆ efl_lld_verify_erase()

flash_error_t efl_lld_verify_erase ( void *  instance,
flash_sector_t  sector 
)

Returns the erase state of a sector.

Parameters
[in]instancepointer to a EFlashDriver instance
[in]sectorsector to be verified
Returns
An error code.
Return values
FLASH_NO_ERRORif the sector is erased.
FLASH_BUSY_ERASINGif there is an erase operation in progress.
FLASH_ERROR_VERIFYif the verify operation failed.
FLASH_ERROR_HW_FAILUREif access to the memory failed.
Function Class:
Not an API, this function is for internal use only.

Definition at line 341 of file hal_efl_lld.c.

Variable Documentation

◆ EFLD1

EFlashDriver EFLD1

EFL1 driver identifier.

Definition at line 41 of file hal_efl_lld.c.

Referenced by efl_lld_init().

hal_efl_config
Type of a structure representing a flash driver configuration.
Definition: hal_efl.h:87
_base_flash_data
#define _base_flash_data
BaseFlash specific data.
Definition: hal_flash.h:211