DIY Logging Volt/Ampmeter
rtc.h
Go to the documentation of this file.
1
/***************************************************************************/
/**
2
* @file rtc.h
3
* @brief RTC functionality for high-precision logging voltage/current meter.
4
* @version 1.0
5
* @author Brecht Van Eeckhoudt
6
*
7
* ******************************************************************************
8
*
9
* @section Versions
10
*
11
* @li v1.0: Initial version.
12
*
13
* ******************************************************************************
14
*
15
* @section License
16
*
17
* **Copyright (C) 2021 - Brecht Van Eeckhoudt**
18
*
19
* This program is free software: you can redistribute it and/or modify
20
* it under the terms of the **GNU General Public License** as published by
21
* the Free Software Foundation, either **version 3** of the License, or
22
* (at your option) any later version.
23
*
24
* This program is distributed in the hope that it will be useful,
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
* GNU General Public License for more details.
28
*
29
* *A copy of the GNU General Public License can be found in the `LICENSE`
30
* file along with this source code.*
31
*
32
******************************************************************************/
33
34
35
/* Include guards prevent multiple inclusions of the same header */
36
#ifndef __RTC_H_
37
#define __RTC_H_
38
39
40
/* Includes necessary for this header file */
41
#include <stdint.h>
/* (u)intXX_t */
42
43
44
/* Public definitions */
45
46
/** Unix epoch time in Julian calendar (UnixTime = 00:00:00 01.01.1970 => JDN = 2440588) */
47
#define JULIAN_DATE_BASE 2440588
48
49
/** Struct to store the RTC data */
50
extern
struct
RTC_dateTime_t
51
{
52
uint8_t
firstUpdate
;
/* 1 = first boot, hour, min, sec need to be converted to chars */
53
uint8_t
latest
;
/* Index (0 or 1) of most recent value */
54
55
uint8_t
hour0
;
56
uint8_t
hour1
;
57
char
charHour
[3];
/* Max 2 char + NULL termination = 3 */
58
uint8_t
newCharHour
;
/* 1 = display needs updating */
59
60
uint8_t
min0
;
61
uint8_t
min1
;
62
char
charMin
[3];
/* Max 2 char + NULL termination = 3 */
63
uint8_t
newCharMin
;
64
65
uint8_t
sec0
;
66
uint8_t
sec1
;
67
char
charSec
[3];
/* Max 2 char + NULL termination = 3 */
68
uint8_t
newCharSec
;
69
70
uint8_t
day0
;
71
uint8_t
day1
;
72
char
charDay
[3];
/* Max 2 char + NULL termination = 3 */
73
uint8_t
newCharDay
;
74
75
uint8_t
wday
;
76
77
uint8_t
month0
;
78
uint8_t
month1
;
79
char
charMonth
[3];
/* Max 2 char + NULL termination = 3 */
80
uint8_t
newCharMonth
;
81
82
uint16_t
year0
;
83
uint16_t
year1
;
84
char
charYear
[5];
/* Max 4 char + NULL termination = 5 */
85
uint8_t
newCharYear
;
86
}
rtc
;
87
88
89
/* Public prototypes */
90
void
RTC_Init
(
void
);
91
void
readFromRTC
(
void
);
92
void
writeToRTC
(
void
);
93
94
95
#endif
/* __RTC_H_ */
RTC_dateTime_t::hour0
uint8_t hour0
Definition:
rtc.h:55
RTC_dateTime_t::min1
uint8_t min1
Definition:
rtc.h:61
rtc
struct RTC_dateTime_t rtc
RTC_dateTime_t
Definition:
rtc.h:50
RTC_dateTime_t::newCharMonth
uint8_t newCharMonth
Definition:
rtc.h:80
RTC_dateTime_t::charMonth
char charMonth[3]
Definition:
rtc.h:79
RTC_dateTime_t::charHour
char charHour[3]
Definition:
rtc.h:57
RTC_dateTime_t::year0
uint16_t year0
Definition:
rtc.h:82
RTC_dateTime_t::newCharMin
uint8_t newCharMin
Definition:
rtc.h:63
RTC_dateTime_t::charSec
char charSec[3]
Definition:
rtc.h:67
RTC_dateTime_t::charDay
char charDay[3]
Definition:
rtc.h:72
RTC_dateTime_t::newCharDay
uint8_t newCharDay
Definition:
rtc.h:73
RTC_dateTime_t::newCharYear
uint8_t newCharYear
Definition:
rtc.h:85
RTC_dateTime_t::min0
uint8_t min0
Definition:
rtc.h:60
RTC_dateTime_t::month0
uint8_t month0
Definition:
rtc.h:77
RTC_dateTime_t::newCharHour
uint8_t newCharHour
Definition:
rtc.h:58
RTC_dateTime_t::year1
uint16_t year1
Definition:
rtc.h:83
RTC_dateTime_t::charMin
char charMin[3]
Definition:
rtc.h:62
RTC_dateTime_t::charYear
char charYear[5]
Definition:
rtc.h:84
RTC_dateTime_t::sec1
uint8_t sec1
Definition:
rtc.h:66
writeToRTC
void writeToRTC(void)
Function to update the RTC values according to the data in the struct.
Definition:
rtc.c:319
RTC_dateTime_t::newCharSec
uint8_t newCharSec
Definition:
rtc.h:68
RTC_dateTime_t::day0
uint8_t day0
Definition:
rtc.h:70
RTC_dateTime_t::sec0
uint8_t sec0
Definition:
rtc.h:65
RTC_dateTime_t::latest
uint8_t latest
Definition:
rtc.h:53
RTC_dateTime_t::day1
uint8_t day1
Definition:
rtc.h:71
readFromRTC
void readFromRTC(void)
Function to update the RTC data in the struct.
Definition:
rtc.c:309
RTC_dateTime_t::wday
uint8_t wday
Definition:
rtc.h:75
RTC_dateTime_t::hour1
uint8_t hour1
Definition:
rtc.h:56
RTC_dateTime_t::month1
uint8_t month1
Definition:
rtc.h:78
RTC_dateTime_t::firstUpdate
uint8_t firstUpdate
Definition:
rtc.h:52
RTC_Init
void RTC_Init(void)
Function to initialize the Real Time Clock.
Definition:
rtc.c:97
STM32F103C8T6_powermeter-interface
Core
Inc
rtc.h
Generated on Mon Dec 13 2021 16:18:48 for DIY Logging Volt/Ampmeter by
1.8.17