The Therapy Adherence Demo Memory Manager is responsible for the EEPROM memory management. This component takes ownership of the chip's EEPROM and provides an API to store/read data from non-volatile memory.
- Memory Requirements:
- The Memory component assumes that it has the exclusive use of the EEPROM memory (read/write rows).
- Usage
- Most of the other components will need to preserve internal status data, for the Memory Manager this status data is simply treated as raw data. For this it divides it's memory space (EEPROM) in slots (see MEMORY_SLOT_ID_T), it is up to the requesting component to keep track of which data is stored in which slot and on it's size. The respective read/write API is: Memory_GetStoredData and Memory_StoreData.
To store and read intake strings (used in the initial NDEF message.) there is specialized API: Memory_StoreIntakeString/Memory_GetIntakeString.
|
void | Memory_Init (void) |
|
void | Memory_DeInit (void) |
|
void | Memory_StartTherapy (void) |
|
void | Memory_StoreData (MEMORY_SLOT_ID_T slot, const void *pSrc, int size) |
|
void | Memory_GetStoredData (MEMORY_SLOT_ID_T slot, void *pDst, int size) |
|
void | Memory_StoreIntakeString (int intakeNr, uint32_t startTime, uint32_t intakeTime, int group, bool positional, int initialCount, int pill) |
|
const char * | Memory_GetIntakeString (int intakeNr) |
|
void | Memory_StoreEvent (int eventNr, uint8_t *pEvent) |
|
const uint8_t * | Memory_GetEvents (void) |
|
#define | THERAPYINSTANCE_SLOTSIZE 26 |
|
#define | RHYTHM_SLOTSIZE 80 |
|
#define | SENSEINSTANCE_SLOTSIZE 40 |
|
◆ MEMORY_EVENTSIZE
#define MEMORY_EVENTSIZE 9 |
The size of an event stored by the memory module.
◆ MEMORY_MAXEVENTS
#define MEMORY_MAXEVENTS 35 |
The maximum number of events stored by the memory module.
◆ THERAPYINSTANCE_SLOTSIZE
#define THERAPYINSTANCE_SLOTSIZE 26 |
Memory slot size for respective slot
◆ RHYTHM_SLOTSIZE
#define RHYTHM_SLOTSIZE 80 |
Memory slot size for respective slot
◆ SENSEINSTANCE_SLOTSIZE
#define SENSEINSTANCE_SLOTSIZE 40 |
Memory slot size for respective slot
◆ MEMORY_SLOT_ID_T
List of available memory slots.
Enumerator |
---|
MEMORY_SLOT_ID_THERAPY_INSTANCE | Memory slot to store the instance for therapy module.
|
MEMORY_SLOT_ID_SENSE_INSTANCE | Memory slot to store the instance for sense module.
|
MEMORY_SLOT_ID_RHYTHM | Memory slot to store the configured rhythm.
|
◆ Memory_Init()
bool Memory_Init |
( |
void |
| ) |
|
Init function, it is important to execute this function before any other call to this component.
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 |
| ) |
|
DeInit function, it is important to execute this function before going to state where RAM is not preserved (Deep power down / Power Off).
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_StartTherapy()
void Memory_StartTherapy |
( |
void |
| ) |
|
Function to inform the Memory component a new therapy was started.
◆ Memory_StoreData()
Function to store raw data
- Parameters
-
slot | : The memory slot where to store the raw data. |
pSrc | : A pointer to the data to be stored. |
size | : Amount of bytes to be stored. |
◆ Memory_GetStoredData()
Function to read raw data (previously stored by Memory_StoreData)
- Parameters
-
slot | : The memory slot where to read the raw data. |
pDst | : A pointer to the memory location where to put the data. |
size | : Amount of bytes to be read (checked to the slotSize). |
◆ Memory_StoreIntakeString()
void Memory_StoreIntakeString |
( |
int |
intakeNr, |
|
|
uint32_t |
startTime, |
|
|
uint32_t |
intakeTime, |
|
|
int |
group, |
|
|
bool |
positional, |
|
|
int |
initialCount, |
|
|
int |
pill |
|
) |
| |
Function to store a new pill intake as a string (used in the initial NDEF message). The provided data is used to generate a string representing this event.
- Parameters
-
intakeNr | : The number of new intake string. |
startTime | : The time at which the therapy was started. |
intakeTime | : The time at which the pill removal was sensed. |
group | : The group of the removed pill. |
positional | : Defines whether group is positional. |
initialCount | : The initial pill count for group . |
pill | : The number of the removed pill (in the group). |
◆ Memory_GetIntakeString()
const char* Memory_GetIntakeString |
( |
int |
intakeNr | ) |
|
Function to get a previously stored 'intake' string.
- Parameters
-
intakeNr | : The number of requested 'intake' string. |
- Returns
- A pointer to memory where the string can be read.
◆ Memory_StoreEvent()
void Memory_StoreEvent |
( |
int |
eventNr, |
|
|
uint8_t * |
pEvent |
|
) |
| |
Function to store a new event. All events are stored consecutively such that they can be read at once.
- Parameters
-
eventNr | : The number of the event. Needed to calculate the memory offset to store the event. |
pEvent | : A pointer to the event data to be stored. |
- Note
- Memory module expects an event to be MEMORY_EVENTSIZE bytes in size.
◆ Memory_GetEvents()
const uint8_t* Memory_GetEvents |
( |
void |
| ) |
|
Function to get a memory pointer where to read recorded events. It is up to higher levels to manage the amount of stored events. All events are stored consecutively such that they can be read at once.
- Returns
- A pointer from where in memory the first event can be read.
- Note
- Memory module expects an event to be MEMORY_EVENTSIZE bytes in size. Memory module can store up to MEMORY_EVENTSIZE events.