NHS31xx SW API

Detailed Description

The Temperature Logger Demo Memory block gathers all accesses to data that must persist across active sessions. It will group access to:

It will maintain the current configuration, allowing access to the different parameters and states in SRAM, and ensuring the data will persist when going to Deep Power Down or Power-off states. To this end, it adds API to update the current state and convenience functions to quickly check for specific states.

Dependencies
  • There is a coupling with the events module: updating the current state through Memory_AddToState will result in calls to Event_Set whenever new states are entered.
  • There is a coupling with the storage module: when it is detected during Memory_Init the firmware has changed, Storage_Reset will be called to wipe all gathered data.
  • There is a dependency with the validate block: the workspace memory is maintained by this block - see MEMORY_CONFIG_T.validation.
Due to these dependencies, the memory block will also initialize respectively de-initialize the above mentioned modules/block by calling Validate_Init, Storage_Init and Event_Init; respectively Validate_DeInit, Storage_DeInit and Event_DeInit.

Apart of the above, calls to the mentioned modules/block still need to be carried out by the application.

Data Structures

struct  MEMORY_CONFIG_T
 

Macros

#define MEMORY_FIRSTUNUSEDEEPROMOFFSET   36
 
#define MEMORY_FIRSTUNUSEDEEPROMOFFSET   44
 

Functions

bool Memory_Init (void)
 
void Memory_DeInit (void)
 
const MEMORY_CONFIG_TMemory_GetConfig (void)
 
bool Memory_IsMonitoring (void)
 
bool Memory_IsFull (void)
 
bool Memory_BodOccurred (void)
 
bool Memory_IsReadyToStart (void)
 
void Memory_ResetConfig (const APP_MSG_CMD_SETCONFIG_T *pCmd)
 
void Memory_SetAttainedValue (int16_t value)
 
void Memory_AddToState (uint32_t events, bool ignoreWhenSet)
 
void Memory_RemoveFromState (uint32_t events)
 
void Memory_SetHumidityConfig (const APP_MSG_CMD_SETHUMIDITYCONFIG_T *pCmd)
 
void Memory_SetAttainedHumidityValue (uint16_t value)
 

Data Structure Documentation

◆ MEMORY_CONFIG_T

struct MEMORY_CONFIG_T

Defines the constant configuration under which to operate; Also stores some data of the ongoing monitoring and logging session

Warning
be sure to only list fields here that are updated very sparingly: each time these contents are changed, they will be written to EEPROM in Memory_DeInit. EEPROM has a guaranteed endurance of 10000 writes (per page) only.
Data Fields
APP_MSG_CMD_SETCONFIG_T cmd

As given by the tag reader.

int16_t attainedMinimum

The absolute minimum value recorded in deci-Celsius degrees.

int16_t attainedMaximum

The absolute maximum value recorded in deci-Celsius degrees.

uint32_t status

An OR'd combination of APP_MSG_EVENT_T events that reflect the current state.

uint32_t validation

A value solely read from and written to by validate.c file

APP_MSG_CMD_SETHUMIDITYCONFIG_T humidityConfig

As given by the tag reader.

uint16_t attainedMinimumHumidity

The absolute minimum value recorded in deci-Celsius degrees.

uint16_t attainedMaximumHumidity

The absolute maximum value recorded in deci-Celsius degrees.

Macro Definition Documentation

◆ MEMORY_FIRSTUNUSEDEEPROMOFFSET [1/2]

#define MEMORY_FIRSTUNUSEDEEPROMOFFSET   36

The offset in EEPROM memory to the first unclaimed byte by this storage component. The EEPROM region from the very first byte up to (not including) this offset is under full control of this component and no other code is assumed to use it.

◆ MEMORY_FIRSTUNUSEDEEPROMOFFSET [2/2]

#define MEMORY_FIRSTUNUSEDEEPROMOFFSET   44

The offset in EEPROM memory to the first unclaimed byte by this storage component. The EEPROM region from the very first byte up to (not including) this offset is under full control of this component and no other code is assumed to use it.

Function Documentation

◆ Memory_Init()

bool Memory_Init ( void  )

Initialization function. Must be called first in this component.

Note
Also calls Storage_Init, Event_Init, Validate_Init
Precondition
Must be the first function called in this file.
Chip_EEPROM_Init has been called beforehand
Returns
Whether the contents available in NVM were accepted. After flashing another image the contents are no longer accepted and a blank slate is used. In that case, false is returned. When true is returned, the contents that were set in NVM were read out and used.

