Enc C Reference¶
Defines
-
HDC2021_TEMPRH
¶ Last character of the URL version string if the URL contains both temperature and relative humidity measurands.
-
HDC2021_TEMPONLY
¶ Last character of the URL version string if the URL contains only temperature measurands.
-
ENDSTOP_BYTE
¶ Last character of the endstop. Must be URL safe according to RFC 1738.
-
BATV_RESETCAUSE
(BATV, RSTC)¶ Macro for creating a 16-bit batv_resetcause value from 8-bit CODEC_FEAT_30 and CODEC_SPEC_16 values.
Enums
Functions
-
void
fram_write_enable
(void) Enable writes to FRAM. Should be defined in the processor-specific cuplTag project.
-
void
fram_write_disable
(void) Disable writes to FRAM. Should be defined in the processor-specific cuplTag project.
-
static bool
one_reading_per_sample
(void)¶
-
static void
incr_loopcounter
(void)¶ Update loop counter and battery voltage in the preamble status field.
Calls a function to measure battery voltage, increases loopcount and clears the battery reset field. These data are base64 encoded and written to EEPROM. ndef_writepreamble overwrites the bufferred circular buffer blocks so these must be read again after with demi_restore.
-
static void
set_elapsed
(unsigned int minutes)¶ Update the endmarker of the endstop with elapsed time in minutes.
- Parameters
minutes – Minutes elapsed since the previous sample.
-
static void
set_pair
(pair_t *pair, int rd0, int rd1)¶ Write one pair.
- Parameters
pair – Pointer to the pair that will be modified.
rd0 – Reading 0 (12 bits).
rd1 – Reading 1 (12 bits).
-
static void
set_rd1
(pair_t *pair, int rd1)¶ Overwrite reading1 in a pair This is used when the format stipulates one reading per pair (see CODEC_FEAT_42).
- Parameters
pair – Pointer to the pair that will be modified.
rd1 – Reading 1 (12 bits).
-
unsigned int
enc_getbatv
(void)¶ Get battery voltage from the status field. This is a value from 0-255. Step size increases exponentially. 255 corresponds to 1V5. 0 is infinity.
-
void
enc_init
(unsigned int resetcause, bool err, unsigned int batv)¶ Initialise the encoder state machine. Writes the.
- Parameters
resetcause – 16-bit status value.
err – Sets an error condition where data will not be logged to the URL circular buffer.
batv – Battery voltage from ADC (not in mv).
-
void
enc_setelapsed
(unsigned int minutes)¶ Update the base64 encoded endstop and write it to the tag.
- Parameters
minutes – Minutes elapsed since the previous sample.
-
int
enc_pushsample
(int rd0, int rd1)¶ Push a sample containing up to two readings onto the circular buffer.
- Parameters
rd0 – First reading in the sample e.g. temperature.
rd1 – Second reading in the sample (optional) e.g. relative humidity.
- Returns
1 if the cursor has moved from the end to the start and data are being overwritten. Otherwise 0.
Variables
-
int
overwriting
= 0¶
-
unsigned int
npairs
= 0¶ Number of base64 encoded pairs in the circular buffer, starting from the endstop and counting backwards.
-
pairbufstate_t
state
= pairbuf_initial¶ Pair buffer write state.
-
struct
stat_t
¶
-
struct
endstop_t
¶ Public Members
-
char
markerb64
[4]¶ End-stop marker comprised of base64 encoded minutes since the previous sample and ENDSTOP_BYTE
-
char
-
struct
endmarker_t
¶