Helper class for providing access to non-volatile data in the EEprom. More...
#include <EEprom.h>
Classes | |
struct | s_cnlTbl |
Channel Table Entry. More... | |
struct | s_devDef |
Device Definition. More... | |
struct | s_peerTbl |
Peer Device Table Entry. More... | |
Public Member Functions | |
uint8_t | getList (uint8_t cnl, uint8_t lst, uint8_t idx, uint8_t *buf) |
uint8_t | setList (uint8_t cnl, uint8_t lst, uint8_t idx, uint8_t *buf) |
Write arbitrary data as list content to EEprom. More... | |
uint8_t | getRegAddr (uint8_t cnl, uint8_t lst, uint8_t idx, uint8_t addr) |
uint32_t | getHMID (void) |
void | init (void) |
void | getMasterID (void) |
void | testModul (void) |
uint8_t | isHMIDValid (uint8_t *toID) |
uint8_t | isPairValid (uint8_t *reID) |
uint8_t | isBroadCast (uint8_t *reID) |
uint8_t | getIntend (uint8_t *reId, uint8_t *toId, uint8_t *peId) |
void | clearPeers (void) |
uint8_t | isPeerValid (uint8_t *peer) |
uint8_t | countFreeSlots (uint8_t cnl) |
uint8_t | getIdxByPeer (uint8_t cnl, uint8_t *peer) |
uint8_t | getPeerByIdx (uint8_t cnl, uint8_t idx, uint8_t *peer) |
uint8_t | addPeer (uint8_t cnl, uint8_t *peer) |
uint8_t | remPeer (uint8_t cnl, uint8_t *peer) |
uint8_t | countPeerSlc (uint8_t cnl) |
uint8_t | getPeerListSlc (uint8_t cnl, uint8_t slc, uint8_t *buf) |
uint8_t | getPeerSlots (uint8_t cnl) |
void | clearRegs (void) |
uint8_t | countRegListSlc (uint8_t cnl, uint8_t lst) |
uint8_t | getRegListSlc (uint8_t cnl, uint8_t lst, uint8_t idx, uint8_t slc, uint8_t *buf) |
uint8_t | setListArray (uint8_t cnl, uint8_t lst, uint8_t idx, uint8_t len, uint8_t *buf) |
Set individual registers of a list. More... | |
uint8_t | getRegListIdx (uint8_t cnl, uint8_t lst) |
uint8_t | checkIndex (uint8_t cnl, uint8_t lst, uint8_t idx) |
Friends | |
class | AS |
class | RV |
class | CB |
Helper class for providing access to non-volatile data in the EEprom.
This class is used by the main AS class to handle non-volatile data stored in the EEprom and accessed in form of Registers in the context of Lists. Additionally, it maintains the peer database to validate incoming messages and help formulate outgoing messages.
Every device requires a set of definitions that define its properties and capabilities:
EE::s_devDef
devDef
comprising device identity and the channel slice address definitionEE::s_cnlTbl
cnlTbl
referring to the channel slice address definitionEE::s_peerTbl
peerTbl
Start | Length | Content |
---|---|---|
0x0000 | 2 | magic byte |
0x0002 | 3 | HMID |
0x0005 | 10 | serial number |
0x000f | N_l | register values (see below) |
0x000f+N_l | N_p | peer list (see below) |
Register values are stored for each possible Channel/List combination. A typical device knows exactly one List0 (Channel 0), and for each channel a combination of List1 and either List3 or List4.
For each channel, the number of possible peer devices can be specified individually. With chanX_listY_len as the number of register bytes for list Y in channel X and peers_chanX as the maximum number of peers for channel X, the memory footprint can be calculated as follows:
Channel | List0 | List1 | List3 | List4 | Size | Note |
---|---|---|---|---|---|---|
0 | chan0_list0_len | chan0_l0_len | mandatory | |||
1 | chan1_list1_len | peers_chan1 * chan1_list1_len | mandatory | |||
1 | chan1_list3_len | peers_chan1 * chan1_list3_len | actor | |||
1 | chan1_list4_len | peers_chan1 * chan1_list4_len | sensor | |||
2 | chan2_list1_len | peers_chan2 * chan1_list1_len | mandatory | |||
2 | chan2_list3_len | peers_chan2 * chan1_list3_len | actor | |||
2 | chan2_list4_len | peers_chan2 * chan1_list4_len | sensor | |||
N | chanN_list1_len | peers_chan2 * chan1_list1_len | mandatory | |||
N | chanN_list3_len | peers_chan2 * chan1_list3_len | actor | |||
N | chanN_list4_len | peers_chan2 * chan1_list4_len | sensor |
uint8_t EE::setList | ( | uint8_t | cnl, |
uint8_t | lst, | ||
uint8_t | idx, | ||
uint8_t * | buf | ||
) |
Write arbitrary data as list content to EEprom.
setList() can be used to set the values of all registers in a list (see Device Registers).
cnl | Channel |
lst | List |
idx | Index of peer (0 if not applicable) |
buf | Array with all new list values (must match size of channel-list) |
The specified channel, list and index are used to identify the eeprom section to write to (see EEprom memory layout).
If a valid eeprom section can be identified, the content of buf will be written to the associated EEprom memory section.
In a simple example, the channel slice address definition for List0 is:
In order to write the contents of list0 (10 bytes) to the EEprom, we simply use:
Note how registers with data types bigger than one byte use consecutive addresses for the required number of bytes.
Commonly, it is good practice to keep the declaration of the register contents close to that of the channel slice address definition to simplify book-keeping during development.
uint8_t EE::setListArray | ( | uint8_t | cnl, |
uint8_t | lst, | ||
uint8_t | idx, | ||
uint8_t | len, | ||
uint8_t * | buf | ||
) |
Set individual registers of a list.
setListArray can be used to set indivual registers of a list (see Device Registers). Any number of registers defined for a list by the respective channel slice address definition can we written with a new value.
cnl | Channel |
lst | List |
idx | Index of peer (0 if not applicable) |
len | Array length (must be a multiple of 2) |
buf | Array with pairs of REGNUM:VALUE |
The specified channel, list and index are used to identify the eeprom section to write to (see EEprom memory layout).
If a valid eeprom section is identified, each REGNUM:VALUE pair in the array for validity and write will be used to write VALUE as the new content of register REGNUM in the specified List.
In a simple example, the channel slice address definition for List0 is:
docs/snippets/register-h-cnlTbl.cpp
In order to write the contents for only a few of the registers of List0 to the EEprom, we simply use: