FlashCALW driver for SAM4L.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | FLASH_FREQ_PS0_FWS_0_MAX_FREQ (18000000UL) |
Maximum operating frequency when FWS is 0 in PS0 mode. More... | |
#define | FLASH_FREQ_PS0_FWS_1_MAX_FREQ (36000000UL) |
Maximum operating frequency when FWS is 1 in PS0 mode. More... | |
#define | FLASH_FREQ_PS1_FWS_0_MAX_FREQ (8000000UL) |
Maximum operating frequency when FWS is 0 in PS1 mode. More... | |
#define | FLASH_FREQ_PS1_FWS_1_FWU_MAX_FREQ (12000000UL) |
Maximum operating frequency when FWS is 1 in PS0 mode and the Fast wakeup is enabled. More... | |
#define | FLASH_FREQ_PS1_FWS_1_MAX_FREQ (12000000UL) |
Maximum operating frequency when FWS is 1 in PS1 mode. More... | |
#define | FLASH_FREQ_PS2_FWS_0_MAX_FREQ (24000000UL) |
Maximum operating frequency when FWS is 0 in PS2 mode. More... | |
#define | FLASH_FREQ_PS2_FWS_1_MAX_FREQ (48000000UL) |
Maximum operating frequency when FWS is 1 in PS2 mode. More... | |
#define | FLASH_NB_OF_REGIONS 16 |
#define | FLASH_PAGE_SIZE 512UL |
#define | FLASHCALW_REGIONS FLASH_NB_OF_REGIONS |
Functions | |
Flash Properties | |
uint32_t | flashcalw_get_flash_size (void) |
Gets the size of the whole flash array. More... | |
uint32_t | flashcalw_get_page_count (void) |
Gets the total number of pages in the flash array. More... | |
uint32_t | flashcalw_get_page_count_per_region (void) |
Gets the number of pages in each flash region. More... | |
uint32_t | flashcalw_get_page_region (int32_t page_number) |
Gets the region number of a page. More... | |
uint32_t | flashcalw_get_region_first_page_number (uint32_t region) |
Gets the number of the first page of a region. More... | |
FLASHCALW Command Control | |
uint32_t | flashcalw_get_command (void) |
Gets the last issued FLASHCALW command. More... | |
uint32_t | flashcalw_get_page_number (void) |
Gets the current FLASHCALW page number. More... | |
void | flashcalw_issue_command (uint32_t command, int page_number) |
Issues a FLASHCALW command. More... | |
FLASHCALW Global Commands | |
void | flashcalw_no_operation (void) |
Issues a No Operation command to the FLASHCALW. More... | |
void | flashcalw_erase_all (void) |
Issues an Erase All command to the FLASHCALW. More... | |
FLASHCALW Protection Mechanisms | |
bool | flashcalw_is_security_bit_active (void) |
Tells whether the Security bit is active. More... | |
void | flashcalw_set_security_bit (void) |
Activates the Security bit. More... | |
bool | flashcalw_is_page_region_locked (uint32_t page_number) |
Tells whether the region of a page is locked. More... | |
bool | flashcalw_is_region_locked (uint32_t region) |
Tells whether a region is locked. More... | |
void | flashcalw_lock_page_region (int page_number, bool lock) |
Locks or unlocks the region of a page. More... | |
void | flashcalw_lock_region (uint32_t region, bool lock) |
Locks or unlocks a region. More... | |
void | flashcalw_lock_all_regions (bool lock) |
Locks or unlocks all regions. More... | |
Access to General-Purpose Fuses | |
bool | flashcalw_read_gp_fuse_bit (uint32_t gp_fuse_bit) |
Reads a general-purpose fuse bit. More... | |
uint64_t | flashcalw_read_gp_fuse_bitfield (uint32_t pos, uint32_t width) |
Reads a general-purpose fuse bit-field. More... | |
uint8_t | flashcalw_read_gp_fuse_byte (uint32_t gp_fuse_byte) |
Reads a general-purpose fuse byte. More... | |
uint64_t | flashcalw_read_all_gp_fuses (void) |
Reads all general-purpose fuses. More... | |
bool | flashcalw_erase_gp_fuse_bit (uint32_t gp_fuse_bit, bool check) |
Erases a general-purpose fuse bit. More... | |
bool | flashcalw_erase_gp_fuse_bitfield (uint32_t pos, uint32_t width, bool check) |
Erases a general-purpose fuse bit-field. More... | |
bool | flashcalw_erase_gp_fuse_byte (uint32_t gp_fuse_byte, bool check) |
Erases a general-purpose fuse byte. More... | |
bool | flashcalw_erase_all_gp_fuses (bool check) |
Erases all general-purpose fuses. More... | |
void | flashcalw_write_gp_fuse_bit (uint32_t gp_fuse_bit, bool value) |
Writes a general-purpose fuse bit. More... | |
void | flashcalw_write_gp_fuse_bitfield (uint32_t pos, uint32_t width, uint64_t value) |
Writes a general-purpose fuse bit-field. More... | |
void | flashcalw_write_gp_fuse_byte (uint32_t gp_fuse_byte, uint8_t value) |
Writes a general-purpose fuse byte. More... | |
void | flashcalw_write_all_gp_fuses (uint64_t value) |
Writes all general-purpose fuses. More... | |
void | flashcalw_set_gp_fuse_bit (uint32_t gp_fuse_bit, bool value) |
Sets a general-purpose fuse bit with the appropriate erase and write operations. More... | |
void | flashcalw_set_gp_fuse_bitfield (uint32_t pos, uint32_t width, uint64_t value) |
Sets a general-purpose fuse bit-field with the appropriate erase and write operations. More... | |
void | flashcalw_set_gp_fuse_byte (uint32_t gp_fuse_byte, uint8_t value) |
Sets a general-purpose fuse byte with the appropriate erase and write operations. More... | |
void | flashcalw_set_all_gp_fuses (uint64_t value) |
Sets all general-purpose fuses with the appropriate erase and write operations. More... | |
PicoCache interfaces. | |
void | flashcalw_picocache_enable (void) |
Enable PicoCache. More... | |
void | flashcalw_picocache_disable (void) |
Disable PicoCache. More... | |
uint32_t | flashcalw_picocache_get_status (void) |
Get PicoCache status. More... | |
void | flashcalw_picocache_invalid_all (void) |
Invalid all PicoCache lines. More... | |
void | flashcalw_picocache_invalid_line (uint32_t index) |
Invalid specific cache line. More... | |
void | flashcalw_picocache_set_monitor_mode (uint32_t mode) |
Set PicoCache monitor mode. More... | |
void | flashcalw_picocache_enable_monitor (void) |
Enable PicoCache monitor. More... | |
void | flashcalw_picocache_disable_monitor (void) |
Disable PicoCache monitor. More... | |
void | flashcalw_picocache_reset_monitor (void) |
Reset PicoCache monitor. More... | |
uint32_t | flashcalw_picocache_get_monitor_cnt (void) |
Get PicoCache monitor count number. More... | |
uint32_t | flashcalw_picocache_get_version (void) |
Get PicoCache version. More... | |
FLASHCALW Control | |
#define | flash_set_bus_freq(cpu_f_hz, ps_value, is_fwu_enabled) flashcalw_set_flash_waitstate_and_readmode(cpu_f_hz, ps_value, is_fwu_enabled) |
Alias on the flashcalw_set_flash_waitstate_and_readmode() function. More... | |
uint32_t | flashcalw_get_wait_state (void) |
Gets the number of wait states of flash read accesses. More... | |
void | flashcalw_set_wait_state (uint32_t wait_state) |
Sets the number of wait states of flash read accesses. More... | |
void | flashcalw_set_flash_waitstate_and_readmode (uint32_t cpu_f_hz, uint32_t ps_value, bool is_fwu_enabled) |
Depending on the CPU frequency, on the Power Scaling mode and on the Fast Wakeup mode, set the wait states of flash read accesses and enable or disable the High speed read mode. More... | |
bool | flashcalw_is_ready_int_enabled (void) |
Tells whether the Flash Ready interrupt is enabled. More... | |
void | flashcalw_enable_ready_int (bool enable) |
Enables or disables the Flash Ready interrupt. More... | |
bool | flashcalw_is_lock_error_int_enabled (void) |
Tells whether the Lock Error interrupt is enabled. More... | |
void | flashcalw_enable_lock_error_int (bool enable) |
Enables or disables the Lock Error interrupt. More... | |
bool | flashcalw_is_prog_error_int_enabled (void) |
Tells whether the Programming Error interrupt is enabled. More... | |
void | flashcalw_enable_prog_error_int (bool enable) |
Enables or disables the Programming Error interrupt. More... | |
FLASHCALW Status | |
void(*volatile | flashcalw_wait_until_ready )(void) |
Pointer to the function used by the driver when it needs to wait until the FLASHCALW is ready to run a new command. More... | |
bool | flashcalw_is_ready (void) |
Tells whether the FLASHCALW is ready to run a new command. More... | |
void | flashcalw_default_wait_until_ready (void) |
Waits actively until the FLASHCALW is ready to run a new command. More... | |
bool | flashcalw_is_lock_error (void) |
Tells whether a Lock Error has occurred during the last function called that issued one or more FLASHCALW commands. More... | |
bool | flashcalw_is_programming_error (void) |
Tells whether a Programming Error has occurred during the last function called that issued one or more FLASHCALW commands. More... | |
Access to Flash Pages | |
#define | flashcalw_memset(dst, src, src_width, nbytes, erase) TPASTE2(flashcalw_memset, src_width) ((dst), (src), (nbytes), (erase)) |
Copies nbytes bytes to the flash destination pointed to by dst from the repeated src big-endian source pattern. More... | |
void | flashcalw_clear_page_buffer (void) |
Clears the page buffer. More... | |
bool | flashcalw_is_page_erased (void) |
Tells whether the page to which the last Quick Page Read or Quick Page Read User Page command was applied was erased. More... | |
bool | flashcalw_quick_page_read (int page_number) |
Applies the Quick Page Read command to a page. More... | |
bool | flashcalw_erase_page (int page_number, bool check) |
Erases a page. More... | |
bool | flashcalw_erase_all_pages (bool check) |
Erases all pages within the flash array. More... | |
void | flashcalw_write_page (int page_number) |
Writes a page from the page buffer. More... | |
bool | flashcalw_quick_user_page_read (void) |
Issues a Quick Page Read User Page command to the FLASHCALW. More... | |
bool | flashcalw_erase_user_page (bool check) |
Erases the User page. More... | |
void | flashcalw_write_user_page (void) |
Writes the User page from the page buffer. More... | |
volatile void * | flashcalw_memset8 (volatile void *dst, uint8_t src, size_t nbytes, bool erase) |
Copies nbytes bytes to the flash destination pointed to by dst from the repeated src source byte. More... | |
volatile void * | flashcalw_memset16 (volatile void *dst, uint16_t src, size_t nbytes, bool erase) |
Copies nbytes bytes to the flash destination pointed to by dst from the repeated src big-endian source half-word. More... | |
volatile void * | flashcalw_memset32 (volatile void *dst, uint32_t src, size_t nbytes, bool erase) |
Copies nbytes bytes to the flash destination pointed to by dst from the repeated src big-endian source word. More... | |
volatile void * | flashcalw_memset64 (volatile void *dst, uint64_t src, size_t nbytes, bool erase) |
Copies nbytes bytes to the flash destination pointed to by dst from the repeated src big-endian source double-word. More... | |
volatile void * | flashcalw_memcpy (volatile void *dst, const void *src, size_t nbytes, bool erase) |
Copies nbytes bytes to the flash destination pointed to by dst from the source pointed to by src. More... | |
#define FLASH_FREQ_PS0_FWS_0_MAX_FREQ (18000000UL) |
Maximum operating frequency when FWS is 0 in PS0 mode.
Referenced by flashcalw_set_flash_waitstate_and_readmode().
#define FLASH_FREQ_PS0_FWS_1_MAX_FREQ (36000000UL) |
Maximum operating frequency when FWS is 1 in PS0 mode.
Referenced by flashcalw_set_flash_waitstate_and_readmode().
#define FLASH_FREQ_PS1_FWS_0_MAX_FREQ (8000000UL) |
Maximum operating frequency when FWS is 0 in PS1 mode.
Referenced by flashcalw_set_flash_waitstate_and_readmode(), and sysclk_init().
#define FLASH_FREQ_PS1_FWS_1_FWU_MAX_FREQ (12000000UL) |
Maximum operating frequency when FWS is 1 in PS0 mode and the Fast wakeup is enabled.
Referenced by flashcalw_set_flash_waitstate_and_readmode().
#define FLASH_FREQ_PS1_FWS_1_MAX_FREQ (12000000UL) |
Maximum operating frequency when FWS is 1 in PS1 mode.
Referenced by sysclk_init().
#define FLASH_FREQ_PS2_FWS_0_MAX_FREQ (24000000UL) |
Maximum operating frequency when FWS is 0 in PS2 mode.
Referenced by flashcalw_set_flash_waitstate_and_readmode().
#define FLASH_FREQ_PS2_FWS_1_MAX_FREQ (48000000UL) |
Maximum operating frequency when FWS is 1 in PS2 mode.
#define FLASH_NB_OF_REGIONS 16 |
Referenced by flashcalw_get_page_count_per_region(), and run_flashcalw_protection_test().
#define FLASH_PAGE_SIZE 512UL |
#define flash_set_bus_freq | ( | cpu_f_hz, | |
ps_value, | |||
is_fwu_enabled | |||
) | flashcalw_set_flash_waitstate_and_readmode(cpu_f_hz, ps_value, is_fwu_enabled) |
Alias on the flashcalw_set_flash_waitstate_and_readmode() function.
cpu_f_hz | The CPU frequency |
ps_value | (boolean), Power Scaling mode |
is_fwu_enabled | (boolean), Fast wakeup mode |
Referenced by sysclk_init().
#define flashcalw_memset | ( | dst, | |
src, | |||
src_width, | |||
nbytes, | |||
erase | |||
) | TPASTE2(flashcalw_memset, src_width) ((dst), (src), (nbytes), (erase)) |
Copies nbytes bytes to the flash destination pointed to by dst from the repeated src big-endian source pattern.
All pointer and size alignments are supported.
dst | Pointer to flash destination. |
src | Source double-word. |
src_width | src width in bits: 8, 16, 32 or 64. |
nbytes | Number of bytes to set. |
erase | Whether to erase before writing: true or false . |
false
only if the destination consists only of erased words, i.e. this function can not be used to write only one bit of a previously written word. E.g., if 0x00000001
then 0xFFFFFFFE
are written to a word, the resulting value in flash may be different from 0x00000000
.Referenced by flash_protect_example(), flash_rw_example(), and run_flashcalw_page_access_test().
#define FLASHCALW_REGIONS FLASH_NB_OF_REGIONS |
Referenced by flashcalw_is_region_locked(), and flashcalw_lock_all_regions().