MySensors Library & Examples  2.3.2
MyHwESP32.h
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2019 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  *
19  * Arduino core for ESP32: https://github.com/espressif/arduino-esp32
20  *
21  * MySensors ESP32 implementation, Copyright (C) 2017-2018 Olivier Mauti <[email protected]>
22  *
23  * Radio wiring ESP32(Node32s): RF24, RFM69, RFM95:
24  *
25  * | IO | RF24 | RFM69 | RFM95 |
26  * |------|------|-------|-------|
27  * | MOSI | 23 | 23 | 23 |
28  * | MISO | 19 | 19 | 19 |
29  * | SCK | 18 | 18 | 18 |
30  * | CSN | 5 | 5 | 5 |
31  * | CE | 17 | - | - |
32  * | RST | - | 17 | 17 |
33  * | IRQ | 16* | 16 | 16 |
34  * * = optional
35  *
36  */
37 
38 #ifndef MyHwESP32_h
39 #define MyHwESP32_h
40 
41 #include <WiFi.h>
42 #include "EEPROM.h"
43 #include <SPI.h>
44 
45 #ifdef __cplusplus
46 #include <Arduino.h>
47 #endif
48 
49 #define CRYPTO_LITTLE_ENDIAN
50 
51 #ifndef MY_SERIALDEVICE
52 #define MY_SERIALDEVICE Serial
53 #endif
54 
55 #ifndef MY_DEBUGDEVICE
56 #define MY_DEBUGDEVICE MY_SERIALDEVICE
57 #endif
58 
59 #ifndef MY_ESP32_TEMPERATURE_OFFSET
60 #define MY_ESP32_TEMPERATURE_OFFSET (0.0f)
61 #endif
62 
63 #ifndef MY_ESP32_TEMPERATURE_GAIN
64 #define MY_ESP32_TEMPERATURE_GAIN (1.0f)
65 #endif
66 
67 #define MY_EEPROM_SIZE 1024
68 
69 #define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)
70 #define hwDigitalRead(__pin) digitalRead(__pin)
71 #define hwPinMode(__pin, __value) pinMode(__pin, __value)
72 #define hwWatchdogReset()
73 #define hwReboot() ESP.restart()
74 #define hwMillis() millis()
75 #define hwMicros() micros()
76 #define hwRandomNumberInit() randomSeed(esp_random())
77 #define hwGetSleepRemaining() (0ul)
78 
79 bool hwInit(void);
80 void hwReadConfigBlock(void *buf, void *addr, size_t length);
81 void hwWriteConfigBlock(void *buf, void *addr, size_t length);
82 void hwWriteConfig(const int addr, uint8_t value);
83 uint8_t hwReadConfig(const int addr);
84 ssize_t hwGetentropy(void *__buffer, size_t __length);
85 #define MY_HW_HAS_GETENTROPY
86 
87 // SOFTSPI
88 #ifdef MY_SOFTSPI
89 #error Soft SPI is not available on this architecture!
90 #endif
91 #define hwSPI SPI
92 
93 
97 static __inline__ void __psRestore(const uint32_t *__s)
98 {
99  XTOS_RESTORE_INTLEVEL(*__s);
100 }
101 
102 #ifndef DOXYGEN
103 #define MY_CRITICAL_SECTION for ( uint32_t __psSaved __attribute__((__cleanup__(__psRestore))) = XTOS_DISABLE_ALL_INTERRUPTS, __ToDo = 1; __ToDo ; __ToDo = 0 )
104 #endif /* DOXYGEN */
105 
106 
107 #endif