MySensors Library & Examples  2.3.2
MyHwESP8266.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 #ifndef MyHwESP8266_h
20 #define MyHwESP8266_h
21 
22 #include <SPI.h>
23 #include <ESP8266WiFi.h>
24 #include <WiFiUdp.h>
25 #include <EEPROM.h>
26 
27 #ifdef __cplusplus
28 #include <Arduino.h>
29 #endif
30 
31 #define CRYPTO_LITTLE_ENDIAN
32 
33 #ifndef MY_SERIALDEVICE
34 #define MY_SERIALDEVICE Serial
35 #endif
36 
37 #ifndef MY_DEBUGDEVICE
38 #define MY_DEBUGDEVICE MY_SERIALDEVICE
39 #endif
40 
41 #define EEPROM_size (1024)
42 
43 // Define these as macros to save valuable space
44 #define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)
45 #define hwDigitalRead(__pin) digitalRead(__pin)
46 #define hwPinMode(__pin, __value) pinMode(__pin, __value)
47 #define hwWatchdogReset() wdt_reset()
48 #define hwReboot() ESP.restart()
49 #define hwMillis() millis()
50 // The use of randomSeed switch to pseudo random number. Keep hwRandomNumberInit empty
51 #define hwRandomNumberInit()
52 #define hwGetSleepRemaining() (0ul)
53 
54 bool hwInit(void);
55 void hwReadConfigBlock(void *buf, void *addr, size_t length);
56 void hwWriteConfigBlock(void *buf, void *addr, size_t length);
57 void hwWriteConfig(const int addr, uint8_t value);
58 uint8_t hwReadConfig(const int addr);
59 ssize_t hwGetentropy(void *__buffer, size_t __length);
60 //#define MY_HW_HAS_GETENTROPY
61 
62 // SOFTSPI
63 #ifdef MY_SOFTSPI
64 #error Soft SPI is not available on this architecture!
65 #endif
66 #define hwSPI SPI
67 
68 
73 static __inline__ void __psRestore(const uint32_t *__s)
74 {
75  xt_wsr_ps( *__s );
76 }
77 
78 #ifndef DOXYGEN
79 #define MY_CRITICAL_SECTION for ( uint32_t __psSaved __attribute__((__cleanup__(__psRestore))) = xt_rsil(15), __ToDo = 1; __ToDo ; __ToDo = 0 )
80 #endif /* DOXYGEN */
81 
82 #endif // #ifdef ARDUINO_ARCH_ESP8266