MySensors Library & Examples  2.3.2
MyHwTeensy3.h
1 
28 #ifndef MyHwTeensy3_h
29 #define MyHwTeensy3_h
30 
31 #include <SPI.h>
32 #include "util/atomic.h"
33 
34 #ifdef __cplusplus
35 #include <Arduino.h>
36 #endif
37 
38 #define CRYPTO_LITTLE_ENDIAN
39 
40 #ifndef MY_SERIALDEVICE
41 #define MY_SERIALDEVICE Serial
42 #endif
43 
44 #ifndef MY_DEBUGDEVICE
45 #define MY_DEBUGDEVICE MY_SERIALDEVICE
46 #endif
47 
48 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
49 #define RNG_CR_GO_MASK 0x1u
50 #define RNG_CR_HA_MASK 0x2u
51 #define RNG_CR_INTM_MASK 0x4u
52 #define RNG_CR_CLRI_MASK 0x8u
53 #define RNG_CR_SLP_MASK 0x10u
54 #define RNG_SR_OREG_LVL_MASK 0xFF00u
55 #define RNG_SR_OREG_LVL_SHIFT 8
56 #define RNG_SR_OREG_LVL(x) (((uint32_t)(((uint32_t)(x))<<RNG_SR_OREG_LVL_SHIFT))&RNG_SR_OREG_LVL_MASK)
57 #define SIM_SCGC6_RNGA ((uint32_t)0x00000200)
58 #endif
59 
60 // Define these as macros to save valuable space
61 #define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
62 #define hwDigitalRead(__pin) digitalReadFast(__pin)
63 #define hwPinMode(__pin, __value) pinMode(__pin, __value)
64 #define hwMillis() millis()
65 #define hwGetSleepRemaining() (0ul)
66 
67 void hwRandomNumberInit(void);
68 bool hwInit(void);
69 void hwWatchdogReset(void);
70 void hwReboot(void);
71 
72 // Teensy 3.x implements avr-libc EEPROM API
73 #define hwReadConfig(__pos) eeprom_read_byte((const uint8_t *)__pos)
74 #define hwWriteConfig(__pos, __val) eeprom_update_byte((uint8_t *)__pos, (uint8_t)__val)
75 #define hwReadConfigBlock(__buf, __pos, __length) eeprom_read_block((void *)__buf, (const void *)__pos, (uint32_t)__length)
76 #define hwWriteConfigBlock(__buf, __pos, __length) eeprom_update_block((const void *)__buf, (void *)__pos, (uint32_t)__length)
77 
78 // SOFTSPI
79 #ifdef MY_SOFTSPI
80 #error Soft SPI is not available on this architecture!
81 #endif
82 #define hwSPI SPI
83 
84 
85 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
86 #define MY_HW_HAS_GETENTROPY
87 #endif
88 
89 #define MY_CRITICAL_SECTION ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
90 
91 #endif