root / proj / src / libs / rtc / include / rtc.h @ 399
History | View | Annotate | Download (4.31 KB)
1 |
#ifndef RTC_H_INCLUDED
|
---|---|
2 |
#define RTC_H_INCLUDED
|
3 |
|
4 |
/**
|
5 |
* @defgroup rtc rtc
|
6 |
* @ingroup libs
|
7 |
* @brief RTC (Real-Time Clock) module.
|
8 |
*
|
9 |
* @{
|
10 |
*/
|
11 |
|
12 |
#include <stdint.h> |
13 |
|
14 |
// RTC IRQ Line
|
15 |
|
16 |
#define RTC_IRQ 8 /* @brief RTC IRQ Line */ |
17 |
|
18 |
/**
|
19 |
* @brief Subscribes RTC Interrupts
|
20 |
* @param interrupt_bit Bit of Interrupt Vector that will be set when RTC Interrupt is pending
|
21 |
* @param interrupt_id RTC Interrupt ID to specify the RTC Interrupt in other calls
|
22 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
23 |
* @see {_ERRORS_H_::errors}
|
24 |
*/
|
25 |
int (subscribe_rtc_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
26 |
|
27 |
/**
|
28 |
* @brief Read RTC register.
|
29 |
* @param reg Register to read from
|
30 |
* @param data Pointer to save read data
|
31 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
32 |
* @see {_ERRORS_H_::errors}
|
33 |
*/
|
34 |
int (rtc_read_register)(uint32_t reg, uint8_t *data);
|
35 |
/**
|
36 |
* @brief Write RTC register.
|
37 |
* @param reg Register to write to
|
38 |
* @param data Data to write in register
|
39 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
40 |
* @see {_ERRORS_H_::errors}
|
41 |
*/
|
42 |
int (rtc_write_register)(uint32_t reg, uint8_t data);
|
43 |
|
44 |
/**
|
45 |
* @brief Reads seconds register.
|
46 |
*
|
47 |
* @param sec Address to store value
|
48 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
49 |
* @see {_ERRORS_H_::errors}
|
50 |
*/
|
51 |
int rtc_read_sec(uint8_t *sec);
|
52 |
|
53 |
/**
|
54 |
* @brief Reads minutes register.
|
55 |
*
|
56 |
* @param min Address to store value
|
57 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
58 |
* @see {_ERRORS_H_::errors}
|
59 |
*/
|
60 |
int rtc_read_min(uint8_t *min);
|
61 |
|
62 |
/**
|
63 |
* @brief Reads hours register.
|
64 |
*
|
65 |
* @param hour Address to store value
|
66 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
67 |
* @see {_ERRORS_H_::errors}
|
68 |
*/
|
69 |
int rtc_read_hour(uint8_t *hour);
|
70 |
/**
|
71 |
* @brief Reads weekday register.
|
72 |
*
|
73 |
* @param hour Address to store value
|
74 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
75 |
* @see {_ERRORS_H_::errors}
|
76 |
*/
|
77 |
int (rtc_read_weekday)(uint8_t *weekday);
|
78 |
/**
|
79 |
* @brief Reads day register.
|
80 |
*
|
81 |
* @param hour Address to store value
|
82 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
83 |
* @see {_ERRORS_H_::errors}
|
84 |
*/
|
85 |
int (rtc_read_day)(uint8_t *day);
|
86 |
/**
|
87 |
* @brief Reads month register.
|
88 |
*
|
89 |
* @param hour Address to store value
|
90 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
91 |
* @see {_ERRORS_H_::errors}
|
92 |
*/
|
93 |
int (rtc_read_month)(uint8_t *month);
|
94 |
/**
|
95 |
* @brief Reads year register.
|
96 |
*
|
97 |
* @param hour Address to store value
|
98 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
99 |
* @see {_ERRORS_H_::errors}
|
100 |
*/
|
101 |
int (rtc_read_year)(uint8_t *year);
|
102 |
|
103 |
/**
|
104 |
* @brief Checks if there's an update in progress.
|
105 |
* @return The value of the flag UIP, or ERROR_CODE if error occurs.
|
106 |
*/
|
107 |
int (rtc_check_update)(void); |
108 |
|
109 |
/**
|
110 |
* @brief Enables/Disables interrupts on update.
|
111 |
* @param on zero to disable, any other value to enable
|
112 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
113 |
*/
|
114 |
int (rtc_set_updates_int)(int on); |
115 |
|
116 |
/**
|
117 |
* @brief Reads time from RTC.
|
118 |
* @param time Pointer to array of 3 bytes to store the information about time (hours, minutes, seconds)
|
119 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
120 |
*/
|
121 |
int (rtc_read_time)(uint8_t *time);
|
122 |
|
123 |
/**
|
124 |
* @brief Reads date from RTC.
|
125 |
* @param date Pointer to array of 4 bytes to store the information about date (year, month, day, weekday)
|
126 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
|
127 |
*/
|
128 |
int (rtc_read_date)(uint8_t *date);
|
129 |
/// @brief RTC Interrupt Handler
|
130 |
void rtc_ih();
|
131 |
|
132 |
/**
|
133 |
* @}
|
134 |
*/
|
135 |
|
136 |
#endif /* end of include guard: RTC_H_INCLUDED */ |