Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
52 #define RTC9_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
62 #define RTC9_RETVAL uint8_t
65 #define RTC9_INIT_ERROR 0xFF
72 #define RTC9_SLAVE_ADDRESS 0x68
79 #define RTC9_REG_PART_SECONDS 0x00
80 #define RTC9_REG_SECONDS 0x01
81 #define RTC9_REG_MINUTES 0x02
82 #define RTC9_REG_CENTURY_HOURS 0x03
83 #define RTC9_REG_DAY 0x04
84 #define RTC9_REG_DATE 0x05
85 #define RTC9_REG_MONTH 0x06
86 #define RTC9_REG_YEAR 0x07
87 #define RTC9_REG_DIGITAL_CALIBRATION 0x08
88 #define RTC9_REG_WATCHDOG 0x09
89 #define RTC9_REG_ALARM1_MONTH 0x0A
90 #define RTC9_REG_ALARM1_DATE 0x0B
91 #define RTC9_REG_ALARM1_HOUR 0x0C
92 #define RTC9_REG_ALARM1_MINUTES 0x0D
93 #define RTC9_REG_ALARM1_SECONDS 0x0E
94 #define RTC9_REG_FLAGS 0x0F
95 #define RTC9_REG_TIMER_VALUE 0x10
96 #define RTC9_REG_TIMER_CONTROL 0x11
97 #define RTC9_REG_ANALOG_CALIBRATION 0x12
98 #define RTC9_REG_SQW 0x13
99 #define RTC9_REG_ALARM2_MONTH 0x14
100 #define RTC9_REG_ALARM2_DATE 0x15
101 #define RTC9_REG_ALARM2_HOUR 0x16
102 #define RTC9_REG_ALARM2_MINUTES 0x17
103 #define RTC9_REG_ALARM2_SECONDS 0x18
110 #define RTC9_FLAG_WATCHDOG_ENABLE 0x80
111 #define RTC9_FLAG_WATCHDOG_DISABLE 0x00
112 #define RTC9_FLAG_ALARM_1_ENABLE 0x40
113 #define RTC9_FLAG_ALARM_1_DISABLE 0x00
114 #define RTC9_FLAG_ALARM_2_ENABLE 0x20
115 #define RTC9_FLAG_ALARM_2_DISABLE 0x00
116 #define RTC9_FLAG_BATTERY_LOW_ENABLE 0x10
117 #define RTC9_FLAG_BATTERY_LOW_DISABLE 0x00
118 #define RTC9_FLAG_TIMER_ENABLE 0x08
119 #define RTC9_FLAG_TIMER_DISABLE 0x00
120 #define RTC9_FLAG_OSCILATOR_FAIL_ENABLE 0x04
121 #define RTC9_FLAG_OSCILATOR_FAIL_DISABLE 0x00
128 #define RTC9_TIMER_CONTROL_ENABLE 0x80
129 #define RTC9_TIMER_CONTROL_DISABLE 0x00
130 #define RTC9_TIMER_CONTROL_NORMAL_INT 0x00
131 #define RTC9_TIMER_CONTROL_FREE_RUNNING_INT 0x40
132 #define RTC9_TIMER_CONTROL_INT_OUT_ASSERT 0x20
133 #define RTC9_TIMER_CONTROL_INT_OUT_DE_ASSERT 0x00
134 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_244p1_US 0x00
135 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_15p6_MS 0x01
136 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_1_S 0x02
137 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_60_S 0x03
144 #define RTC9_ANALOG_CALIBRATION_OSCILATOR_FREQ_NORMAL 0x00
145 #define RTC9_ANALOG_CALIBRATION_OSCILATOR_FREQ_SLOW 0x27
146 #define RTC9_ANALOG_CALIBRATION_OSCILATOR_FREQ_FAST 0xC8
153 #define RTC9_DIGITAL_CALIBRATION_POSITIVE 0x20
154 #define RTC9_DIGITAL_CALIBRATION_NEGATIVE 0x00
155 #define RTC9_DIGITAL_CALIBRATION_FREQ_TEST_ENABLED 0x40
156 #define RTC9_DIGITAL_CALIBRATION_FREQ_TEST_DISABLED 0x00
157 #define RTC9_DIGITAL_CALIBRATION_VALUE_0 0x00
158 #define RTC9_DIGITAL_CALIBRATION_VALUE_1 0x01
159 #define RTC9_DIGITAL_CALIBRATION_VALUE_2 0x02
160 #define RTC9_DIGITAL_CALIBRATION_VALUE_3 0x03
161 #define RTC9_DIGITAL_CALIBRATION_VALUE_4 0x04
162 #define RTC9_DIGITAL_CALIBRATION_VALUE_5 0x05
163 #define RTC9_DIGITAL_CALIBRATION_VALUE_6 0x06
164 #define RTC9_DIGITAL_CALIBRATION_VALUE_7 0x07
165 #define RTC9_DIGITAL_CALIBRATION_VALUE_8 0x08
166 #define RTC9_DIGITAL_CALIBRATION_VALUE_9 0x09
167 #define RTC9_DIGITAL_CALIBRATION_VALUE_10 0x0A
168 #define RTC9_DIGITAL_CALIBRATION_VALUE_11 0x0B
169 #define RTC9_DIGITAL_CALIBRATION_VALUE_12 0x0C
170 #define RTC9_DIGITAL_CALIBRATION_VALUE_13 0x0D
171 #define RTC9_DIGITAL_CALIBRATION_VALUE_14 0x0E
172 #define RTC9_DIGITAL_CALIBRATION_VALUE_15 0x0F
173 #define RTC9_DIGITAL_CALIBRATION_VALUE_16 0x10
174 #define RTC9_DIGITAL_CALIBRATION_VALUE_17 0x11
175 #define RTC9_DIGITAL_CALIBRATION_VALUE_18 0x12
176 #define RTC9_DIGITAL_CALIBRATION_VALUE_19 0x13
177 #define RTC9_DIGITAL_CALIBRATION_VALUE_20 0x14
178 #define RTC9_DIGITAL_CALIBRATION_VALUE_21 0x15
179 #define RTC9_DIGITAL_CALIBRATION_VALUE_22 0x16
180 #define RTC9_DIGITAL_CALIBRATION_VALUE_23 0x17
181 #define RTC9_DIGITAL_CALIBRATION_VALUE_24 0x18
182 #define RTC9_DIGITAL_CALIBRATION_VALUE_25 0x19
183 #define RTC9_DIGITAL_CALIBRATION_VALUE_26 0x1A
184 #define RTC9_DIGITAL_CALIBRATION_VALUE_27 0x1B
185 #define RTC9_DIGITAL_CALIBRATION_VALUE_28 0x1C
186 #define RTC9_DIGITAL_CALIBRATION_VALUE_29 0x1D
187 #define RTC9_DIGITAL_CALIBRATION_VALUE_30 0x1E
188 #define RTC9_DIGITAL_CALIBRATION_VALUE_31 0x1F
195 #define RTC9_WATCHDOG_OSCILATOR_FAIL_ENABLED 0x80
196 #define RTC9_WATCHDOG_OSCILATOR_FAIL_DISABLED 0x00
197 #define RTC9_WATCHDOG_RESOLUTION_1_DIV_16_SEC 0x00
198 #define RTC9_WATCHDOG_RESOLUTION_1_DIV_4_SEC 0x01
199 #define RTC9_WATCHDOG_RESOLUTION_1_SEC 0x02
200 #define RTC9_WATCHDOG_RESOLUTION_4_SEC 0x03
207 #define RTC9_MONTH_JANUARY 0x01
208 #define RTC9_MONTH_FEBRUARY 0x02
209 #define RTC9_MONTH_MARCH 0x03
210 #define RTC9_MONTH_APRIL 0x04
211 #define RTC9_MONTH_MAY 0x05
212 #define RTC9_MONTH_JUNE 0x06
213 #define RTC9_MONTH_JULY 0x07
214 #define RTC9_MONTH_AUGUST 0x08
215 #define RTC9_MONTH_SEPTEMBER 0x09
216 #define RTC9_MONTH_OCTOBER 0x0A
217 #define RTC9_MONTH_NOVEMBER 0x0B
218 #define RTC9_MONTH_DECEMBER 0x0C
225 #define RTC9_DAY_SUNDAY 0x01
226 #define RTC9_DAY_MONDAY 0x02
227 #define RTC9_DAY_TUESDAY 0x03
228 #define RTC9_DAY_WEDNESDAY 0x04
229 #define RTC9_DAY_THURSDAY 0x05
230 #define RTC9_DAY_FRIDAY 0x06
231 #define RTC9_DAY_SATURDAY 0x07
rtc9_get_date_t get_date
Definition: rtc9.h:287
void rtc9_set_date(rtc9_t *ctx, rtc9_set_data_t *set_data)
Set new date.
uint8_t min
Definition: rtc9.h:253
uint8_t day_of_week
Definition: rtc9.h:244
void rtc9_set_alarm_date(rtc9_t *ctx, uint8_t day, uint8_t month, uint8_t year)
Set new ALARM 1 date.
void rtc9_wakeup(rtc9_t *ctx)
Wake-up process.
char * rtc9_current_month(uint8_t month)
Month in the String format.
pin_name_t sda
Definition: rtc9.h:299
RTC9_RETVAL rtc9_init(rtc9_t *ctx, rtc9_cfg_t *cfg)
Initialization function.
uint8_t day_of_week
Definition: rtc9.h:262
uint8_t month
Definition: rtc9.h:245
uint8_t slave_address
Definition: rtc9.h:283
void rtc9_generic_read(rtc9_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t year
Definition: rtc9.h:246
uint8_t part_sec
Definition: rtc9.h:255
uint8_t month
Definition: rtc9.h:263
pin_name_t scl
Definition: rtc9.h:298
void rtc9_cfg_setup(rtc9_cfg_t *cfg)
Config Object Initialization function.
void rtc9_set_alarm_time(rtc9_t *ctx, uint8_t hour, uint8_t min, uint8_t sec)
Set new ALARM 1 time - 24 hour format.
void rtc9_hardware_reset(rtc9_t *ctx)
Hardware reset.
void rtc9_software_reset(rtc9_t *ctx)
Software reset.
uint8_t day
Definition: rtc9.h:261
void rtc9_generic_write(rtc9_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
char * rtc9_current_day_of_week(uint8_t day_of_week)
Day of Week in the String format.
pin_name_t rst
Definition: rtc9.h:303
Click configuration structure definition.
Definition: rtc9.h:295
i2c_master_t i2c
Definition: rtc9.h:279
uint32_t i2c_speed
Definition: rtc9.h:307
void rtc9_read_flag_status(rtc9_t *ctx, uint8_t *read_data)
Reads FLAGS regiter.
void rtc9_get_time(rtc9_t *ctx, rtc9_get_time_t *get_time)
Get new time - 24 hour format.
void rtc9_get_date(rtc9_t *ctx, rtc9_get_date_t *get_data)
Get new date.
uint8_t i2c_address
Definition: rtc9.h:308
rtc9_set_data_t set_data
Definition: rtc9.h:285
uint8_t year
Definition: rtc9.h:264
#define RTC9_RETVAL
Definition: rtc9.h:62
void rtc9_set_time(rtc9_t *ctx, uint8_t hour, uint8_t min, uint8_t sec)
Set new time - 24 hour format.
uint8_t hour
Definition: rtc9.h:252
uint8_t sec
Definition: rtc9.h:254
rtc9_get_time_t get_time
Definition: rtc9.h:286
uint8_t day
Definition: rtc9.h:243
Click ctx object definition.
Definition: rtc9.h:272
digital_out_t rst
Definition: rtc9.h:275