forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

jinlicong
2024-05-24 1360095f8d64cf607d333d2fc7fd1dcd81d1bd7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef _EXTERN_RTC_H_
#define _EXTERN_RTC_H_
 
#include "define_all.h" 
 
 
//ÍⲿRTCÖжÏIO
#define  EXT_RTC_INT_PORT     GPIOD
#define  EXT_RTC_INT_PIN      GPIO_Pin_6    //  P3.2    IIC SCA ÐźÅ
 
 
 
//    <<< Use Configuration Wizard in Context Menu >>>
 
//     <h> ÍⲿRTC¼Ä´æÆ÷ÉèÖà   
//     <o> ¶¨Ê±Æ÷¼ÆÊýÆ÷0£¨È¡Öµ·¶Î§0~255£©
//    <i> bit0 = 1 bit1 = 2 bit3 = 4 ......bit7 = 128
//     <0-255>
        #define TIMER_COUNTER_0 0
        
//     <o> ¶¨Ê±Æ÷¼ÆÊýÆ÷1£¨È¡Öµ·¶Î§0£¬256~3840£©
//    <i> bit0 = 256 bit1 = 512 bit3 = 1024 bit3 = 2048
//     <0=>0 <1=>256 <2=>512 <3=>768 <4=>1024 <5=>1280 <6=>1536 <7=>1792 
//    <8=>2048 <9=>2304 <10=>2560 <11=>2816 <12=>3072 <13=>3328 <14=>3584 <15=>3840
        #define TIMER_COUNTER_1 0
        
//     <h> À©Õ¹¹¦ÄÜ£¨È磺ʱÖÓÔ´ÉèÖúͶ¨Ê±Æ÷¸üÐÂÆô¶¯µÈ£©
//     <o> ¶¨Ê±Æ÷ÖжÏÖÜÆÚ£¨Ê±ÖÓÔ´£©
//     <0=>4096Hz <0x01=>64Hz <0x02=>Sec Updata <0x03=>Min Updata
        #define EXTENSION_TIMER_SELECT 0x02
        
//     <o> FOUTƵÂÊÉèÖã¨ÎÞÓã©
//     <0=>32768Hz <0x04=>1024Hz <0x08=>1Hz <0x0C=>32768_1Hz
        #define FOUT_FRE_SELECT 0x0
        
//     <o> ¶¨Ê±Æ÷Æô¶¯±ê־λ
//     <0=>¹Ø±Õ <0x10=>Æô¶¯
        #define TIMER_EN 0x00
        
//     <o> ¸üÐÂÖÐ¶ÏÆô¶¯±ê־λ
//     <0=>Sec¸üÐÂÆô¶¯ <0x20=>Min¸üÐÂÆô¶¯
        #define UPDATA_INTER_SELECT 0x0        
 
//     <o> ¾¯¸æÆô¶¯±ê־λ
//     <0=>¹Ø±Õ
        #define ALARM_BIT_FLAG 0    
        
//     <o> ²âÊÔ±ê־λ£¨Ä¬ÈÏΪ0£©
//     <0=>0
        #define TEST_BIT_FLAG 0            
//    </h>
//     <o> FLAG¹¦ÄÜ£¨ÎÞÓã¬Ä¬ÈÏΪ0£©
//  <0=>0
        #define FLAG_REG    0
        
//     <h> ¿ØÖƹ¦ÄÜ£¨È磺¶¨Ê±Æ÷ÖжÏÉèÖúÍζȲ¹³¥µÈ£©
//     <o> ¸´Î»¹¦ÄÜ£¨Ä¬ÈÏΪ0£©
//  <0x0=>0
        #define RESET_BIT_FLAG    0x0
 
//     <o> ¾¯¸æÖжϹ¦ÄÜ
//  <0x0=>¹Ø±Õ
        #define ALARM_BIT_EN    0x0
 
//     <o> ¶¨Ê±Æ÷ÖжϹ¦ÄÜ
//  <0x0=>¹Ø±Õ <0x10=>Æô¶¯
        #define TIMER_BIT_FLAG    0x00
        
//     <o> ¸üÐÂÖжϹ¦ÄÜ
//  <0x0=>¹Ø±Õ <0x20=>Æô¶¯
        #define UPDATA_BIT_FLAG    0x000000        
 
//     <o> Î¶Ȳ¹³¥¹¦ÄÜ
//  <0x0=>0.5S <0x40=>2.0S <0x80=>10S <0xC0=>30S 
        #define TEMP_BIT_FLAG    0x0000040
//     </h> 
 
//     </h>
//    <<< end of configuration section >>>
 
 
#define RX8025_WRITE_ADDR                    0x64
#define RX8025_READ_ADDR                    0x65
 
 
 
 
 
#pragma pack(1)
typedef struct
{
    uint8_t     second;
    uint8_t     minute;
    uint8_t     hour;
    uint8_t     week;
    uint8_t         day;
    uint8_t     month;
    uint16_t     year;
}CALENDAR_TIME_T;//BCD
 
 
 
typedef struct
{
    uint8_t year;    //Ä꣬BCD Âë 00~99
    uint8_t month;    //Ô£¬BCD Âë 01~12
    uint8_t day;    //ÈÕ£¬BCD Âë 01~31
    uint8_t hour;    //ʱ£¬BCD Âë 00~23
    uint8_t min;    //·Ö£¬BCD Âë 00~59
    uint8_t sec;    //Ã룬BCD Âë 00~59
}sClockBCD;
 
 
 
 
#pragma pack()
 
void RTC_GPIO_Init(void);
 
void Set_Extern_Rtc_Time(uint16_t year,uint8_t month,uint8_t day,uint8_t week,uint8_t hour,uint8_t min,uint8_t sec);
ErrorStatus Get_Extern_Rtc_Time(__IO sClockBCD * calendar_p);
 
void Set_Rtc_UpdataInterrupt(void);
 
extern __IO sClockBCD sys_clockBCD_g;
 
 
ErrorStatus TimeEffectJudgm(const sClockBCD TimeBCD);
 
#endif