Microchip® Advanced Software Framework

flashcalw_example1.c File Reference

FLASHCALW example1 for SAM.

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

#include <asf.h>

Data Structures

struct  nvram_data_t
 

Macros

#define NVRAM_PAGE_ADDRESS   (FLASH_ADDR + FLASH_SIZE - FLASH_PAGE_SIZE)
 
#define NVRAM_PAGE_NUMBER   (NVRAM_PAGE_ADDRESS/FLASH_PAGE_SIZE)
 
#define USER_PAGE_ADDRESS   (FLASH_USER_PAGE_ADDR + 8)
 

Functions

static void configure_console (void)
 Configure serial console. More...
 
static void flash_protect_example (void)
 This is an example demonstrating the flash lock bits feature. More...
 
static void flash_rw_example (const char *caption, nvram_data_t *nvram_data)
 This is an example demonstrating flash read / write data accesses using the FLASHCALW driver. More...
 
int main (void)
 main function : perform several read/write accesses to the flash then lock and unlock a page in the flash. More...
 
static void print_nvram_variables (nvram_data_t *nvram_data)
 Prints the variables stored in NVRAM. More...
 

#define NVRAM_PAGE_ADDRESS   (FLASH_ADDR + FLASH_SIZE - FLASH_PAGE_SIZE)

Referenced by flash_protect_example(), and main().

#define NVRAM_PAGE_NUMBER   (NVRAM_PAGE_ADDRESS/FLASH_PAGE_SIZE)

Referenced by flash_protect_example().

#define USER_PAGE_ADDRESS   (FLASH_USER_PAGE_ADDR + 8)

Referenced by main().

static void configure_console ( void  )
static
static void flash_protect_example ( void  )
static

This is an example demonstrating the flash lock bits feature.

References FLASH_PAGE_SIZE, flashcalw_is_lock_error(), flashcalw_lock_page_region(), flashcalw_memset, NVRAM_PAGE_ADDRESS, and NVRAM_PAGE_NUMBER.

Referenced by main().

static void flash_rw_example ( const char *  caption,
nvram_data_t nvram_data 
)
static

This is an example demonstrating flash read / write data accesses using the FLASHCALW driver.

Parameters
captionCaption to print before running the example.
nvram_dataPointer to the NVRAM data structure to use in the example.

References flashcalw_memcpy(), flashcalw_memset, print_nvram_variables(), nvram_data_t::var16, nvram_data_t::var32, nvram_data_t::var8, and nvram_data_t::var8_3.

Referenced by main().

int main ( void  )

main function : perform several read/write accesses to the flash then lock and unlock a page in the flash.

References board_init(), BOARD_NAME, CONF_UART, configure_console(), flash_protect_example(), flash_rw_example(), flashcalw_set_security_bit(), NVRAM_PAGE_ADDRESS, sysclk_init(), usart_read(), and USER_PAGE_ADDRESS.

static void print_nvram_variables ( nvram_data_t nvram_data)
static

Prints the variables stored in NVRAM.

Parameters
nvram_dataPointer to the NVRAM data structure to print.

References nvram_data_t::var16, nvram_data_t::var32, nvram_data_t::var8, and nvram_data_t::var8_3.

Referenced by flash_rw_example().