Data Structures | Typedefs | Functions | Variables
NVSMSP432.h File Reference
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  NVSMSP432_HWAttrs
 NVSMSP432 attributes. More...
 
struct  NVSMSP432_Object
 

Typedefs

typedef struct NVSMSP432_HWAttrs NVSMSP432_HWAttrs
 NVSMSP432 attributes. More...
 
typedef struct NVSMSP432_Object NVSMSP432_Object
 

Functions

void NVSMSP432_close (NVS_Handle handle)
 
int_fast16_t NVSMSP432_control (NVS_Handle handle, uint_fast16_t cmd, uintptr_t arg)
 
int_fast16_t NVSMSP432_erase (NVS_Handle handle, size_t offset, size_t size)
 
void NVSMSP432_getAttrs (NVS_Handle handle, NVS_Attrs *attrs)
 
void NVSMSP432_init ()
 
int_fast16_t NVSMSP432_lock (NVS_Handle handle, uint32_t timeout)
 
NVS_Handle NVSMSP432_open (uint_least8_t index, NVS_Params *params)
 
int_fast16_t NVSMSP432_read (NVS_Handle handle, size_t offset, void *buffer, size_t bufferSize)
 
void NVSMSP432_unlock (NVS_Handle handle)
 
int_fast16_t NVSMSP432_write (NVS_Handle handle, size_t offset, void *buffer, size_t bufferSize, uint_fast16_t flags)
 

Variables

const NVS_FxnTable NVSMSP432_fxnTable
 NVS function pointer table. More...
 

Typedef Documentation

§ NVSMSP432_HWAttrs

NVSMSP432 attributes.

The 'regionBase' field must point to the base address of the region to be managed.

The regionSize must be an integer multiple of the flash sector size. For most MSP432 devices, the flash sector size is 4096 bytes. The NVSMSP432 driver will determine the device's actual sector size by reading internal system configuration registers.

Care must be taken to ensure that the linker does not unintentionally place application content (e.g., code/data) in the flash regions.

For CCS and IAR tools, defining and reserving flash memory regions can be done entirely within the Board.c file. For GCC, additional content is required in the application's linker command file to achieve the same result.

The example below defines a char array, 'flashBuf' and uses compiler CCS and IAR compiler pragmas to place 'flashBuf' at a specific address within the flash memory.

For GCC, the 'flashBuf' array is placed into a named linker section. Corresponding linker commands are added to the application's linker command file to place the section at a specific flash memory address. The section placement command is carefully chosen to only RESERVE space for the 'flashBuf' array, and not to actually initialize it during the application load process, thus preserving the content of flash.

The 'regionBase' fields of the two HWAttrs region instances are initialized to point to the base address of 'flashBuf' and to some offset from the base of the char array.

The linker command syntax is carefully chosen to only RESERVE space for the char array and not to actually initialize it during application load.

#define SECTORSIZE 0x1000
#define FLASH_REGION_BASE 0x3b000
//
// Reserve flash sectors for NVS driver use
// by placing an uninitialized byte array
// at the desired flash address.
//
#if defined(__TI_COMPILER_VERSION__)
//
// Place uninitialized array at FLASH_REGION_BASE
//
#pragma LOCATION(flashBuf, FLASH_REGION_BASE);
#pragma NOINIT(flashBuf);
char flashBuf[SECTORSIZE * 4];
#elif defined(__IAR_SYSTEMS_ICC__)
//
// Place uninitialized array at FLASH_REGION_BASE
//
__no_init char flashBuf[SECTORSIZE * 4] @ FLASH_REGION_BASE;
#elif defined(__GNUC__)
//
// Place the reserved flash buffers in the .nvs section.
// The ,nvs section will be placed at address FLASH_REGION_BASE by
// the gcc linker cmd file.
//
__attribute__ ((section (".nvs")))
char flashBuf[SECTORSIZE * 4];
#endif
NVSMSP432_HWAttrs nvsMSP432HWAttrs[2] = {
//
// region 0 is 1 flash sector in length.
//
{
.regionBase = (void *)flashBuf,
.regionSize = SECTORSIZE,
},
//
// region 1 is 3 flash sectors in length.
//
{
.regionBase = (void *)(flashBuf + SECTORSIZE),
.regionSize = SECTORSIZE*3,
}
};
Example GCC linker command file content reserves flash space
but does not initialize it:
MEMORY
{
MAIN_FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00040000
INFO_FLASH (RX) : ORIGIN = 0x00200000, LENGTH = 0x00004000
SRAM_CODE (RWX): ORIGIN = 0x01000000, LENGTH = 0x00010000
SRAM_DATA (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
}
.nvs (0x3b000) (NOLOAD) : AT (0x3b000) {
KEEP (*(.nvs))
} > NVS

§ NVSMSP432_Object

Function Documentation

§ NVSMSP432_close()

void NVSMSP432_close ( NVS_Handle  handle)

§ NVSMSP432_control()

int_fast16_t NVSMSP432_control ( NVS_Handle  handle,
uint_fast16_t  cmd,
uintptr_t  arg 
)

§ NVSMSP432_erase()

int_fast16_t NVSMSP432_erase ( NVS_Handle  handle,
size_t  offset,
size_t  size 
)

§ NVSMSP432_getAttrs()

void NVSMSP432_getAttrs ( NVS_Handle  handle,
NVS_Attrs attrs 
)

§ NVSMSP432_init()

void NVSMSP432_init ( )

§ NVSMSP432_lock()

int_fast16_t NVSMSP432_lock ( NVS_Handle  handle,
uint32_t  timeout 
)

§ NVSMSP432_open()

NVS_Handle NVSMSP432_open ( uint_least8_t  index,
NVS_Params params 
)

§ NVSMSP432_read()

int_fast16_t NVSMSP432_read ( NVS_Handle  handle,
size_t  offset,
void *  buffer,
size_t  bufferSize 
)

§ NVSMSP432_unlock()

void NVSMSP432_unlock ( NVS_Handle  handle)

§ NVSMSP432_write()

int_fast16_t NVSMSP432_write ( NVS_Handle  handle,
size_t  offset,
void *  buffer,
size_t  bufferSize,
uint_fast16_t  flags 
)

Variable Documentation

§ NVSMSP432_fxnTable

const NVS_FxnTable NVSMSP432_fxnTable

NVS function pointer table.

'NVSMSP432_fxnTable' is a fully populated function pointer table that can be referenced in the NVS_config[] array entries.

Users can minimize their application code size by providing their own custom NVS function pointer table that contains only those APIs used by the application.

An example of a custom NVS function table is shown below:

//
// Since the application does not use the
// NVS_control(), NVS_lock(), and NVS_unlock() APIs,
// these APIs are removed from the function
// pointer table and replaced with NULL
//
const NVS_FxnTable myNVS_fxnTable = {
NULL, // remove NVSMSP432_control(),
NULL, // remove NVSMSP432_lock(),
NULL, // remove NVSMSP432_unlock(),
};
Copyright 2017, Texas Instruments Incorporated