Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Enhanced Embedded Flash Controller (EEFC)

The Enhanced Embedded Flash Controller ensures the interface of the Flash block with the 32-bit internal bus.

Macros

#define EEFC_ERROR_FLAGS   (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE | EEFC_FSR_FLERR)
 
#define EEFC_FCR_FCMD(value)   ((EEFC_FCR_FCMD_Msk & ((value) << EEFC_FCR_FCMD_Pos)))
 
#define EEFC_FCR_FKEY_PASSWD   EEFC_FCR_FKEY(FWP_KEY)
 
#define FWP_KEY   0x5Au
 
#define READ_BUFF_ADDR0   IFLASH0_ADDR
 
#define READ_BUFF_ADDR1   IFLASH1_ADDR
 

Functions

void efc_disable_cloe (Efc *p_efc)
 Disable code loop optimization. More...
 
void efc_disable_frdy_interrupt (Efc *p_efc)
 Disable the flash ready interrupt. More...
 
void efc_disable_write_protection (Efc *p_efc)
 Disable the write protection. More...
 
void efc_enable_cloe (Efc *p_efc)
 Enable code loop optimization. More...
 
void efc_enable_frdy_interrupt (Efc *p_efc)
 Enable the flash ready interrupt. More...
 
void efc_enable_write_protection (Efc *p_efc)
 Enable the write protection. More...
 
uint32_t efc_get_result (Efc *p_efc)
 Get the result of the last executed command. More...
 
uint32_t efc_get_status (Efc *p_efc)
 Get the current status of the EEFC. More...
 
uint32_t efc_get_wait_state (Efc *p_efc)
 Get flash wait state. More...
 
uint32_t efc_init (Efc *p_efc, uint32_t ul_access_mode, uint32_t ul_fws)
 Initialize the EFC controller. More...
 
uint32_t efc_perform_command (Efc *p_efc, uint32_t ul_command, uint32_t ul_argument)
 Perform the given command and wait until its completion (or an error). More...
 
uint32_t efc_perform_fcr (Efc *p_efc, uint32_t ul_fcr)
 Perform command. More...
 
__no_inline RAMFUNC uint32_t efc_perform_read_sequence (Efc *p_efc, uint32_t ul_cmd_st, uint32_t ul_cmd_sp, uint32_t *p_ul_buf, uint32_t ul_size)
 Perform read sequence. More...
 
void efc_set_wait_state (Efc *p_efc, uint32_t ul_fws)
 Set flash wait state. More...
 
void efc_write_fmr (Efc *p_efc, uint32_t ul_fmr)
 Set mode register. More...
 

#define EEFC_ERROR_FLAGS   (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE | EEFC_FSR_FLERR)

Referenced by efc_perform_fcr().

#define EEFC_FCR_FCMD (   value)    ((EEFC_FCR_FCMD_Msk & ((value) << EEFC_FCR_FCMD_Pos)))
#define EEFC_FCR_FKEY_PASSWD   EEFC_FCR_FKEY(FWP_KEY)
#define FWP_KEY   0x5Au
#define READ_BUFF_ADDR0   IFLASH0_ADDR
#define READ_BUFF_ADDR1   IFLASH1_ADDR

void efc_disable_cloe ( Efc *  p_efc)

Disable code loop optimization.

Parameters
p_efcPointer to an EFC instance.

References efc_write_fmr().

void efc_disable_frdy_interrupt ( Efc *  p_efc)

Disable the flash ready interrupt.

Parameters
p_efcPointer to an EFC instance.

References efc_write_fmr().

void efc_disable_write_protection ( Efc *  p_efc)

Disable the write protection.

Parameters
p_efcPointer to an EFC instance.
void efc_enable_cloe ( Efc *  p_efc)

Enable code loop optimization.

Parameters
p_efcPointer to an EFC instance.

References efc_write_fmr().

void efc_enable_frdy_interrupt ( Efc *  p_efc)

