Microchip® Advanced Software Framework

flash_efc.c File Reference

Embedded Flash service for SAM.

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

#include <string.h>
#include <assert.h>
#include "flash_efc.h"
#include "sysclk.h"

Macros

#define GPNVM_NUM_MAX   2
 

Functions

static void compute_address (Efc *p_efc, uint16_t us_page, uint16_t us_offset, uint32_t *pul_addr)
 Compute the address of a flash by the given page and offset. More...
 
static void compute_lock_range (uint32_t ul_start, uint32_t ul_end, uint32_t *pul_actual_start, uint32_t *pul_actual_end)
 Compute the lock range associated with the given address range. More...
 
uint32_t flash_clear_gpnvm (uint32_t ul_gpnvm)
 Clear the given GPNVM bit. More...
 
uint32_t flash_enable_security_bit (void)
 Set security bit. More...
 
uint32_t flash_erase_all (uint32_t ul_address)
 Erase the entire flash. More...
 
uint32_t flash_get_descriptor (uint32_t ul_address, uint32_t *pul_flash_descriptor, uint32_t ul_size)
 Get flash descriptor. More...
 
uint32_t flash_get_page_count (const uint32_t *pul_flash_descriptor)
 Get flash total page count for the specified bank. More...
 
uint32_t flash_get_page_count_per_region (const uint32_t *pul_flash_descriptor)
 Get flash page count per region (plane) for the specified bank. More...
 
uint32_t flash_get_region_count (const uint32_t *pul_flash_descriptor)
 Get flash region (plane) count for the specified bank. More...
 
uint32_t flash_get_wait_state (uint32_t ul_address)
 Get flash wait state. More...
 
uint32_t flash_init (uint32_t ul_mode, uint32_t ul_fws)
 Initialize the flash service. More...
 
uint32_t flash_is_gpnvm_set (uint32_t ul_gpnvm)
 Check if the given GPNVM bit is set or not. More...
 
uint32_t flash_is_locked (uint32_t ul_start, uint32_t ul_end)
 Get the number of locked regions inside the given address range. More...
 
uint32_t flash_is_security_bit_enabled (void)
 Check if the security bit is set or not. More...
 
uint32_t flash_lock (uint32_t ul_start, uint32_t ul_end, uint32_t *pul_actual_start, uint32_t *pul_actual_end)
 Lock all the regions in the given address range. More...
 
uint32_t flash_read_unique_id (uint32_t *pul_data, uint32_t ul_size)
 Read the flash unique ID. More...
 
uint32_t flash_set_gpnvm (uint32_t ul_gpnvm)
 Set the given GPNVM bit. More...
 
uint32_t flash_set_wait_state (uint32_t ul_address, uint32_t ul_fws)
 Set flash wait state. More...
 
uint32_t flash_set_wait_state_adaptively (uint32_t ul_address)
 Set flash wait state. More...
 
uint32_t flash_unlock (uint32_t ul_start, uint32_t ul_end, uint32_t *pul_actual_start, uint32_t *pul_actual_end)
 Unlock all the regions in the given address range. More...
 
uint32_t flash_write (uint32_t ul_address, const void *p_buffer, uint32_t ul_size, uint32_t ul_erase_flag)
 Write a data buffer on flash. More...
 
static void translate_address (Efc **pp_efc, uint32_t ul_addr, uint16_t *pus_page, uint16_t *pus_offset)
 Translate the given flash address to page and offset values. More...
 

Variables

static uint32_t gs_ul_page_buffer [IFLASH_PAGE_SIZE/sizeof(uint32_t)]