SDI12_boards.h file
This file defines the timing units needed for various Arduino boards.
Classes
- class SDI12Timer
- The class used to define the processor timer for the SDI-12 serial emulation.
Typedefs
- using sdi12timer_t = uint8_t
Defines
- #define ISR_MEM_ACCESS = IRAM_ATTR
- Defines a memory access location, if needed for the interrupts service routines.
- #define TIMER_IN_USE_STR = "Timer2"
- A string description of the timer to use.
- #define TIMER_INT_TYPE = uint8_t
- The integer type of the timer.
- #define TIMER_INT_SIZE = 8
- The size in bits of the C++ timer storage type.
- #define READTIME = TCNT2
- The function or macro used to read the clock timer value.
- #define PRESCALE_IN_USE = 1024
- The prescaler value in use.
- #define PRESCALE_IN_USE_STR = "16MHz/1024=15.625kHz"
- A string description of the prescaler in use.
- #define TICKS_PER_SECOND = 15625
- The number of clock ticks per second, after accounting for the prescaler.
- #define TIMER_COUNTER_BITS
- The number of physically implemented timer counter bits.
- #define TIMER_COUNTER_MASK = 0xFFU
- A mask for the physically implemented timer counter bits.
- #define TIMER_COUNTER_SPAN_MICROS = (((1ULL <<
- The selected timer counter's rollover interval in microseconds.
- #define RX_WINDOW_FUDGE
- A "fudge factor" to get the Rx to work well. It mostly works to ensure that uneven tick increments get rounded up.
- #define TICKS_PER_BIT = 13
- The number of "ticks" of the timer that occur within the timing of one bit at the SDI-12 baud rate of 1200 bits/second.
- #define BITS_PER_TICK_Q10 = 79
- The number of "ticks" of the timer per SDI-12 bit, shifted by 2^10.
Typedef documentation
Define documentation
#define ISR_MEM_ACCESS = IRAM_ATTR
Defines a memory access location, if needed for the interrupts service routines.
On espressif boards (ESP8266 and ESP32), the ISR must be stored in IRAM
#define RX_WINDOW_FUDGE
A "fudge factor" to get the Rx to work well. It mostly works to ensure that uneven tick increments get rounded up.
This is the width of the receive window before the expected bit boundary: SDI12Timer::(dt + RX_, so a level change may arrive up to RX_ ticks early and up to TICKS_ ticks late and still be counted in the correct bit. A value of half of TICKS_
Define SDI12_RX_WINDOW_FUDGE at build time to override the value selected for your board.
#define TICKS_PER_BIT = 13
The number of "ticks" of the timer that occur within the timing of one bit at the SDI-12 baud rate of 1200 bits/second.
15625 'ticks'/sec = 64 µs / 'tick' (1 sec/1200 bits) * (1 tick/64 µs) = 13.0208 ticks/bit
The 8-bit timer rolls over after 256 ticks, 19.66085 bits, or 16.38505 ms (256 ticks/roll-over) * (1 bit/13.0208 ticks) = 19.66085 bits (256 ticks/roll-over) * (1 sec/15625 ticks) = 16.38505 milliseconds
#define BITS_PER_TICK_Q10 = 79
The number of "ticks" of the timer per SDI-12 bit, shifted by 2^10.
1/(13.0208 ticks/bit) * 2^10 = 78.6432