NVM3HalEMDRV > NVM3

Detailed Description

NVM3 hal module.

This module provides the interface to the NVM. By having all NVM access functions in a separate file, it is possible to support different hardware by just substituting the functions in this module.

Note
These functions are used by the NVM3 and should not be used by any applications.

Data Structures

struct nvm3_HalDeviceInfo
Write size capabilities in the NVM.

Macros

#define CHECK_DATA 1
Macro defining if data should be checked.
#define NVM3_HAL_WRITE_SIZE_16 1
Two writes are allowed.
#define NVM3_HAL_WRITE_SIZE_32 0
Only single writes are allowed.

Typedefs

typedef struct nvm3_HalDeviceInfo nvm3_HalDeviceInfo_t
Write size capabilities in the NVM.
typedef void * nvm3_HalPtr_t
Pointer to NVM.

Functions

void nvm3_halClose (void)
Close the NVM3 hal for usage.
void nvm3_halGetDeviceInfo ( nvm3_HalDeviceInfo_t *deviceInfo)
Retrieve device information.
Ecode_t nvm3_halOpen ( nvm3_HalPtr_t nvmAdr, size_t nvmSize)
Open the NVM3 hal for usage.
Ecode_t nvm3_halPageErase ( nvm3_HalPtr_t nvmAdr)
Erase a page in the NVM.
void nvm3_halReadBytes ( nvm3_HalPtr_t nvmAdr, uint8_t *pDst, size_t cnt)
Read data from NVM.
void nvm3_halReadWords ( nvm3_HalPtr_t nvmAdr, uint32_t *pDst, size_t cnt)
Read data from NVM.
Ecode_t nvm3_halWriteBytes ( nvm3_HalPtr_t nvmAdr, void const *pSrc, size_t cnt)
Write data to NVM.
Ecode_t nvm3_halWriteWords ( nvm3_HalPtr_t nvmAdr, void const *pSrc, size_t cnt)
Write data to NVM.

Variables

static uint32_t openCnt = 0
A variable that keeps track of the open count.

Function Documentation

void nvm3_halClose ( void )

Close the NVM3 hal for usage.

This function should be called at program termination. Should be done before any graceful halts.

Definition at line 127 of file nvm3_hal_flash.c .

References MSC_Deinit() , and openCnt .

void nvm3_halGetDeviceInfo ( nvm3_HalDeviceInfo_t * deviceInfo )

Retrieve device information.

This function is used to retrieve information about the device properties like the device family, write size, whether the NVM is memory mapped or not, and finally the NVM page size.

Parameters
[in] deviceInfo A pointer to a struct that will receive the device information.

Definition at line 137 of file nvm3_hal_flash.c .

References SYSTEM_ChipRevision_TypeDef::family , NVM3_HAL_WRITE_SIZE_16 , NVM3_HAL_WRITE_SIZE_32 , SYSTEM_ChipRevisionGet() , and SYSTEM_GetFlashPageSize() .

Ecode_t nvm3_halOpen ( nvm3_HalPtr_t nvmAdr,
size_t nvmSize
)

Open the NVM3 hal for usage.

Open the NVM3 flash driver.

This function must be run at initialization, before any other functions are called. It is used to call necessary startup routines before the hardware can be accessed.

Parameters
[in] nvmAdr A pointer to the destination in NVM.
[in] nvmSize The total size of the NVM.
Returns
The result of the open call. ECODE_NVM3_OK on success or a NVM3 Ecode_t on failure.

Definition at line 115 of file nvm3_hal_flash.c .

References ECODE_NVM3_OK , MSC_Init() , and openCnt .

Ecode_t nvm3_halPageErase ( nvm3_HalPtr_t nvmAdr )

Erase a page in the NVM.

This function is used to erase an NVM page.

Parameters
[in] nvmAdr A memory address pointing to the start of the page to erase.
Returns
The result of the erase operation.

Definition at line 225 of file nvm3_hal_flash.c .

References ECODE_NVM3_ERR_ERASE_FAILED , ECODE_NVM3_OK , MSC_ErasePage() , and SYSTEM_GetFlashPageSize() .

void nvm3_halReadBytes ( nvm3_HalPtr_t nvmAdr,
uint8_t * pDst,
size_t cnt
)

Read data from NVM.

This function is used to read data from the NVM. It will be a blocking call, since the thread asking for data to be read cannot continue without the data.

Parameters
[in] nvmAdr A memory address in NVM where the data shall be read.
[in] *pDst A pointer to the destination buffer.
[in] cnt The number of bytes to read.

Definition at line 152 of file nvm3_hal_flash.c .

void nvm3_halReadWords ( nvm3_HalPtr_t nvmAdr,
uint32_t * pDst,
size_t cnt
)

Read data from NVM.

This function is used to read data from the NVM. It will be a blocking call, since the thread asking for data to be read cannot continue without the data.

Parameters
[in] nvmAdr A memory address in NVM where the data shall be read.
[in] *pDst A pointer to the destination buffer.
[in] cnt The number of words to read.

Definition at line 162 of file nvm3_hal_flash.c .

Ecode_t nvm3_halWriteBytes ( nvm3_HalPtr_t nvmAdr,
void const * pSrc,
size_t cnt
)

Write data to NVM.

Parameters
[in] nvmAdr A memory address in NVM where the data shall be written.
[in] pSrc A pointer to the source data.
[in] cnt The number of bytes to write.
Returns
The result of the write operation. ECODE_NVM3_OK on success or a NVM3 Ecode_t on failure.

Definition at line 172 of file nvm3_hal_flash.c .

References ECODE_NVM3_OK , and nvm3_halWriteWords() .

Ecode_t nvm3_halWriteWords ( nvm3_HalPtr_t nvmAdr,
void const * pSrc,
size_t cnt
)

Write data to NVM.

This function is used to write data to the NVM. This is a blocking function.

Parameters
[in] nvmAdr A memory address in NVM where the data shall be written.
[in] *pSrc A pointer to the source data.
[in] cnt The number of words to write.
Returns
The result of the write operation. ECODE_NVM3_OK on success or a NVM3 Ecode_t on failure.

Definition at line 196 of file nvm3_hal_flash.c .

References ECODE_NVM3_ERR_INT_WRITE_TO_NOT_ERASED , ECODE_NVM3_ERR_WRITE_FAILED , ECODE_NVM3_OK , and MSC_WriteWord() .

Referenced by nvm3_halWriteBytes() .