Microchip® Advanced Software Framework

pds_nvm.c File Reference

Persistent Storage NVM management.

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

#include <asf.h>
#include <string.h>
#include "pds_nvm.h"
#include "conf_nvm.h"
#include "ble_utils.h"

Functions

pds_status_t pds_nvm_erase (pds_env_t *pds_instance, uint32_t mem_address, uint16_t len)
 PDS NVM erase operation. More...
 
pds_status_t pds_nvm_init (pds_env_t *pds_instance)
 Initialize the PDS NVM memory controller. More...
 
pds_status_t pds_nvm_read (pds_env_t *pds_instance, uint32_t mem_address, uint8_t *buffer, uint16_t len)
 PDS NVM read operation. More...
 
pds_status_t pds_nvm_write (pds_env_t *pds_instance, uint32_t mem_address, uint8_t *buffer, uint16_t len)
 PDS NVM write operation. More...
 

Variables

pds_env_t pds_env_cfg
 

pds_status_t pds_nvm_erase ( pds_env_t pds_instance,
uint32_t  mem_address,
uint16_t  len 
)

PDS NVM erase operation.

Erase the PDS data from NVM address location for the given size

Parameters
[in]pds_instanceInitialized PDS environment structure
[in]mem_addressNVM address location
[in]lenNVM erase size
Returns
Status of the NVM read operation
Return values
PDS_SUCCESSNVM erase procedure is completed
forother return values check pds_status_t enum values

References pds_env::flash_id, nvm_erase_row(), PDS_INTERNAL_FLASH_ID, PDS_INVALID_FLASH_ID, PDS_SUCCESS, status, system_interrupt_enter_critical_section(), and system_interrupt_leave_critical_section().

Referenced by pds_compact_sector(), and pds_delete_all().

pds_status_t pds_nvm_init ( pds_env_t pds_instance)

Initialize the PDS NVM memory controller.

Initialize the NVM memory controller, based on the NVM id the respective driver API's must be called, If any errors in the initialization will result in PDS Initialization error

Parameters
[in]pds_instanceInitialized PDS environment structure
Returns
Status of the PDS Initialize procedure
Return values
PDS_SUCCESSPDS Initialize procedure is completed
PDS_INIT_ERRORPDS initialization failed, due to inactive sector or NVM Init failures
forother return values check pds_status_t enum values

References Assert, pds_env::flash_id, nvm_config::manual_page_write, nvm_get_config_defaults(), nvm_set_config(), PDS_INTERNAL_FLASH_ID, PDS_INVALID_FLASH_ID, PDS_NVM_INIT_ERROR, PDS_SUCCESS, STATUS_OK, and nvm_config::wait_states.

Referenced by pds_init().

pds_status_t pds_nvm_read ( pds_env_t pds_instance,
uint32_t  mem_address,
uint8_t *  buffer,
uint16_t  len 
)

PDS NVM read operation.

Read the PDS data from NVM address location for the given size

Parameters
[in]pds_instanceInitialized PDS environment structure
[in]mem_addressNVM address location
[in]bufferNVM read buffer
[in]lenNVM read buffer size
Returns
Status of the NVM read operation
Return values
PDS_SUCCESSNVM read procedure is completed
forother return values check pds_status_t enum values

References Assert, data, pds_env::flash_id, len, nvm_is_ready(), NVM_MEMORY, PDS_INTERNAL_FLASH_ID, PDS_INVALID_FLASH_ID, PDS_NVM_READ_ERROR, and PDS_SUCCESS.

Referenced by pds_compact_sector(), pds_delete(), pds_init(), pds_item_exist(), pds_list_item(), pds_read(), and pds_write().

pds_status_t pds_nvm_write ( pds_env_t pds_instance,
uint32_t  mem_address,
uint8_t *  buffer,
uint16_t  len 
)

PDS NVM write operation.

Write the PDS data into NVM address location

Parameters
[in]pds_instanceInitialized PDS environment structure
[in]mem_addressNVM address location
[in]bufferNVM write buffer
[in]lenNVM write buffer size
Returns
Status of the NVM write procedure
Return values
PDS_SUCCESSNVM write procedure is completed
forother return values check pds_status_t enum values

References buffer, pds_env::flash_id, i, nvm_erase_row(), nvm_read_buffer(), nvm_write_buffer(), PDS_INTERNAL_FLASH_ID, PDS_INVALID_FLASH_ID, PDS_NVM_WRITE_ERROR, PDS_SUCCESS, STATUS_BUSY, STATUS_OK, system_interrupt_enter_critical_section(), and system_interrupt_leave_critical_section().

Referenced by pds_compact_sector(), pds_delete(), pds_delete_all(), and pds_write().

pds_env_t pds_env_cfg
Initial value:
= {
.flash_id = PDS_INTERNAL_FLASH_ID,
.pds_nvm_start_address = PDS_START_ADDRESS,
.pds_sector_count = PDS_SECTOR_COUNT,
.pds_sector_size = PDS_SECTOR_SIZE
}
#define PDS_INTERNAL_FLASH_ID
Definition: pds_nvm.h:91