Enable the flash ready interrupt.

Parameters
p_efcPointer to an EFC instance.

References efc_write_fmr().

void efc_enable_write_protection ( Efc *  p_efc)

Enable the write protection.

Parameters
p_efcPointer to an EFC instance.
uint32_t efc_get_result ( Efc *  p_efc)

Get the result of the last executed command.

Parameters
p_efcPointer to an EFC instance.
Returns
The result of the last executed command.
uint32_t efc_get_status ( Efc *  p_efc)

Get the current status of the EEFC.

Note
This function clears the value of some status bits (FLOCKE, FCMDE).
Parameters
p_efcPointer to an EFC instance.
Returns
The current status.
uint32_t efc_get_wait_state ( Efc *  p_efc)

Get flash wait state.

Parameters
p_efcPointer to an EFC instance.
Returns
The number of wait states in cycle (no shift).
uint32_t efc_init ( Efc *  p_efc,
uint32_t  ul_access_mode,
uint32_t  ul_fws 
)

Initialize the EFC controller.

Parameters
ul_access_mode0 for 128-bit, EEFC_FMR_FAM for 64-bit.
ul_fwsThe number of wait states in cycle (no shift).
Returns
0 if successful.

References EFC_RC_OK, and efc_write_fmr().

uint32_t efc_perform_command ( Efc *  p_efc,
uint32_t  ul_command,
uint32_t  ul_argument 
)

Perform the given command and wait until its completion (or an error).

Note
Unique ID commands are not supported, use efc_perform_read_sequence.
Parameters
p_efcPointer to an EFC instance.
ul_commandCommand to perform.
ul_argumentOptional command argument.
Note
This function will automatically choose to use IAP function.
Returns
0 if successful, otherwise returns an error code.

References cpu_irq_restore(), cpu_irq_save(), EEFC_FCR_FCMD, EEFC_FCR_FKEY_PASSWD, EFC_FCMD_SPUI, EFC_FCMD_STUI, efc_perform_fcr(), and EFC_RC_NOT_SUPPORT.

__no_inline RAMFUNC uint32_t efc_perform_fcr ( Efc *  p_efc,
uint32_t  ul_fcr 
)

Perform command.

Parameters
p_efcPointer to an EFC instance.
ul_fcrFlash command.
Returns
The current status.

References EEFC_ERROR_FLAGS.

Referenced by efc_perform_command().

__no_inline RAMFUNC uint32_t efc_perform_read_sequence ( Efc *  p_efc,
uint32_t  ul_cmd_st,
uint32_t  ul_cmd_sp,
uint32_t *  p_ul_buf,
uint32_t  ul_size 
)

Perform read sequence.

Supported sequences are read Unique ID and read User Signature

Parameters
p_efcPointer to an EFC instance.
ul_cmd_stStart command to perform.
ul_cmd_spStop command to perform.
p_ul_bufPointer to an data buffer.
ul_sizeBuffer size.
Returns
0 if successful, otherwise returns an error code.

References EEFC_FCR_FCMD, EEFC_FCR_FKEY_PASSWD, EFC_RC_INVALID, EFC_RC_NOT_SUPPORT, EFC_RC_OK, FWP_KEY, READ_BUFF_ADDR0, and READ_BUFF_ADDR1.

void efc_set_wait_state ( Efc *  p_efc,
uint32_t  ul_fws 
)

Set flash wait state.

Parameters
p_efcPointer to an EFC instance.
ul_fwsThe number of wait states in cycle (no shift).

References efc_write_fmr().

__no_inline RAMFUNC void efc_write_fmr ( Efc *  p_efc,
uint32_t  ul_fmr 
)

Set mode register.

Parameters
p_efcPointer to an EFC instance.
ul_fmrValue of mode register

Referenced by efc_disable_cloe(), efc_disable_frdy_interrupt(), efc_enable_cloe(), efc_enable_frdy_interrupt(), efc_init(), and efc_set_wait_state().