Microchip® Advanced Software Framework

common_nvm.h File Reference

Non volatile memories management.

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

#include "compiler.h"
#include "conf_board.h"
#include "parts.h"
#include "status_codes.h"

Macros

#define IFLASH_ADDR   IFLASH0_ADDR
 
#define IFLASH_PAGE_SIZE   IFLASH0_PAGE_SIZE
 

Enumerations

enum  mem_type_t { INT_FLASH }
 

Functions

status_code_t nvm_get_page_size (mem_type_t mem, uint32_t *size)
 Get the size of a page in the non volatile memory specified. More...
 
status_code_t nvm_get_pagenumber (mem_type_t mem, uint32_t address, uint32_t *num)
 Get the page number from the byte address address. More...
 
status_code_t nvm_get_size (mem_type_t mem, uint32_t *size)
 Get the size of whole non volatile memory specified. More...
 
status_code_t nvm_init (mem_type_t mem)
 Initialize the non volatile memory specified. More...
 
status_code_t nvm_page_erase (mem_type_t mem, uint32_t page_number)
 Erase a page in the non volatile memory. More...
 
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...
 
status_code_t nvm_read_char (mem_type_t mem, uint32_t address, uint8_t *data)
 Read single byte of data. More...
 
status_code_t nvm_set_security_bit (void)
 Enable security bit which blocks external read and write access to the device. More...
 
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...
 
status_code_t nvm_write_char (mem_type_t mem, uint32_t address, uint8_t data)
 Write single byte of data. More...
 

#define IFLASH_ADDR   IFLASH0_ADDR

Referenced by nvm_read(), and nvm_read_char().

#define IFLASH_PAGE_SIZE   IFLASH0_PAGE_SIZE

enum mem_type_t
Enumerator
INT_FLASH 

status_code_t nvm_get_page_size ( mem_type_t  mem,
uint32_t *  size 
)

Get the size of a page in the non volatile memory specified.

Parameters
memType of non volatile memory
sizePointer to where to store the size

References ERR_INVALID_ARG, IFLASH_PAGE_SIZE, INT_FLASH, and STATUS_OK.

status_code_t nvm_get_pagenumber ( mem_type_t  mem,
uint32_t  address,
uint32_t *  num 
)

Get the page number from the byte address address.

Parameters
memType of non volatile memory
addressByte address of the non volatile memory
numPointer to where to store the page number

References ERR_INVALID_ARG, IFLASH_PAGE_SIZE, INT_FLASH, and STATUS_OK.

status_code_t nvm_get_size ( mem_type_t  mem,
uint32_t *  size 
)

Get the size of whole non volatile memory specified.

Parameters
memType of non volatile memory
sizePointer to where to store the size

References ERR_INVALID_ARG, IFLASH_PAGE_SIZE, INT_FLASH, and STATUS_OK.

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, ERR_NO_MEMORY, INT_FLASH, and STATUS_OK.

Referenced by pal_init().

status_code_t nvm_page_erase ( mem_type_t  mem,
uint32_t  page_number 
)

Erase a page in the non volatile memory.

Parameters
memType of non volatile memory to erase
page_numberPage number to erase

References ERR_INVALID_ARG, IFLASH_PAGE_SIZE, INT_FLASH, and STATUS_OK.

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 ERR_BAD_ADDRESS, ERR_INVALID_ARG, IFLASH_ADDR, IFLASH_PAGE_SIZE, INT_FLASH, and STATUS_OK.

Referenced by pal_ps_get().

status_code_t nvm_read_char ( mem_type_t  mem,
uint32_t  address,
uint8_t *  data 
)

Read single byte of data.

Parameters
memType of non volatile memory to read
addressAddress to read
dataPointer to where to store the read data

References ERR_BAD_ADDRESS, ERR_INVALID_ARG, IFLASH_ADDR, IFLASH_PAGE_SIZE, INT_FLASH, and STATUS_OK.

status_code_t nvm_set_security_bit ( void  )

Enable security bit which blocks external read and write access to the device.

References ERR_INVALID_ARG, and STATUS_OK.

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_BAD_ADDRESS, ERR_INVALID_ARG, flashcalw_memcpy(), INT_FLASH, and STATUS_OK.

Referenced by pal_ps_set().

status_code_t nvm_write_char ( mem_type_t  mem,
uint32_t  address,
uint8_t  data 
)

Write single byte of data.

Parameters
memType of non volatile memory to write
addressAddress to write
dataData to be written

References ERR_BAD_ADDRESS, ERR_INVALID_ARG, INT_FLASH, and STATUS_OK.