LevelMeter-Display  2.0
An ultrasonic Level Meter for Stormwater Cisterns
Functions | Variables
dcf77.c File Reference

Routines for setting and adjusting the Real Time Clock via DCF77. More...

Include dependency graph for dcf77.c:

Functions

static uint8_t BitsSet (uint8_t b)
 Counts the Number of 1-Bits in a Byte. More...
 
void DCF77int (void)
 Interrupt Handler for DCF77. More...
 
int32_t GetDCFdiff ()
 Gets the difference between DCF and RTC in seconds. Positive means RTC is late. More...
 
static uint8_t GetPinState (void)
 Returns the logical Signal of the DCF Pin. More...
 
void Invalidate ()
 Invalidates Reception Variables, so Reception is started from scratch. More...
 
static void PushBit (uint8_t b)
 Stores a Bit in the next Position of the Telegram. More...
 

Variables

static uint8_t bitcnt
 counts the bits in the telegram More...
 
int32_t DCFdiff
 Difference to RTC in Seconds, positive means RTC is late. More...
 
bool DCFInSync
 True when a valid Telegram has been received. More...
 
static uint8_t dcfTicks
 counts 10ms-intervals between the edges of the signal More...
 
uint8_t hour
 The Hour Value received. More...
 
static bool lastPinState
 The Pin State at last Interrupt. More...
 
uint8_t min
 The Minute Value received. More...
 
static bool minpulseReceived
 Did we receive a valid Minute Pulse (missing Pulse at second 59)? More...
 
static const uint8_t ms100max =14
 The maximum Pulse Width to be recognized as 100ms. More...
 
static const uint8_t ms100min =6
 The minimum Pulse Width to be recognized as 100ms. More...
 
static const uint8_t ms200max =23
 The maximum Pulse Width to be recognized as 200ms. More...
 
static const uint8_t ms200min =15
 The minimum Pulse Width to be recognized as 200ms. More...
 
static const uint8_t mspause59max =220
 The maximum Pulse Width to be recognized as a missing pulse. More...
 
static const uint8_t mspause59min =150
 The minimum Pulse Width to be recognized as a missing pulse. More...
 
static const uint8_t xorMask =0
 set to 0 or DCF77_PINMASK to invert signal More...
 

Detailed Description

Routines for setting and adjusting the Real Time Clock via DCF77.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Function Documentation

◆ BitsSet()

static uint8_t BitsSet ( uint8_t  b)
static

Counts the Number of 1-Bits in a Byte.

Parameters
bThe Byte
Returns
The Number of Bits set

Referenced by DCF77int().

Here is the caller graph for this function:

◆ DCF77int()

void DCF77int ( void  )

Interrupt Handler for DCF77.

Has to be called from 10ms interrupt

References bitcnt, BitsSet(), dcfTicks, DFLAG_DCF77, dFlags, GetPinState(), hour, hprintf_P(), Invalidate(), lastPinState, min, minpulseReceived, ms100max, ms100min, ms200max, ms200min, mspause59max, mspause59min, PushBit(), and RTCsync().

Referenced by ISR().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDCFdiff()

int32_t GetDCFdiff ( )

Gets the difference between DCF and RTC in seconds. Positive means RTC is late.

References DCFdiff.

Referenced by CmdStat().

Here is the caller graph for this function:

◆ GetPinState()

static uint8_t GetPinState ( void  )
inlinestatic

Returns the logical Signal of the DCF Pin.

This function honors the invDCF77 configuration variable and returns a polarity corrected value of the DCF77 receive signal.

Returns
0 for pause, 1 for pulse

References config, DCF77_PIN, DCF77_PINMASK, confStruct_t::invDCF77, LEDBlueOff(), and LEDBlueOn().

Referenced by DCF77int().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Invalidate()

void Invalidate ( )

Invalidates Reception Variables, so Reception is started from scratch.

References bitcnt, DCFInSync, dcfTicks, hour, min, minpulseReceived, RTC_NORMAL, and RTCAdj.

Referenced by DCF77int(), InitDCF77(), and PushBit().

Here is the caller graph for this function:

◆ PushBit()

static void PushBit ( uint8_t  b)
static

Stores a Bit in the next Position of the Telegram.

References bitcnt, DFLAG_DCF77, dFlags, hour, hprintf_P(), Invalidate(), and min.

Referenced by DCF77int().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ bitcnt

uint8_t bitcnt
static

counts the bits in the telegram

Referenced by DCF77int(), Invalidate(), and PushBit().

◆ DCFdiff

int32_t DCFdiff

Difference to RTC in Seconds, positive means RTC is late.

Referenced by GetDCFdiff(), and RTCsync().

◆ DCFInSync

bool DCFInSync

True when a valid Telegram has been received.

Referenced by CmdSetTime(), CmdStat(), Invalidate(), RTCsync(), and ShowScreen().

◆ dcfTicks

uint8_t dcfTicks
static

counts 10ms-intervals between the edges of the signal

Referenced by DCF77int(), and Invalidate().

◆ hour

uint8_t hour

The Hour Value received.

Referenced by DCF77int(), Invalidate(), PushBit(), and RTCsync().

◆ lastPinState

bool lastPinState
static

The Pin State at last Interrupt.

Referenced by DCF77int().

◆ min

uint8_t min

The Minute Value received.

Referenced by CmdSetTime(), DCF77int(), Invalidate(), PushBit(), and RTCsync().

◆ minpulseReceived

bool minpulseReceived
static

Did we receive a valid Minute Pulse (missing Pulse at second 59)?

Referenced by DCF77int(), and Invalidate().

◆ ms100max

const uint8_t ms100max =14
static

The maximum Pulse Width to be recognized as 100ms.

Referenced by DCF77int().

◆ ms100min

const uint8_t ms100min =6
static

The minimum Pulse Width to be recognized as 100ms.

Referenced by DCF77int().

◆ ms200max

const uint8_t ms200max =23
static

The maximum Pulse Width to be recognized as 200ms.

Referenced by DCF77int().

◆ ms200min

const uint8_t ms200min =15
static

The minimum Pulse Width to be recognized as 200ms.

Referenced by DCF77int().

◆ mspause59max

const uint8_t mspause59max =220
static

The maximum Pulse Width to be recognized as a missing pulse.

Referenced by DCF77int().

◆ mspause59min

const uint8_t mspause59min =150
static

The minimum Pulse Width to be recognized as a missing pulse.

Referenced by DCF77int().

◆ xorMask

const uint8_t xorMask =0
static

set to 0 or DCF77_PINMASK to invert signal