rtc.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 namespace eez {
22 namespace psu {
23 namespace rtc {
24 
25 static const uint8_t RD_CONTROL_1 = 0B10010000;
26 static const uint8_t WR_CONTROL_1 = 0B00010000;
27 static const uint8_t RD_CONTROL_2 = 0B10010001;
28 static const uint8_t WR_CONTROL_2 = 0B00010001;
29 
30 static const uint8_t RD_SECONDS = 0B10010010;
31 static const uint8_t WR_SECONDS = 0B00010010;
32 static const uint8_t RD_MINUTES = 0B10010011;
33 static const uint8_t WR_MINUTES = 0B00010011;
34 static const uint8_t RD_HOURS = 0B10010100;
35 static const uint8_t WR_HOURS = 0B00010100;
36 
37 static const uint8_t RD_DAYS = 0B10010101;
38 static const uint8_t WR_DAYS = 0B00010101;
39 static const uint8_t RD_WEEKDAYS = 0B10010110;
40 static const uint8_t WR_WEEKDAYS = 0B00010110;
41 static const uint8_t RD_MONTHS = 0B10010111;
42 static const uint8_t WR_MONTHS = 0B00010111;
43 static const uint8_t RD_YEARS = 0B10011000;
44 static const uint8_t WR_YEARS = 0B00011000;
45 
46 static const uint8_t RD_CLKOUT = 0B10011101;
47 static const uint8_t WR_CLKOUT = 0B00011101;
48 
49 static const uint8_t CONTROL_1_VALUE = 0B00001000;
50 static const uint8_t CONTROL_2_VALUE = 0B00000000;
51 
52 extern psu::TestResult g_testResult;
53 
54 void init();
55 bool test();
56 
57 bool readDate(uint8_t &year, uint8_t &month, uint8_t &day);
58 bool writeDate(uint8_t year, uint8_t month, uint8_t day);
59 
60 bool readTime(uint8_t &hour, uint8_t &minute, uint8_t &second);
61 bool writeTime(uint8_t hour, uint8_t minute, uint8_t second);
62 
63 bool readDateTime(uint8_t &year, uint8_t &month, uint8_t &day, uint8_t &hour, uint8_t &minute, uint8_t &second);
64 bool writeDateTime(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);
65 
66 }
67 }
68 } // namespace eez::psu::rtc
Namespace for the everything from the EEZ.
Definition: actions.cpp:41