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.
static sdi12timer_t timerDelta(sdi12timer_t now, sdi12timer_t previous) -> sdi12timer_t
Calculate elapsed timer ticks using the counter's physical modulus.

Constructors, destructors, conversion operators

SDI12Timer()
Construct a new SDI12Timer.
sdi12timer_t SDI12TimerRead(void) -> sdi12timer_t
A function to read the timer value, where a multi-step function is needed.

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.

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.


static sdi12timer_t SDI12Timer::timerDelta(sdi12timer_t now, sdi12timer_t previous)

Calculate elapsed timer ticks using the counter's physical modulus.

Parameters
now The current timer count.
previous The earlier timer count.
Returns sdi12timer_t Elapsed ticks, including one counter rollover.

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