ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
fw_rtc.h
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef ___FW_RTC_H___
16#define ___FW_RTC_H___
17
18#include "fw_conf.h"
19#include "fw_types.h"
20
21typedef enum
22{
26
27#define RTC_SetRunState(__STATE__) SFRX_ASSIGN(RTCCR, 0, (__STATE__))
28#define RTC_SetClockSource(__SOURCE__) SFRX_ASSIGN(RTCCFG, 1, (__SOURCE__))
29#define RTC_ConfigClockApply() SFRX_SET(RTCCFG, 0)
30
34#define RTC_ClearAllInterrupts() (RTCIF = 0x00)
35#define RTC_IsAlarmInterrupt() (RTCIF & 0x80)
36#define RTC_ClearAlarmInterrupt() (RTCIF &= ~0x80)
37#define RTC_IsDayInterrupt() (RTCIF & 0x40)
38#define RTC_ClearDayInterrupt() (RTCIF &= ~0x40)
39#define RTC_IsHourInterrupt() (RTCIF & 0x20)
40#define RTC_ClearHourInterrupt() (RTCIF &= ~0x20)
41#define RTC_IsMinuteInterrupt() (RTCIF & 0x10)
42#define RTC_ClearMinuteInterrupt() (RTCIF &= ~0x10)
43#define RTC_IsSecondInterrupt() (RTCIF & 0x08)
44#define RTC_ClearSecondInterrupt() (RTCIF &= ~0x08)
45#define RTC_IsSecondDiv2Interrupt() (RTCIF & 0x04)
46#define RTC_ClearSecondDiv2Interrupt() (RTCIF &= ~0x04)
47#define RTC_IsSecondDiv8Interrupt() (RTCIF & 0x02)
48#define RTC_ClearSecondDiv8Interrupt() (RTCIF &= ~0x02)
49#define RTC_IsSecondDiv32Interrupt() (RTCIF & 0x01)
50#define RTC_ClearSecondDiv32Interrupt() (RTCIF &= ~0x01)
51
55#define RTC_ConfigAlarm(__HOUR__, __MIN__, __SEC__, __SSEC__) do { \
56 SFRX_ON(); \
57 ALAHOUR = (__HOUR__ & 0x1F); \
58 ALAMIN = (__MIN__ & 0x3F); \
59 ALASEC = (__SEC__ & 0x3F); \
60 ALASSEC = (__SSEC__ & 0x7F); \
61 SFRX_OFF(); \
62 } while(0)
66#define RTC_ConfigClock(__YEAR__, __MON__, __DAY__, __HOUR__, __MIN__, __SEC__, __SSEC__) do { \
67 SFRX_ON(); \
68 INIYEAR = (__YEAR__ & 0x7F); \
69 INIMONTH = (__MON__ & 0x0F); \
70 INIDAY = (__DAY__ & 0x1F); \
71 INIHOUR = (__HOUR__ & 0x1F); \
72 INIMIN = (__MIN__ & 0x3F); \
73 INISEC = (__SEC__ & 0x3F); \
74 INISSEC = (__SSEC__ & 0x7F); \
75 SFRX_OFF(); \
76 } while(0)
77
78
79#endif
RTC_ClockSource_t
Definition: fw_rtc.h:22
@ RTC_ClockSource_Internal
Definition: fw_rtc.h:24
@ RTC_ClockSource_External
Definition: fw_rtc.h:23