NV component implementation.
Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.
#include <D_Nv_Bindings.h>
#include <D_Nv.h>
#include <D_Nv_Init.h>
#include "nvm.h"
#include "common_nvm.h"
#include "compiler.h"
#include "system_interrupt.h"
#include "string.h"
#include "assert.h"
Macros | |
#define | COMPID "D_Nv" |
#define | D_NV_MEMORY_END (((uint32_t)&__d_nv_mem_end) - 1U) |
#define | D_NV_MEMORY_START (uint32_t)&__d_nv_mem_start |
Functions | |
static bool | CompareData (uint8_t sector, uint16_t offset, uint8_t *pBuffer, D_Nv_Size_t numberOfBytes) |
Compare bytes with contents of the internal NV. More... | |
void | D_Nv_EraseSector (uint8_t sector) |
Erases a sector of the internal NV. More... | |
void | D_Nv_Init (void) |
Initializes the component – checks that parameters are correct. More... | |
bool | D_Nv_IsEmpty (uint8_t sector, uint16_t offset, D_Nv_Size_t numberOfBytes) |
Checks if the requested range is empty (containing all 0xFF). More... | |
bool | D_Nv_IsEqual (uint8_t sector, uint16_t offset, uint8_t *pBuffer, D_Nv_Size_t numberOfBytes) |
Compare bytes with contents of the internal NV. More... | |
void | D_Nv_Read (uint8_t sector, uint16_t offset, uint8_t *pBuffer, D_Nv_Size_t numberOfBytes) |
Read bytes from the internal NV. More... | |
void | D_Nv_SetSystemIntegrityCheckFunction (void(*pf)(void)) |
The function to set system integrity check callback function. More... | |
void | D_Nv_Write (uint8_t sector, uint16_t offset, uint8_t *pBuffer, D_Nv_Size_t numberOfBytes) |
Write bytes to the internal NV. More... | |
Variables | |
uint32_t | __d_nv_mem_end |
uint32_t | __d_nv_mem_start |
static void(* | s_pfSystemCheckCallback )(void) = NULL |
#define COMPID "D_Nv" |
#define D_NV_MEMORY_END (((uint32_t)&__d_nv_mem_end) - 1U) |
Referenced by CompareData(), D_Nv_EraseSector(), D_Nv_Init(), D_Nv_Read(), and D_Nv_Write().
#define D_NV_MEMORY_START (uint32_t)&__d_nv_mem_start |
Referenced by CompareData(), D_Nv_EraseSector(), D_Nv_Init(), D_Nv_Read(), and D_Nv_Write().
|
static |
Compare bytes with contents of the internal NV.
sector | The sector to use (0..D_NV_SECTOR_COUNT) | |
offset | The offset to start comparing with | |
[in] | pBuffer | If NULL then read buffer will be compared with 0xFF Otherwise it is the start address of the buffer that contains the data to compare with |
numberOfBytes | The number of bytes to compare |
References D_NV_FIRST_SECTOR, D_NV_MEMORY_END, D_NV_MEMORY_START, D_NV_SECTOR_SIZE, FLASH_PTR, i, and MIN.
Referenced by D_Nv_IsEmpty(), and D_Nv_IsEqual().
void D_Nv_EraseSector | ( | uint8_t | sector | ) |
Erases a sector of the internal NV.
sector | The sector to erase (0..D_NV_SECTOR_COUNT) |
References D_NV_FIRST_SECTOR, D_NV_MEMORY_END, D_NV_MEMORY_START, D_NV_SECTOR_SIZE, i, and nvm_erase_row().
void D_Nv_Init | ( | void | ) |
Initializes the component – checks that parameters are correct.
References D_NV_MEMORY_END, D_NV_MEMORY_SIZE, D_NV_MEMORY_START, and D_NV_SECTOR_SIZE.
Referenced by PDS_Init().
bool D_Nv_IsEmpty | ( | uint8_t | sector, |
uint16_t | offset, | ||
D_Nv_Size_t | numberOfBytes | ||
) |
Checks if the requested range is empty (containing all 0xFF).
sector | The sector to use (0..D_NV_SECTOR_COUNT) |
offset | The start offset to check |
numberOfBytes | The number of bytes to check |
References CompareData().
bool D_Nv_IsEqual | ( | uint8_t | sector, |
uint16_t | offset, | ||
uint8_t * | pBuffer, | ||
D_Nv_Size_t | numberOfBytes | ||
) |
Compare bytes with contents of the internal NV.
sector | The sector to use (0..D_NV_SECTOR_COUNT) | |
offset | The offset to start comparing with | |
[in] | pBuffer | The start address of the buffer that contains the data to compare with |
numberOfBytes | The number of bytes to compare |
References CompareData().
void D_Nv_Read | ( | uint8_t | sector, |
uint16_t | offset, | ||
uint8_t * | pBuffer, | ||
D_Nv_Size_t | numberOfBytes | ||
) |
Read bytes from the internal NV.
sector | The sector to use (0..D_NV_SECTOR_COUNT) | |
offset | The offset to start reading at | |
[out] | pBuffer | The start address of the buffer to store the read data to |
numberOfBytes | The number of bytes to read |
References D_NV_FIRST_SECTOR, D_NV_MEMORY_END, D_NV_MEMORY_START, D_NV_SECTOR_SIZE, and FLASH_PTR.
void D_Nv_SetSystemIntegrityCheckFunction | ( | void(*)(void) | pf | ) |
The function to set system integrity check callback function.
References s_pfSystemCheckCallback.
void D_Nv_Write | ( | uint8_t | sector, |
uint16_t | offset, | ||
uint8_t * | pBuffer, | ||
D_Nv_Size_t | numberOfBytes | ||
) |
Write bytes to the internal NV.
sector | The sector to use (0..D_NV_SECTOR_COUNT) | |
offset | The offset to start writing to | |
[in] | pBuffer | The start address of the buffer that contains the data to write |
numberOfBytes | The number of bytes to write |
References D_NV_FIRST_SECTOR, D_NV_MEMORY_END, D_NV_MEMORY_START, D_NV_SECTOR_SIZE, MIN, nvm_write_buffer(), s_pfSystemCheckCallback, STATUS_BUSY, STATUS_OK, system_interrupt_enter_critical_section(), and system_interrupt_leave_critical_section().
uint32_t __d_nv_mem_end |
uint32_t __d_nv_mem_start |
|
static |
Referenced by D_Nv_SetSystemIntegrityCheckFunction(), and D_Nv_Write().