Microchip® Advanced Software Framework

nvm.c File Reference

SAM Non Volatile Memory driver.

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

#include "nvm.h"
#include <system.h>
#include <system_interrupt.h>
#include <string.h>

Data Structures

struct  _nvm_module
 

Macros

#define FUSES_BOD12_ACTION_Msk   (0x3ul << FUSES_BOD12_ACTION_Pos)
 
#define FUSES_BOD12_ACTION_Pos   24
 
#define FUSES_BOD12_DIS_Msk   (0x1ul << FUSES_BOD12_DIS_Pos)
 
#define FUSES_BOD12_DIS_Pos   23
 
#define FUSES_BOD12USERLEVEL_Msk   (0x3Ful << FUSES_BOD12USERLEVEL_Pos)
 
#define FUSES_BOD12USERLEVEL_Pos   17
 
#define NVM_MEMORY   ((volatile uint16_t *)FLASH_ADDR)
 
#define NVM_USER_MEMORY   ((volatile uint16_t *)NVMCTRL_USER)
 

Functions

enum status_code nvm_erase_row (const uint32_t row_address)
 Erases a row in the NVM memory space. More...
 
enum status_code nvm_execute_command (const enum nvm_command command, const uint32_t address, const uint32_t parameter)
 Executes a command on the NVM controller. More...
 
enum status_code nvm_get_fuses (struct nvm_fusebits *fusebits)
 Get fuses from user row. More...
 
void nvm_get_parameters (struct nvm_parameters *const parameters)
 Reads the parameters of the NVM controller. More...
 
bool nvm_is_page_locked (uint16_t page_number)
 Checks whether the page region is locked. More...
 
enum status_code nvm_read_buffer (const uint32_t source_address, uint8_t *const buffer, uint16_t length)
 Reads a number of bytes from a page in the NVM memory region. More...
 
enum status_code nvm_set_config (const struct nvm_config *const config)
 Sets the up the NVM hardware module based on the configuration. More...
 
enum status_code nvm_set_fuses (struct nvm_fusebits *fb)
 Set fuses from user row. More...
 
enum status_code nvm_update_buffer (const uint32_t destination_address, uint8_t *const buffer, uint16_t offset, uint16_t length)
 Updates an arbitrary section of a page with new data. More...
 
enum status_code nvm_write_buffer (const uint32_t destination_address, const uint8_t *buffer, uint16_t length)
 Writes a number of bytes to a page in the NVM memory region. More...
 

Variables

static struct _nvm_module _nvm_dev
 

#define FUSES_BOD12_ACTION_Msk   (0x3ul << FUSES_BOD12_ACTION_Pos)
#define FUSES_BOD12_ACTION_Pos   24

Referenced by nvm_set_fuses().

#define FUSES_BOD12_DIS_Msk   (0x1ul << FUSES_BOD12_DIS_Pos)
#define FUSES_BOD12_DIS_Pos   23

Referenced by nvm_set_fuses().

#define FUSES_BOD12USERLEVEL_Msk   (0x3Ful << FUSES_BOD12USERLEVEL_Pos)
#define FUSES_BOD12USERLEVEL_Pos   17

Referenced by nvm_set_fuses().

#define NVM_MEMORY   ((volatile uint16_t *)FLASH_ADDR)

Pointer to the NVM MEMORY region start address

Referenced by nvm_erase_row(), nvm_execute_command(), nvm_get_fuses(), nvm_read_buffer(), nvm_write_buffer(), and pds_nvm_read().

#define NVM_USER_MEMORY   ((volatile uint16_t *)NVMCTRL_USER)

Pointer to the NVM USER MEMORY region start address

Referenced by nvm_get_parameters().

struct _nvm_module _nvm_dev
static