nvm_hal.c File Reference
Non-Volatile Memory Wear-Leveling driver HAL implementation.
License
Copyright 2018 Silicon Laboratories Inc. www.silabs.com
SPDX-License-Identifier: Zlib
The licensor of this software is Silicon Laboratories Inc.
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
- This notice may not be removed or altered from any source distribution.
Definition in file
nvm_hal.c
.
#include <stdbool.h>
#include "
em_msc.h
"
#include "
nvm.h
"
#include "
nvm_hal.h
"
Functions |
|
void | NVMHAL_Checksum (uint16_t *pChecksum, void *pMemory, uint16_t len) |
Calculate checksum according to CCITT CRC16.
|
|
void | NVMHAL_DeInit (void) |
De-initialize NVM .
|
|
void | NVMHAL_Init (void) |
Initialize NVM driver.
|
|
Ecode_t | NVMHAL_PageErase (uint8_t *pAddress) |
Erase a page in the NVM.
|
|
void | NVMHAL_Read (uint8_t *pAddress, void *pObject, uint16_t len) |
Read data from NVM.
|
|
Ecode_t | NVMHAL_Write (uint8_t *pAddress, void const *pObject, uint16_t len) |
Write data to NVM.
|
|
Function Documentation
void NVMHAL_Checksum | ( | uint16_t * |
pChecksum,
|
void * |
pMemory,
|
||
uint16_t |
len
|
||
) |
Calculate checksum according to CCITT CRC16.
This function calculates a checksum of the supplied buffer. The checksum is calculated using CCITT CRC16 plynomial x^16+x^12+x^5+1.
This functionality is also present internally in the API, but is duplicated here to allow for much more efficient calculations specific to the hardware.
- Parameters
-
[in] pChecksum
Pointer to where the checksum should be calculated and stored. This buffer should be initialized. A good consistent starting point would be NVM_CHECKSUM_INITIAL. [in] pMemory
Pointer to the data you want to calculate a checksum for. [in] len
The length of the data.
Definition at line
318
of file
nvm_hal.c
.
void NVMHAL_DeInit | ( | void |
|
) |
De-initialize NVM .
This function is run when the API deinit function is run. This should be done before any graceful halts.
Definition at line
147
of file
nvm_hal.c
.
References MSC_Deinit() .
void NVMHAL_Init | ( | void |
|
) |
Initialize NVM driver.
This function is run upon initialization, at least once before any other functions. It can be used to call necessary startup routines before the hardware can be accessed.
Definition at line
134
of file
nvm_hal.c
.
References MSC_Init() .
Referenced by NVM_Init() .
Ecode_t NVMHAL_PageErase | ( | uint8_t * |
pAddress
|
) |
Erase a page in the NVM.
This function calls MSC_ErasePage and converts the return status.
- Parameters
-
[in] *pAddress
Memory address pointing to the start of the page to erase.
- Returns
- Returns the result of the erase operation.
Definition at line
289
of file
nvm_hal.c
.
References MSC_ErasePage() .
Referenced by NVM_Erase() .
void NVMHAL_Read | ( | uint8_t * |
pAddress,
|
void * |
pObject,
|
||
uint16_t |
len
|
||
) |
Read data from NVM.
This function is used to read data from the NVM hardware. It should be a blocking call, since the thread asking for data to be read cannot continue without the data.
Another requirement is the ability to read unaligned blocks of data with single byte precision.
- Parameters
-
[in] *pAddress
Memory address in hardware for the data to read. [in] *pObject
RAM buffer to store the data from NVM. [in] len
The length of the data.
Definition at line
173
of file
nvm_hal.c
.
Referenced by NVM_Erase() , NVM_Init() , NVM_Read() , and NVM_Write() .
Ecode_t NVMHAL_Write | ( | uint8_t * |
pAddress,
|
void const * |
pObject,
|
||
uint16_t |
len
|
||
) |
Write data to NVM.
This function is used to write data to the NVM. This is a blocking function.
- Parameters
-
[in] *pAddress
NVM address to write to. [in] *pObject
Pointer to source data. [in] len
The length of the data in bytes.
- Returns
- Returns the result of the write operation.
Definition at line
210
of file
nvm_hal.c
.
References MSC_WriteWord() , and mscReturnOk .
Referenced by NVM_Erase() , and NVM_Write() .