sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dev_data.h
Go to the documentation of this file.
1 #ifndef dev_data_h
2 #define dev_data_h
3 
4 #include <inttypes.h>
5 #include "dev_config.h"
6 
7 #define EUID_LEN 8
8 
9 #define CFG_DATA(n) struct config_##n
10 #define cfg_read(n,x) _cfg_read(&x, sizeof(struct config_##n), CfgID_##n)
11 #ifdef USE_EEPROM
12 #define cfg_write(n,x) _cfg_write(&x, sizeof(struct config_##n), CfgID_##n)
13 #endif
14 
15 char _cfg_read(void *data, uint8_t size, ConfigID id);
16 #ifdef USE_EEPROM
17 char _cfg_write(void *data, uint8_t size, ConfigID id);
18 #endif
19 
20 #ifdef SMALL_DEVICE
21 typedef uint8_t cfg_addr_t;
22 #else
23 typedef uint16_t cfg_addr_t;
24 #endif
25 
26 // Find the block where this config item is stored
27 cfg_addr_t cfg_addr(uint8_t *size, ConfigID id);
28 
29 // read a config byte
30 uint8_t cfg_byte(cfg_addr_t addr);
31 
38 uint8_t cfg_count(cfg_addr_t *addr);
39 uint8_t cfg_type(cfg_addr_t *addr);
40 
41 struct config_rf12 { // for radio devices
42  unsigned int band:2;
43  unsigned int collect:1; // monitor mode: don't ack
44  unsigned int node:5;
45  uint8_t group; // RF12 sync pattern
46  uint8_t speed; // bitrate for RF12
47 };
48 
49 struct config_euid {
50  uint8_t id[EUID_LEN];
51 };
52 
53 struct config_crypto {
54  uint32_t key[4];
55 };
56 
57 struct config_owid {
58  uint8_t type;
59  uint8_t serial[6];
60  uint8_t crc;
61 };
62 
63 struct config_loader {
64  uint16_t loader; // address of moat_loader_t struct
65  uint16_t endp; // end of loaded area
66  uint16_t crc; // checksum of loadable code
67 };
68 
69 #ifdef USE_EEPROM
70 void eeprom_init(void);
71 #else
72 #define eeprom_init() do {} while(0)
73 #endif
74 #endif // dev_data_h
unsigned int node
Definition: dev_data.h:44
unsigned int collect
Definition: dev_data.h:43
uint8_t cfg_count(cfg_addr_t *addr)
Definition: dev_data.c:253
unsigned int band
Definition: dev_data.h:42
uint8_t speed
Definition: dev_data.h:46
Definition: dev_data.h:41
uint16_t cfg_addr_t
Definition: dev_data.h:23
byte addr[8]
Definition: OWP_DG_1w-adaptor.ino:104
uint16_t crc
Definition: dev_data.h:66
Definition: dev_data.h:49
tuple size
Definition: unpack-test.py:15
cfg_addr_t cfg_addr(uint8_t *size, ConfigID id)
Definition: dev_data.c:236
tuple data
Definition: ser-mon-AS7265X.py:40
uint8_t cfg_type(cfg_addr_t *addr)
Definition: dev_data.c:265
uint16_t loader
Definition: dev_data.h:64
#define EUID_LEN
Definition: dev_data.h:7
uint8_t group
Definition: dev_data.h:45
#define eeprom_init()
Definition: dev_data.h:72
uint32_t key[4]
Definition: dev_data.h:54
Definition: dev_data.h:57
uint8_t serial[6]
Definition: dev_data.h:59
Definition: dev_data.h:63
Definition: dev_data.h:53
uint8_t cfg_byte(cfg_addr_t addr)
Definition: dev_data.c:42
uint8_t crc
Definition: dev_data.h:60
char _cfg_read(void *data, uint8_t size, ConfigID id)
Definition: dev_data.c:170
uint8_t type
Definition: dev_data.h:58
uint16_t endp
Definition: dev_data.h:65