Atmel Software Framework

uc3_nvm.c File Reference

Non volatile memories management for UC3 devices.

Copyright (c) 2012 Atmel Corporation. All rights reserved.

#include "common_nvm.h"
#include "conf_nvm.h"
#include "flash_api.h"
#include "string.h"

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...
 

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, 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, 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 AT45DBX_MEM_SIZE, ERR_INVALID_ARG, 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 at45dbx_init(), at45dbx_mem_check(), ERR_INVALID_ARG, ERR_NO_MEMORY, INT_FLASH, and STATUS_OK.

Referenced by test_mem().

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_BAD_DATA, ERR_INVALID_ARG, 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 at45dbx_read_close(), at45dbx_read_sector_open(), at45dbx_read_sector_to_ram(), AT45DBX_SECTOR_SIZE, ERR_BAD_ADDRESS, ERR_INVALID_ARG, INT_FLASH, and STATUS_OK.

Referenced by test_mem().

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 at45dbx_read_byte(), at45dbx_read_byte_open(), at45dbx_read_close(), ERR_BAD_ADDRESS, ERR_INVALID_ARG, 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 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 AT45DBX_SECTOR_SIZE, at45dbx_write_close(), at45dbx_write_sector_from_ram(), at45dbx_write_sector_open(), ERR_BAD_ADDRESS, ERR_INVALID_ARG, INT_FLASH, and STATUS_OK.

Referenced by test_mem().

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 at45dbx_write_byte(), at45dbx_write_byte_open(), at45dbx_write_close(), ERR_BAD_ADDRESS, ERR_INVALID_ARG, INT_FLASH, and STATUS_OK.