Flipklok
 
Loading...
Searching...
No Matches
dcfReceive.h
Go to the documentation of this file.
1/*
2 * dcfReceive.h
3 *
4 * Created on: 21 mrt. 2025
5 */
6
7#ifndef DCFRECEIVE_H_
8#define DCFRECEIVE_H_
9
10#include <msp430.h>
11#include <stdbool.h>
12#include <stdint.h>
13#include "timer.h"
14
16unsigned int startTime;
18unsigned int endTime;
21#define bitArrayLength 58 // needs to be 58, but 10 for testing
22bool bitArray[60];
23
25
26
27#define bitTime0Sec 0.1 //normal 0.1 for testing 0.05
28#define bitTime1Sec 0.2 //normal 0.2 for testing 0.1
29#define bitTimeSyncSec 1.8
30#define bitTimeCyclesTresh 0.01
31
32//Correct casting
33//0
34#define bitTimeCycles0 ((clockFreq) * (bitTime0Sec))
35#define bitTimeCycles0Upper ((int)((bitTimeCycles0) + ((clockFreq) * (bitTimeCyclesTresh))))
36#define bitTimeCycles0Lower ((int)((bitTimeCycles0) - ((clockFreq) * (bitTimeCyclesTresh))))
37//1
38#define bitTimeCycles1 ((clockFreq) * (bitTime1Sec))
39#define bitTimeCycles1Upper ((int)((bitTimeCycles1) + ((clockFreq) * (bitTimeCyclesTresh))))
40#define bitTimeCycles1Lower ((int)((bitTimeCycles1) - ((clockFreq) * (bitTimeCyclesTresh))))
41//start of DCF77 message
42#define bitTimeCyclesSync ((unsigned int)(clockFreq * bitTimeSyncSec))
43#define bitTimeCyclesSyncUpper ((unsigned int)(bitTimeCyclesSync + (clockFreq * bitTimeCyclesTresh)))
44#define bitTimeCyclesSyncLower ((unsigned int)(bitTimeCyclesSync - (clockFreq * bitTimeCyclesTresh)))
45
46volatile unsigned int minuteDcfLast;
47volatile unsigned int hourDcfLast;
48
50
51
52unsigned int calculateBitTransmitTime(bool checkSyncStatus, unsigned int start, bool startDir, unsigned int stop, bool stopDir);
53bool bitValue(unsigned int bitTime);
54void storeBit(bool bit, unsigned int location);
56bool checkBitStream();
57void interruptDcf();
58
59#endif /* DCFRECEIVE_H_ */
volatile unsigned int hourDcfLast
Definition dcfReceive.h:47
bool countingDirectionEnd
Definition dcfReceive.h:19
bool bitValue(unsigned int bitTime)
Determine the bit value of the transmitted DCF77 bit and return it, gets called from interruptDcf()
Definition dcfReceive.c:154
bool countingDirectionStart
Definition dcfReceive.h:17
void storeBit(bool bit, unsigned int location)
Store the received DCF77 bit in the array, gets called from interruptDcf()
Definition dcfReceive.c:178
unsigned int startTime
Definition dcfReceive.h:16
uint32_t countDcf77Messages
Definition dcfReceive.h:49
volatile unsigned int minuteDcfLast
Definition dcfReceive.h:46
bool checkBitStream()
Checks if certain predetermined bits are 1 or 0 and if parity of minute and hour is correct,...
Definition dcfReceive.c:188
bool bitArray[60]
Definition dcfReceive.h:22
unsigned int calculateBitTransmitTime(bool checkSyncStatus, unsigned int start, bool startDir, unsigned int stop, bool stopDir)
Calculate the bit time of the DCF77 pulses, gets called from interruptDcf()
Definition dcfReceive.c:120
bool currentBit
Definition dcfReceive.h:20
bool toggleInterruptDcf
Definition dcfReceive.h:24
unsigned int endTime
Definition dcfReceive.h:18
void decodeBitStream2Seconds()
Decode the received DCF77 bitstream to a time, gets called from interruptDcf() Also ensure that the r...
Definition dcfReceive.c:262
bool interruptEdgeToggleDcf
Definition dcfReceive.h:15
void interruptDcf()
Time the DCF77 pulses gets called from pin interrupt port1ISR(void)
Definition dcfReceive.c:26