libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
rtc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Adrian "asie" Siekierka
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 *
17 * 2. Altered source versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software.
19 *
20 * 3. This notice may not be removed or altered from any source distribution.
21 */
22
26
27#ifndef LIBWS_RTC_H_
28#define LIBWS_RTC_H_
29
30#include "../ports.h"
31
36
37#define WS_RTC_MONTH_AMPM 0x80
38#define WS_RTC_MONTH_AM 0x00
39#define WS_RTC_MONTH_PM 0x80
40
41#define WS_RTC_STATUS_POWER_LOST 0x80
42#define WS_RTC_STATUS_12_HOUR 0x00
43#define WS_RTC_STATUS_24_HOUR 0x40
44#define WS_RTC_STATUS_INTAE 0x20
45#define WS_RTC_STATUS_INTME 0x08
46#define WS_RTC_STATUS_INTFE 0x02
47#define WS_RTC_STATUS_INT_OFF 0
48#define WS_RTC_STATUS_INT_FREQ_STEADY (WS_RTC_STATUS_INTFE)
49#define WS_RTC_STATUS_INT_MINUTE_EDGE (WS_RTC_STATUS_INTME)
50#define WS_RTC_STATUS_INT_MINUTE_STEADY (WS_RTC_STATUS_INTME | WS_RTC_STATUS_INTFE)
51#define WS_RTC_STATUS_INT_ALARM (WS_RTC_STATUS_INTAE)
52
53#ifndef __ASSEMBLER__
54
55#include <stdbool.h>
56#include <stdint.h>
57
58typedef struct {
59 uint8_t year;
60 uint8_t month;
61 uint8_t date;
62 uint8_t day;
64
65typedef struct {
66 uint8_t hour;
67 uint8_t minute;
68 uint8_t second;
70
75
76int16_t ws_rtc_low_read_byte(uint16_t timeout);
77bool ws_rtc_low_write_byte(uint8_t value, uint16_t timeout);
78bool ws_rtc_low_write_ctrl(uint8_t value, uint16_t timeout);
79
80// TODO: high-level commands
81
83
84#endif /* __ASSEMBLER__ */
85
86#endif /* LIBWS_RTC_H_ */
bool ws_rtc_low_write_byte(uint8_t value, uint16_t timeout)
bool ws_rtc_low_write_ctrl(uint8_t value, uint16_t timeout)
int16_t ws_rtc_low_read_byte(uint16_t timeout)
uint8_t date
Definition rtc.h:61
uint8_t month
Definition rtc.h:60
uint8_t day
Definition rtc.h:62
uint8_t year
Definition rtc.h:59
ws_rtc_time_t time
Definition rtc.h:73
ws_rtc_date_t date
Definition rtc.h:72
uint8_t second
Definition rtc.h:68
uint8_t minute
Definition rtc.h:67
uint8_t hour
Definition rtc.h:66