Microchip® Advanced Software Framework

efc.h File Reference

Embedded Flash Controller (EFC) driver for SAM.

Copyright (c) 2011-2019 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"

Macros

#define CHIP_FLASH_IAP_ADDRESS   (IROM_ADDR + 8)
 
EFC command
#define EFC_FCMD_GETD   0x00
 Get Flash Descriptor. More...
 
#define EFC_FCMD_WP   0x01
 Write page. More...
 
#define EFC_FCMD_WPL   0x02
 Write page and lock. More...
 
#define EFC_FCMD_EWP   0x03
 Erase page and write page. More...
 
#define EFC_FCMD_EWPL   0x04
 Erase page and write page then lock. More...
 
#define EFC_FCMD_EA   0x05
 Erase all. More...
 
#define EFC_FCMD_EPL   0x06
 Erase plane. More...
 
#define EFC_FCMD_EPA   0x07
 Erase pages. More...
 
#define EFC_FCMD_SLB   0x08
 Set Lock Bit. More...
 
#define EFC_FCMD_CLB   0x09
 Clear Lock Bit. More...
 
#define EFC_FCMD_GLB   0x0A
 Get Lock Bit. More...
 
#define EFC_FCMD_SGPB   0x0B
 Set GPNVM Bit. More...
 
#define EFC_FCMD_CGPB   0x0C
 Clear GPNVM Bit. More...
 
#define EFC_FCMD_GGPB   0x0D
 Get GPNVM Bit. More...
 
#define EFC_FCMD_STUI   0x0E
 Start unique ID. More...
 
#define EFC_FCMD_SPUI   0x0F
 Stop unique ID. More...
 
#define EFC_FCMD_GCALB   0x10
 Get CALIB Bit. More...
 
#define EFC_FCMD_ES   0x11
 Erase sector. More...
 
#define EFC_FCMD_WUS   0x12
 Write user signature. More...
 
#define EFC_FCMD_EUS   0x13
 Erase user signature. More...
 
#define EFC_FCMD_STUS   0x14
 Start read user signature. More...
 
#define EFC_FCMD_SPUS   0x15
 Stop read user signature. More...
 
EFC access mode
#define EFC_ACCESS_MODE_128   0
 
#define EFC_ACCESS_MODE_64   EEFC_FMR_FAM
 

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

EFC return codes

enum  efc_rc {
  EFC_RC_OK = 0,
  EFC_RC_YES = 0,
  EFC_RC_NO = 1,
  EFC_RC_ERROR = 1,
  EFC_RC_INVALID,
  EFC_RC_NOT_SUPPORT = 0xFFFFFFFF
}
 
typedef enum efc_rc efc_rc_t
 

#define CHIP_FLASH_IAP_ADDRESS   (IROM_ADDR + 8)

The IAP function entry address

#define EFC_ACCESS_MODE_128   0
#define EFC_ACCESS_MODE_64   EEFC_FMR_FAM
#define EFC_FCMD_CGPB   0x0C

Clear GPNVM Bit.

#define EFC_FCMD_CLB   0x09

Clear Lock Bit.

#define EFC_FCMD_EA   0x05

Erase all.

#define EFC_FCMD_EPA   0x07

Erase pages.

#define EFC_FCMD_EPL   0x06

Erase plane.

#define EFC_FCMD_ES   0x11

Erase sector.

#define EFC_FCMD_EUS   0x13

Erase user signature.

#define EFC_FCMD_EWP   0x03

Erase page and write page.

#define EFC_FCMD_EWPL   0x04

Erase page and write page then lock.

#define EFC_FCMD_GCALB   0x10

Get CALIB Bit.

#define EFC_FCMD_GETD   0x00

Get Flash Descriptor.

#define EFC_FCMD_GGPB   0x0D

Get GPNVM Bit.

#define EFC_FCMD_GLB   0x0A

Get Lock Bit.

#define EFC_FCMD_SGPB   0x0B

Set GPNVM Bit.

#define EFC_FCMD_SLB   0x08

Set Lock Bit.

#define EFC_FCMD_SPUI   0x0F

Stop unique ID.

Referenced by efc_perform_command().

#define EFC_FCMD_SPUS   0x15

Stop read user signature.

#define EFC_FCMD_STUI   0x0E

Start unique ID.

Referenced by efc_perform_command().

#define EFC_FCMD_STUS   0x14

Start read user signature.

#define EFC_FCMD_WP   0x01

Write page.

#define EFC_FCMD_WPL   0x02

Write page and lock.

#define EFC_FCMD_WUS   0x12

Write user signature.

typedef enum efc_rc efc_rc_t

enum efc_rc
Enumerator
EFC_RC_OK 

Operation OK.

EFC_RC_YES 

Yes.

EFC_RC_NO 

No.

EFC_RC_ERROR 

General error.

EFC_RC_INVALID 

Invalid argument input.

EFC_RC_NOT_SUPPORT 

Operation is not supported.