MySensors Library & Examples
2.3.2-62-ge298769
hal
architecture
AVR
MyHwMegaAVR.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-2022 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
20
#ifndef MyHwAVR_h
21
#define MyHwAVR_h
22
23
#include <avr/eeprom.h>
24
#include <avr/pgmspace.h>
25
#include <avr/sleep.h>
26
#include <avr/power.h>
27
#include <avr/interrupt.h>
28
#include <avr/io.h>
29
#include <avr/wdt.h>
30
#include <util/atomic.h>
31
#include <SPI.h>
32
33
// Fast IO driver
34
#include "drivers/DigitalWriteFast/digitalWriteFast.h"
35
36
// SOFTSPI
37
#ifdef MY_SOFTSPI
38
#include "
hal/architecture/AVR/drivers/DigitalIO/DigitalIO.h
"
39
#endif
40
41
#ifdef __cplusplus
42
#include <Arduino.h>
43
#endif
44
45
#define CRYPTO_LITTLE_ENDIAN
46
47
#ifndef MY_SERIALDEVICE
48
#define MY_SERIALDEVICE Serial
49
#endif
50
51
#ifndef MY_DEBUGDEVICE
52
#define MY_DEBUGDEVICE MY_SERIALDEVICE
53
#endif
54
55
// AVR temperature calibration reference: http://ww1.microchip.com/downloads/en/AppNotes/Atmel-8108-Calibration-of-the-AVRs-Internal-Temperature-Reference_ApplicationNote_AVR122.pdf
56
#ifndef MY_AVR_TEMPERATURE_OFFSET
57
#define MY_AVR_TEMPERATURE_OFFSET (324.31f)
58
#endif
59
60
#ifndef MY_AVR_TEMPERATURE_GAIN
61
#define MY_AVR_TEMPERATURE_GAIN (1.22f)
62
#endif
63
64
// Define these as macros to save valuable space
65
#define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
66
#define hwDigitalRead(__pin) digitalReadFast(__pin)
67
#define hwPinMode(__pin, __value) pinModeFast(__pin, __value)
68
69
void (*_beforeSleep)() ;
70
void (*_afterSleep)() ;
71
72
bool
hwInit(
void
);
73
void
pit_reset();
74
75
#define hwWatchdogReset() pit_reset()
76
#define hwReboot() wdt_enable(WDTO_15MS); while (1)
77
#define hwMillis() millis()
78
#define hwReadConfig(__pos) eeprom_read_byte((const uint8_t *)__pos)
79
#define hwWriteConfig(__pos, __val) eeprom_update_byte((uint8_t *)__pos, (uint8_t)__val)
80
#define hwReadConfigBlock(__buf, __pos, __length) eeprom_read_block((void *)__buf, (const void *)__pos, (uint32_t)__length)
81
#define hwWriteConfigBlock(__buf, __pos, __length) eeprom_update_block((const void *)__buf, (void *)__pos, (uint32_t)__length)
82
83
inline
void
hwRandomNumberInit(
void
);
84
85
#if defined(MY_SOFTSPI)
86
SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, 0>
hwSPI;
87
#else
88
#define hwSPI SPI
89
#endif
90
91
#ifndef DOXYGEN
92
#define MY_CRITICAL_SECTION ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
93
#endif
/* DOXYGEN */
94
95
#endif
DigitalIO.h
Fast Digital I/O functions.
SoftSPI
Fast software SPI.
Definition:
SoftSPI.h:50
Copyright (C) 2013-2019 Sensnology AB. Generated by
doxygen
1.8.17