SDI12Timer class

The class used to define the processor timer for the SDI-12 serial emulation.

Public static functions

static uint16_t mul8x8to16(uint8_t x, uint8_t y) -> uint16_t
static method for getting a 16-bit value from the multiplication of 2 8-bit values
static uint16_t bitTimes(sdi12timer_t dt) -> uint16_t
static method for calculating the number of bit-times that have elapsed between interrupts.

Constructors, destructors, conversion operators

SDI12Timer()
Construct a new SDI12Timer.

Public functions

void configSDI12TimerPrescale(void)
Set the processor timer prescaler such that the 10 bits of an SDI-12 character are divided into the rollover time of the timer.
void resetSDI12TimerPrescale(void)
Reset the processor timer prescaler to whatever it was prior to being adjusted for this library.
sdi12timer_t SDI12TimerRead(void) -> sdi12timer_t
A function to read the timer value, where a multi-step function is needed.

Function documentation

static uint16_t SDI12Timer::mul8x8to16(uint8_t x, uint8_t y)

static method for getting a 16-bit value from the multiplication of 2 8-bit values

Parameters
x The first 8 bit integer
y The second 8 bit integer
Returns uint16_t The result of the multiplication, as a 16 bit integer.

static uint16_t SDI12Timer::bitTimes(sdi12timer_t dt)

static method for calculating the number of bit-times that have elapsed between interrupts.

Parameters
dt The current value of the timer
Returns uint16_t The number of bit times that have passed at 1200 baud.

Adds a rxWindowWidth fudge factor to the time difference to get the number of ticks, and then multiplies the fudged ticks by the number of bits per tick. Uses the number of bits per tick shifted up by 2^10 and then shifts the result down by the same amount to compensate for the fact that the number of bits per tick is a decimal the timestamp is only an 8-bit integer.


sdi12timer_t SDI12Timer::SDI12TimerRead(void)

A function to read the timer value, where a multi-step function is needed.

Returns sdi12timer_t sdi12timer_t The current timer value