📄 smartclock.h
字号:
#define RTC_DAY 2831155200 // Number of RTC counts in a day
#define RTC_HOUR 117964800 // Number of RTC counts in an hour
#define RTC_MINUTE 1966080 // Number of RTC counts in a minute
#define RTC_SECOND 32768 // Number of RTC counts in a second
#define RTC_HUNDRETH 328 // Number of RTC counts in a hundreth
// of a second (rounded up)
// used with UU32 (b0 is least-significant byte)
# define b0 3
# define b1 2
# define b2 1
# define b3 0
//-----------------------------------------------------------------------------
// Indirect RTC Register Addresses
//-----------------------------------------------------------------------------
#define CAPTURE0 0x00 // RTC address of CAPTURE0 register
#define CAPTURE1 0x01 // RTC address of CAPTURE1 register
#define CAPTURE2 0x02 // RTC address of CAPTURE2 register
#define CAPTURE3 0x03 // RTC address of CAPTURE3 register
#define CAPTURE4 0x04 // RTC address of CAPTURE4 register
#define CAPTURE5 0x05 // RTC address of CAPTURE5 register
#define RTC0CN 0x06 // RTC address of RTC0CN register
#define RTC0XCN 0x07 // RTC address of RTC0XCN register
#define ALARM0 0x08 // RTC address of ALARM0 register
#define ALARM1 0x09 // RTC address of ALARM1 register
#define ALARM2 0x0A // RTC address of ALARM2 register
#define ALARM3 0x0B // RTC address of ALARM3 register
#define ALARM4 0x0C // RTC address of ALARM4 register
#define ALARM5 0x0D // RTC address of ALARM5 register
// Initial settings for time and date
// Current date setting would be September 22, 2008
#define YEAR_INIT 9 // Output will be 2000+YEAR_INIT
#define DAY_INIT 79 // Valid range of DAY_INIT is 1-366
#define HOUR_INIT 22 // Valid range of HOUR_INIT is 0-23
#define MINUTE_INIT 21 // Valid range of MINUTE_INIT is 0-59
#define SECOND_INIT 55 // Valid range of SECOND_INIT is 0-59
// Convert initial time settings to RTC alarm counts. Used in RTC_Init()
// (note: '\' is in following line to allow code to continue on next line)
#define TIME_INIT ((RTC_HOUR*HOUR_INIT)+(RTC_MINUTE*MINUTE_INIT)+ \
(RTC_SECOND*SECOND_INIT))
typedef unsigned char U8;
typedef unsigned int U16;
typedef unsigned long U32;
typedef signed char S8;
typedef signed int S16;
typedef signed long S32;
typedef union UU16
{
U16 U16;
S16 S16;
U8 U8[2];
S8 S8[2];
} UU16;
typedef union UU32
{
U32 U32;
S32 S32;
UU16 UU16[2];
U16 U16[2];
S16 S16[2];
U8 U8[4];
S8 S8[4];
} UU32;
typedef struct DATE_INFO {
INT16U years;
INT16U output_month;
INT16U days;
INT16U output_days;
INT16U hours;
INT16U minutes;
INT16U seconds;
INT16U hundreths;
} DATE_INFO;
extern void Init_DateINFO(void);
extern U8 Leap_Year (U16 year);
extern void RTC_Init (void);
extern void RTC_Write (U8 reg, U8 value);
extern INT8U RTC_Read (U8 reg);
extern void Compute_Month (U16* month, U16* days, U16 total, U16 year);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -