Microchip® Advanced Software Framework

sam_nvm.c File Reference

Non volatile memories management for SAM devices.

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

#include "nvm.h"
#include "common_nvm.h"
#include "conf_board.h"
#include "system_interrupt.h"
#include "string.h"

Macros

#define NVM_MEMORY   ((volatile uint16_t *)FLASH_ADDR)
 

Functions

status_code_t nvm_init (mem_type_t mem)
 Initialize the non volatile memory specified. More...
 
static enum status_code nvm_memcpy (const uint32_t destination_address, uint8_t *const buffer, uint16_t length, bool erase_flag)
 
status_code_t nvm_read (mem_type_t mem, uint32_t address, void *buffer, uint32_t len)
 Read len number of bytes from address address in non volatile memory mem and store it in the buffer buffer. More...
 
static status_code_t nvm_sam0_read (mem_type_t mem, uint32_t address, uint8_t *const buffer, uint32_t len)
 
status_code_t nvm_write (mem_type_t mem, uint32_t address, void *buffer, uint32_t len)
 Write len number of bytes at address address in non volatile memory mem from the buffer buffer. More...
 

#define NVM_MEMORY   ((volatile uint16_t *)FLASH_ADDR)

Pointer to the NVM MEMORY region start address

Referenced by nvm_sam0_read().

status_code_t nvm_init ( mem_type_t  mem)

Initialize the non volatile memory specified.

Parameters
memType of non volatile memory to initialize

References ERR_INVALID_ARG, INT_FLASH, nvm_config::manual_page_write, nvm_get_config_defaults(), nvm_set_config(), STATUS_OK, and nvm_config::wait_states.

Referenced by main().

enum status_code nvm_memcpy ( const uint32_t  destination_address,
uint8_t *const  buffer,
uint16_t  length,
bool  erase_flag 
)
static
status_code_t nvm_read ( mem_type_t  mem,
uint32_t  address,
void *  buffer,
uint32_t  len 
)

Read len number of bytes from address address in non volatile memory mem and store it in the buffer buffer.

Parameters
memType of non volatile memory to read
addressAddress to read
bufferPointer to destination buffer
lenNumber of bytes to read

References nvm_sam0_read().

status_code_t nvm_sam0_read ( mem_type_t  mem,
uint32_t  address,
uint8_t *const  buffer,
uint32_t  len 
)
static
status_code_t nvm_write ( mem_type_t  mem,
uint32_t  address,
void *  buffer,
uint32_t  len 
)

Write len number of bytes at address address in non volatile memory mem from the buffer buffer.

Parameters
memType of non volatile memory to write
addressAddress to write
bufferPointer to source buffer
lenNumber of bytes to write

References ERR_INVALID_ARG, INT_FLASH, nvm_memcpy(), and STATUS_OK.