◆ Memory_DeInit()

void Memory_DeInit ( void  )

De-Initializes the component.

Note
Also calls Storage_DeInit(), Event_DeInit, Validate_DeInit.
Precondition
Must be called before going to Power-off or Deep Power Down mode.
Postcondition
Must be called last in this file.

◆ Memory_GetConfig()

const MEMORY_CONFIG_T * Memory_GetConfig ( void  )

Retrieve configuration.

Returns
A pointer to the filled-in MEMORY_CONFIG_T structure.
Note
Multiple calls return the same pointer.

◆ Memory_IsMonitoring()

bool Memory_IsMonitoring ( void  )

Helper function. Checks MEMORY_CONFIG_T.status solely.

Returns
true if a new measurement will be made after some delay. There may be no measurements made yet.

◆ Memory_IsFull()

bool Memory_IsFull ( void  )

Helper function. Checks MEMORY_CONFIG_T.status solely.

Returns
true if storage is full - based on the previous calls to Memory_AddToState - and no new measurement can be stored.

◆ Memory_BodOccurred()

bool Memory_BodOccurred ( void  )

Helper function. Checks MEMORY_CONFIG_T.status solely.

Returns
true if a low battery voltage has been detected - using the bod HW block.

◆ Memory_IsReadyToStart()

bool Memory_IsReadyToStart ( void  )

Helper function. Checks MEMORY_CONFIG_T.status solely.

Returns
true if a configuration is present but no measurement is available, nor is due.

◆ Memory_ResetConfig()

void Memory_ResetConfig ( const APP_MSG_CMD_SETCONFIG_T pCmd)

Resets all parameters.

Parameters
pCmd: pointer to a structure where all new parameters are to be copied from. May be NULL. If equal to NULL, all values are reset to default values.
Note
Regardless of the given argument, the fields MEMORY_CONFIG_T.attainedMinimum, MEMORY_CONFIG_T.attainedMaximum and MEMORY_CONFIG_T.status will explicitly be set to default values - so no need to be filled in by the caller.

◆ Memory_SetAttainedValue()

void Memory_SetAttainedValue ( int16_t  value)

Updates the attained extremities of the measured values. There is no update of MEMORY_CONFIG_T.status - Use Memory_AddToState.

Parameters
valueThe new value to compare against the current extremities.
Note
The change is made to the memory pointed to by Memory_GetConfig.
Changes made are saved in NVM during Memory_DeInit.

◆ Memory_AddToState()

void Memory_AddToState ( uint32_t  events,
bool  ignoreWhenSet 
)

Updates MEMORY_CONFIG_T.status by adding bits to the bitmask.

Note
Every bit added will cause a new entry in event: event bookkeeping module
Measurement and event validation is notified for each set bit through Validate_NewEvents.
Parameters
eventsAn OR'd combination of APP_MSG_EVENT_T events that must be added.
ignoreWhenSet

◆ Memory_RemoveFromState()

void Memory_RemoveFromState ( uint32_t  events)

Updates MEMORY_CONFIG_T.status by removing bits from the bitmask.

Note
Entries in event: event bookkeeping module are left untouched.
Parameters
eventsAn OR'd combination of APP_MSG_EVENT_T events that must be removed. The bits that are not set in MEMORY_CONFIG_T.status are ignored.

◆ Memory_SetHumidityConfig()

void Memory_SetHumidityConfig ( const APP_MSG_CMD_SETHUMIDITYCONFIG_T pCmd)

Sets all humidity parameters.

Parameters
pCmd: pointer to a structure where all new humidity parameters are to be copied from. May be NULL. If equal to NULL, all humidity values are reset to default values.
Note
Regardless of the given argument, the fields MEMORY_CONFIG_T.attainedMinimumHumidity, and MEMORY_CONFIG_T.attainedMaximumHumidity will explicitly be set to default values - so no need to be filled in by the caller.

◆ Memory_SetAttainedHumidityValue()

void Memory_SetAttainedHumidityValue ( uint16_t  value)

Updates the attained extremities of the measured humidity values. There is no update of MEMORY_CONFIG_T.status - Use Memory_AddToState.

Parameters
valueThe new value to compare against the current extremities.
Note
The change is made to the memory pointed to by Memory_GetConfig.
Changes made are saved in NVM during Memory_DeInit.