-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhwcfg.wfc
570 lines (471 loc) · 12.3 KB
/
hwcfg.wfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
/*
* Copyright (C) 2018-2024, Thomas Maier-Komor
* Atrium Firmware Package for ESP
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
option author="Thomas Maier-Komor";
option copyright="2018-2024";
option common {
BaseClass=Message;
getMember=getMember;
id0=true;
wfclib=extern;
}
option pc : common {
toSink="";
toASCII=toASCII;
optimize=speed;
//header="pcconfig.h";
header="support.h";
enumnames=true;
enummap=true;
cfgdefs=all;
}
option esp : common {
withEqual=true;
toString="";
toSink="";
toWire="";
toASCII=toASCII;
intsize=32;
varintbits=32;
header="estring.h";
header=<sdkconfig.h>;
header="stream.h";
streamtype=stream;
stringtype=estring;
bytestype=estring;
SortMembers=size;
enumnames=true;
enummap="!CONFIG_ESPTOOLPY_FLASHSIZE_1MB";
}
option esp32 : esp {
optimize=speed;
endian=little; // not for esp8266, does not allow unaligned access
withUnequal=true;
/AdcConfig/adc_name: used = false;
/AdcConfig/mode: used = false;
/AdcConfig/clk_div: used = false;
}
option esp8266 : esp {
ssize_t=_ssize_t;
optimize=size;
withUnequal=false;
/TouchpadConfig: used = false;
/TouchChannelConfig: used = false;
/AdcChannel: used = false;
/HardwareConfig/uart: used = false;
/HardwareConfig/touchpad: used = false;
/HardwareConfig/tp_channel: used = false;
/I2CConfig/freq: used = false;
/UartConfig/tx_gpio: used = false;
/UartConfig/rx_gpio: used = false;
/UartConfig/cts_gpio: used = false;
/UartConfig/rts_gpio: used = false;
/AdcConfig/adc1_bits: used = false;
/AdcConfig/adc2_bits: used = false;
/AdcConfig/hall_name: used = false;
/AdcConfig/channels: used = false;
/Ws2812bConfig/ch: used = false;
/SX1276Config: used = false;
}
option esp8285 : esp8266 {
BaseClass="";
getMember="";
/HardwareConfig/max7129: used = false;
/HardwareConfig/display: used = false;
/DisplayConfig: used = false;
/Max7219Config: used = false;
}
message SystemConfig
{
string manufacturer = 1;
string board_name = 2;
string board_rev = 3;
sint8 diag_uart = 4 [ unset = 0 ];
sint8 console_rx = 5 [ default = 0 ];
sint8 console_tx = 6 [ default = 0 ];
string model_name = 7;
string model_number = 8;
bool usb_diag = 9 [ unset = true, ifdef=CONFIG_USB_DIAGLOG ];
bool usb_con = 10 [ unset = true, ifdef=CONFIG_USB_CONSOLE ];
// CC1/CC2 must be GPIO ports with ADC channel.
// Related driver provides cable orientation, plug state,
// and max. current delivered.
sint8 cc1_gpio = 11 [ unset = -1, ifdef=CONFIG_ESP_PHY_ENABLE_USB ];
sint8 cc2_gpio = 12 [ unset = -1, ifdef=CONFIG_ESP_PHY_ENABLE_USB ];
}
message TouchpadConfig
{
bool fsm_mode = 1 [ unset = false ];
sint8 lvolt = 2 [ unset = -1 ];
sint8 hvolt = 3 [ unset = -1 ];
sint8 atten = 4 [ unset = -1 ];
unsigned interval = 7;
}
message TouchChannelConfig
{
string name = 1;
sint8 channel = 2 [ unset = -1 ];
fixed16 threshold = 3;
uint8 slope = 4;
uint8 tieopt = 5;
}
enum pull_mode_e
{
option allow_alias = true;
pull_none = 0;
pull_en = 1;
pull_dir = 2;
pull_down = 1;
pull_up = 3;
}
bitset pull_mode_t
{
bool enable : 0;
bool up : 1;
}
message ButtonConfig
{
string name = 1;
sint8 gpio = 2 [ unset = -1 ];
bool presslvl = 3 [ unset = 0 ];
pull_mode_t pull_mode = 4 [ unset = pull_none ];
sint8 clk = 5 [ unset = -1, ifdef=CONFIG_ROTARYENCODER ];
sint8 dt = 6 [ unset = -1, ifdef=CONFIG_ROTARYENCODER ];
}
bitset relay_cfg_t
{
bool active_high : 0;
bool init_on : 1;
bool persistent : 2;
bool opendrain : 3;
bool mqtt : 4;
}
message RelayConfig
{
string name = 1;
sint8 gpio = 2 [ unset = -1 ];
relay_cfg_t config = 3 [ unset = 0 ];
unsigned min_itv = 4 [ default = 0 ]; // minimum interval
sint8 interlock = 5 [ unset = -1 ]; // index of relay to interlock with
}
message Max7219Config
{
sint8 clk = 1 [ unset = -1 ];
sint8 dout = 2 [ unset = -1 ];
sint8 cs = 3 [ unset = -1 ];
bool odrain = 4 [ unset = false ];
uint8 digits = 5 [ unset = 0 ];
}
message Tlc5947Config
{
sint8 sin = 1 [ unset = -1 ];
sint8 sclk = 2 [ unset = -1 ];
sint8 xlat = 3 [ unset = -1 ];
sint8 blank = 4 [ unset = -1 ];
uint8 ntlc = 5 [ unset = 0 ];
}
message Ws2812bConfig
{
sint8 gpio = 1 [ unset = -1 ];
sint8 ch = 2 [ unset = -1, ifdef=CONFIG_SOC_RMT_SUPPORTED ];
uint8 nleds = 3 [ unset = 0 ];
string name = 4;
}
enum dht_model_t
{
DHT_NONE = 0;
RHT03 = 3;
DHT11 = 11;
DHT21 = 21;
DHT22 = 22;
AM2301 = 2301;
AM2302 = 2302;
}
message DhtConfig
{
dht_model_t model = 1 [ unset = DHT_NONE ];
sint8 gpio = 2 [ unset = -1 ];
}
enum i2cdrv_t {
i2cdrv_invalid = 0;
i2cdrv_pcf8574 = 1;
i2cdrv_mcp2300x = 2;
i2cdrv_mcp2301x = 3;
i2cdrv_pca9685 = 4;
i2cdrv_pca9685_npn = 5;
i2cdrv_pca9685_pnp = 6;
i2cdrv_pca9685_xclk = 7;
i2cdrv_pca9685_xclk_npn = 8;
i2cdrv_pca9685_xclk_pnp = 9;
i2cdrv_ht16k33 = 10;
i2cdrv_ina219 = 11;
i2cdrv_si7021 = 12; // also si7013,si7020,htu21
i2cdrv_tca9555 = 13;
i2cdrv_ssd1306 = 14;
i2cdrv_sh1106 = 15;
i2cdrv_ads1013 = 16;
i2cdrv_ads1014 = 17;
i2cdrv_ads1015 = 18;
i2cdrv_ads1113 = 19;
i2cdrv_ads1114 = 20;
i2cdrv_ads1115 = 21;
i2cdrv_ina220 = 22;
i2cdrv_aht10 = 23; // fixed address
i2cdrv_aht20 = 24; // fixed address
i2cdrv_aht30 = 25; // fixed address
}
bitset i2cdev_t
{
// Use addr=0 (general call address) to scan all potential addresses.
// Address range scan is not supported by all drivers and may
// result in misdetections.
uint8 addr : 0..6;
i2cdrv_t drv : 8..15;
uint8 intr : 16..21; // 0 = no interrupt, >0: (intr-1)=gpio
}
message I2CConfig
{
uint8 port = 1 [ default = 0 ];
sint8 sda = 2 [ unset = -1 ];
sint8 scl = 3 [ unset = -1 ];
unsigned freq = 4 [ default = 100000 ];
bool xpullup = 5 [ unset = false ]; // have external pull-ups
repeated i2cdev_t devices = 6 [ packed = true, ifdef=CONFIG_I2C_XDEV ];
}
message HcSr04Config
{
sint8 trigger = 1 [ unset = -1 ];
sint8 echo = 2 [ unset = -1 ];
string name = 3;
}
bitset ledcfg_t
{
bool active_high : 0;
bool open_drain : 1;
bool init_high : 2;
}
message LedConfig
{
sint8 gpio = 1 [ unset = -1 ];
ledcfg_t config = 2 [ default = 0 ];
string name = 3;
sint8 pwm_ch = 4 [ unset = -1 ];
}
message OneWireConfig
{
sint8 gpio = 1 [ unset = -1 ];
// pull-up the gpio - internal pull-up is too weak for most applications!
bool pullup = 2 [ unset = false ];
sint8 power = 3 [ unset = -1 ];
}
message UartConfig
{
sint8 port = 1 [ unset = -1 ];
sint8 tx_gpio = 2 [ unset = -1 ];
sint8 rx_gpio = 3 [ unset = -1 ];
sint8 cts_gpio = 4 [ unset = -1 ];
sint8 rts_gpio = 5 [ unset = -1 ];
}
message AdcChannel
{
string name = 1;
// ADC1 or ADC2 - ADC2 cannot be used with WiFi started
uint8 unit = 2 [ unset = 0 ];
// valid channels: 0-9
sint8 ch = 3 [ unset = -1 ];
// adc_atten_t: 0 = 0dB, 1=2,5dB, 2=6dB, 3=11dB
uint8 atten = 4 [ default = 0 ];
// 0: manual sampling, >0: sampling interval in ms
uint16 interval = 5 [ unset = 0 ];
uint8 window = 6 [ unset = 0 ];
/*
// sliding window requires window-size*2 bytes additional RAM
bool slide = 7 [ default = false ];
*/
float scale = 8 [ default = 1 ];
float offset = 9 [ default = 0 ];
string dim = 10;
}
message AdcConfig
{
// esp8266: set name to enable
// esp32: not used
string adc_name = 1;
// adc_width_t: 0=9bit .. 3=12bit
uint8 adc1_bits = 2 [ default = 0 ];
uint8 adc2_bits = 3 [ default = 0 ];
// esp8266 only (adc_mode_t: TOUT_MODE=0, VDD_MODE=1)
uint8 mode = 4;
uint8 clk_div = 5;
// name of hall sensor
string hall_name = 6 [ ifdef=CONFIG_IDF_TARGET_ESP32 ];
repeated AdcChannel channels = 7; // ESP8266: used=false
}
bitset gpiocfg_t
{
// xio_cfg_io_t: 0=in, 1=out, 2=od
uint8 mode : 0..1;
// xio_cfg_intr_t: 0=disable, 1=rise, 2=fall, 3=edges, 4=lvl0, 5=lvl1
uint8 intrtype : 2..4;
bool setinit : 5;
bool initlvl : 6;
bool pullup : 7;
bool pulldown : 8;
// TODO:
// bool cap_freq_r2r : 9; // determine frequence rise-to-rise
}
message GpioConfig
{
string name = 1;
sint8 gpio = 2 [ unset = -1 ];
// bit 1,0: gpio_mode_t: input, output, output_od
// bit 4..2: gpio_int_type_t
// {0=none, 1=pos edge, 2=neg edge, 3=both edges}
// {4=lolevel, 5=hilevel}: currently unused
// bit 5: set initial level
// bit 6: init level
// bit 7: pull-up enable
// bit 8: pull-down enable
// bit 9: frequency rise2rise instead of fall2fall
gpiocfg_t config = 3;
}
enum disp_t
{
dt_none = 0;
// segment displays
dt_sd_7seg = 1;
dt_sd_14seg = 2;
// LCD text displays
dt_pcf8574_hd44780u = 16;
// monochrom displays
dt_ssd1306 = 32; // I2C
dt_ssd1309 = 33; // 4-wire spi
dt_sh1106 = 34;
// TFT displays
dt_ili9341 = 64;
}
message DisplayConfig
{
disp_t type = 1 [ unset = dt_none ];
unsigned options = 2 [ default = 0 ];
unsigned maxx = 3;
unsigned maxy = 4 [ default = 1 ];
}
enum spidrv_t
{
spidrv_invalid = 0;
spidrv_sx1276 = 1;
spidrv_ssd1309 = 2;
spidrv_ili9341 = 3;
spidrv_xpt2046 = 4;
spidrv_sdcard = 5;
}
bitset spiopt_t
{
bool txlsbfirst : 0;
bool rxlsbfirst : 1;
bool mosi_as_miso : 2; // 3-wire mode, MOSI is also used as MiSO
bool positive_cs : 3;
bool full_duplex : 4;
bool pol_hi : 5;
bool pha_hi : 6;
}
message SpiDeviceConfig
{
spidrv_t drv = 1 [ unset = spidrv_invalid ];
sint8 cs = 2 [ unset = -1 ]; // chip select
sint8 intr = 3 [ unset = -1 ]; // interrupt
sint8 reset = 4 [ unset = -1 ]; // reset
sint8 cd = 5 [ unset = -1 ]; // command/data
unsigned freq = 6 [ unset = 0 ]; // frequency in kHz, 0=use default
}
message SpiBusConfig
{
sint8 host = 1 [ unset = -1 ];
sint8 mosi = 2 [ unset = -1 ];
sint8 miso = 3 [ unset = -1 ]; // miso=-1 for 3-wire
sint8 sclk = 4 [ unset = -1 ]; // -1 = cs as clock
sint8 wp = 5 [ unset = -1 ];
sint8 hold = 6 [ unset = -1 ];
spiopt_t options = 7;
sint8 dma = 8 [ unset = -1 ];
repeated SpiDeviceConfig devices = 9;
}
message GpioCluster
{
string name = 1;
uint8 base = 2 [ unset = 0 ];
uint8 numio = 3 [ unset = 0 ];
sint8 int_a = 4 [ unset = -1 ];
sint8 int_b = 5 [ unset = -1 ];
}
message Hlw8012Config
{
// string name = 1;
sint8 sel = 2 [ unset = -1 ];
sint8 cf = 3 [ unset = -1 ];
sint8 cf1 = 4 [ unset = -1 ];
}
message SX1276Config
{
sint8 dio0 = 1 [ unset = -1 ];
sint8 dio1 = 2 [ unset = -1 ];
sint8 dio2 = 3 [ unset = -1 ];
sint8 dio3 = 4 [ unset = -1 ];
sint8 dio4 = 5 [ unset = -1 ];
sint8 dio5 = 6 [ unset = -1 ];
}
message Melody
{
string name = 1;
repeated fixed16 tones = 2; // sequence of freq [Hz], time [ms] pairs
}
message BuzzerConfig
{
sint8 gpio = 1 [ unset = -1 ];
repeated Melody melodies = 2;
}
message HardwareConfig
{
fixed32 magic = 0; // should always be set to 0xAE54EDCB
// core hardware
SystemConfig system = 1;
repeated UartConfig uart = 3;
AdcConfig adc = 4;
TouchpadConfig touchpad = 5 [ ifdef=CONFIG_TOUCHPAD ];
repeated TouchChannelConfig tp_channel = 6 [ ifdef=CONFIG_TOUCHPAD ];
repeated GpioConfig gpios = 7;
repeated SpiBusConfig spibus = 8 [ ifdef=CONFIG_SPI ];
// direct gpio drivers
repeated ButtonConfig button = 16 [ ifdef=CONFIG_BUTTON ];
repeated RelayConfig relay = 17 [ ifdef=CONFIG_RELAY ];
repeated LedConfig led = 18 [ ifdef=CONFIG_LEDS ];
BuzzerConfig buzzer = 19 [ ifdef=CONFIG_BUZZER ];
// direct attached devices
Hlw8012Config hlw8012 = 20 [ ifdef=CONFIG_HLW8012 ];
// high level applicaton drivers
Max7219Config max7219 = 32 [ ifdef=CONFIG_MAX7219 ]; // for 7-segment clock
Tlc5947Config tlc5947 = 33 [ ifdef=CONFIG_TLC5947 ]; // for nightsky LEDs
repeated Ws2812bConfig ws2812b = 34 [ ifdef=CONFIG_RGBLEDS ]; // for ws2812b LED strips
DhtConfig dht = 35 [ ifdef=CONFIG_DHT ];
repeated I2CConfig i2c = 36 [ ifdef=CONFIG_I2C ];
repeated HcSr04Config hcsr04 = 37 [ ifdef=CONFIG_HCSR04 ];
OneWireConfig onewire = 38 [ ifdef=CONFIG_ONEWIRE ];
SX1276Config sx1276 = 39 [ ifdef=CONFIG_SX1276 ];
repeated GpioCluster iocluster = 40 [ ifdef=CONFIG_IOEXTENDERS ];
DisplayConfig display = 50 [ ifdef=CONFIG_DISPLAY ];
}