Go to the documentation of this file.
42 #ifdef PREINIT_SUPPORTED
46 #ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 #include "drv_i2c_master.h"
66 #define RTC9_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
76 #define RTC9_RETVAL uint8_t
79 #define RTC9_INIT_ERROR 0xFF
86 #define RTC9_SLAVE_ADDRESS 0x68
93 #define RTC9_REG_PART_SECONDS 0x00
94 #define RTC9_REG_SECONDS 0x01
95 #define RTC9_REG_MINUTES 0x02
96 #define RTC9_REG_CENTURY_HOURS 0x03
97 #define RTC9_REG_DAY 0x04
98 #define RTC9_REG_DATE 0x05
99 #define RTC9_REG_MONTH 0x06
100 #define RTC9_REG_YEAR 0x07
101 #define RTC9_REG_DIGITAL_CALIBRATION 0x08
102 #define RTC9_REG_WATCHDOG 0x09
103 #define RTC9_REG_ALARM1_MONTH 0x0A
104 #define RTC9_REG_ALARM1_DATE 0x0B
105 #define RTC9_REG_ALARM1_HOUR 0x0C
106 #define RTC9_REG_ALARM1_MINUTES 0x0D
107 #define RTC9_REG_ALARM1_SECONDS 0x0E
108 #define RTC9_REG_FLAGS 0x0F
109 #define RTC9_REG_TIMER_VALUE 0x10
110 #define RTC9_REG_TIMER_CONTROL 0x11
111 #define RTC9_REG_ANALOG_CALIBRATION 0x12
112 #define RTC9_REG_SQW 0x13
113 #define RTC9_REG_ALARM2_MONTH 0x14
114 #define RTC9_REG_ALARM2_DATE 0x15
115 #define RTC9_REG_ALARM2_HOUR 0x16
116 #define RTC9_REG_ALARM2_MINUTES 0x17
117 #define RTC9_REG_ALARM2_SECONDS 0x18
124 #define RTC9_FLAG_WATCHDOG_ENABLE 0x80
125 #define RTC9_FLAG_WATCHDOG_DISABLE 0x00
126 #define RTC9_FLAG_ALARM_1_ENABLE 0x40
127 #define RTC9_FLAG_ALARM_1_DISABLE 0x00
128 #define RTC9_FLAG_ALARM_2_ENABLE 0x20
129 #define RTC9_FLAG_ALARM_2_DISABLE 0x00
130 #define RTC9_FLAG_BATTERY_LOW_ENABLE 0x10
131 #define RTC9_FLAG_BATTERY_LOW_DISABLE 0x00
132 #define RTC9_FLAG_TIMER_ENABLE 0x08
133 #define RTC9_FLAG_TIMER_DISABLE 0x00
134 #define RTC9_FLAG_OSCILATOR_FAIL_ENABLE 0x04
135 #define RTC9_FLAG_OSCILATOR_FAIL_DISABLE 0x00
142 #define RTC9_TIMER_CONTROL_ENABLE 0x80
143 #define RTC9_TIMER_CONTROL_DISABLE 0x00
144 #define RTC9_TIMER_CONTROL_NORMAL_INT 0x00
145 #define RTC9_TIMER_CONTROL_FREE_RUNNING_INT 0x40
146 #define RTC9_TIMER_CONTROL_INT_OUT_ASSERT 0x20
147 #define RTC9_TIMER_CONTROL_INT_OUT_DE_ASSERT 0x00
148 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_244p1_US 0x00
149 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_15p6_MS 0x01
150 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_1_S 0x02
151 #define RTC9_TIMER_CONTROL_TIMER_SOURCE_FREQ_60_S 0x03
158 #define RTC9_ANALOG_CALIBRATION_OSCILATOR_FREQ_NORMAL 0x00
159 #define RTC9_ANALOG_CALIBRATION_OSCILATOR_FREQ_SLOW 0x27
160 #define RTC9_ANALOG_CALIBRATION_OSCILATOR_FREQ_FAST 0xC8
167 #define RTC9_DIGITAL_CALIBRATION_POSITIVE 0x20
168 #define RTC9_DIGITAL_CALIBRATION_NEGATIVE 0x00
169 #define RTC9_DIGITAL_CALIBRATION_FREQ_TEST_ENABLED 0x40
170 #define RTC9_DIGITAL_CALIBRATION_FREQ_TEST_DISABLED 0x00
171 #define RTC9_DIGITAL_CALIBRATION_VALUE_0 0x00
172 #define RTC9_DIGITAL_CALIBRATION_VALUE_1 0x01
173 #define RTC9_DIGITAL_CALIBRATION_VALUE_2 0x02
174 #define RTC9_DIGITAL_CALIBRATION_VALUE_3 0x03
175 #define RTC9_DIGITAL_CALIBRATION_VALUE_4 0x04
176 #define RTC9_DIGITAL_CALIBRATION_VALUE_5 0x05
177 #define RTC9_DIGITAL_CALIBRATION_VALUE_6 0x06
178 #define RTC9_DIGITAL_CALIBRATION_VALUE_7 0x07
179 #define RTC9_DIGITAL_CALIBRATION_VALUE_8 0x08
180 #define RTC9_DIGITAL_CALIBRATION_VALUE_9 0x09
181 #define RTC9_DIGITAL_CALIBRATION_VALUE_10 0x0A
182 #define RTC9_DIGITAL_CALIBRATION_VALUE_11 0x0B
183 #define RTC9_DIGITAL_CALIBRATION_VALUE_12 0x0C
184 #define RTC9_DIGITAL_CALIBRATION_VALUE_13 0x0D
185 #define RTC9_DIGITAL_CALIBRATION_VALUE_14 0x0E
186 #define RTC9_DIGITAL_CALIBRATION_VALUE_15 0x0F
187 #define RTC9_DIGITAL_CALIBRATION_VALUE_16 0x10
188 #define RTC9_DIGITAL_CALIBRATION_VALUE_17 0x11
189 #define RTC9_DIGITAL_CALIBRATION_VALUE_18 0x12
190 #define RTC9_DIGITAL_CALIBRATION_VALUE_19 0x13
191 #define RTC9_DIGITAL_CALIBRATION_VALUE_20 0x14
192 #define RTC9_DIGITAL_CALIBRATION_VALUE_21 0x15
193 #define RTC9_DIGITAL_CALIBRATION_VALUE_22 0x16
194 #define RTC9_DIGITAL_CALIBRATION_VALUE_23 0x17
195 #define RTC9_DIGITAL_CALIBRATION_VALUE_24 0x18
196 #define RTC9_DIGITAL_CALIBRATION_VALUE_25 0x19
197 #define RTC9_DIGITAL_CALIBRATION_VALUE_26 0x1A
198 #define RTC9_DIGITAL_CALIBRATION_VALUE_27 0x1B
199 #define RTC9_DIGITAL_CALIBRATION_VALUE_28 0x1C
200 #define RTC9_DIGITAL_CALIBRATION_VALUE_29 0x1D
201 #define RTC9_DIGITAL_CALIBRATION_VALUE_30 0x1E
202 #define RTC9_DIGITAL_CALIBRATION_VALUE_31 0x1F
209 #define RTC9_WATCHDOG_OSCILATOR_FAIL_ENABLED 0x80
210 #define RTC9_WATCHDOG_OSCILATOR_FAIL_DISABLED 0x00
211 #define RTC9_WATCHDOG_RESOLUTION_1_DIV_16_SEC 0x00
212 #define RTC9_WATCHDOG_RESOLUTION_1_DIV_4_SEC 0x01
213 #define RTC9_WATCHDOG_RESOLUTION_1_SEC 0x02
214 #define RTC9_WATCHDOG_RESOLUTION_4_SEC 0x03
221 #define RTC9_MONTH_JANUARY 0x01
222 #define RTC9_MONTH_FEBRUARY 0x02
223 #define RTC9_MONTH_MARCH 0x03
224 #define RTC9_MONTH_APRIL 0x04
225 #define RTC9_MONTH_MAY 0x05
226 #define RTC9_MONTH_JUNE 0x06
227 #define RTC9_MONTH_JULY 0x07
228 #define RTC9_MONTH_AUGUST 0x08
229 #define RTC9_MONTH_SEPTEMBER 0x09
230 #define RTC9_MONTH_OCTOBER 0x0A
231 #define RTC9_MONTH_NOVEMBER 0x0B
232 #define RTC9_MONTH_DECEMBER 0x0C
239 #define RTC9_DAY_SUNDAY 0x01
240 #define RTC9_DAY_MONDAY 0x02
241 #define RTC9_DAY_TUESDAY 0x03
242 #define RTC9_DAY_WEDNESDAY 0x04
243 #define RTC9_DAY_THURSDAY 0x05
244 #define RTC9_DAY_FRIDAY 0x06
245 #define RTC9_DAY_SATURDAY 0x07
rtc9_get_date_t get_date
Definition: rtc9.h:301
void rtc9_set_date(rtc9_t *ctx, rtc9_set_data_t *set_data)
Set new date.
uint8_t min
Definition: rtc9.h:267
uint8_t day_of_week
Definition: rtc9.h:258
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:313
RTC9_RETVAL rtc9_init(rtc9_t *ctx, rtc9_cfg_t *cfg)
Initialization function.
uint8_t day_of_week
Definition: rtc9.h:276
uint8_t month
Definition: rtc9.h:259
uint8_t slave_address
Definition: rtc9.h:297
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:260
uint8_t part_sec
Definition: rtc9.h:269
uint8_t month
Definition: rtc9.h:277
pin_name_t scl
Definition: rtc9.h:312
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:275
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:317
Click configuration structure definition.
Definition: rtc9.h:309
i2c_master_t i2c
Definition: rtc9.h:293
uint32_t i2c_speed
Definition: rtc9.h:321
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:322
rtc9_set_data_t set_data
Definition: rtc9.h:299
uint8_t year
Definition: rtc9.h:278
#define RTC9_RETVAL
Definition: rtc9.h:76
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:266
uint8_t sec
Definition: rtc9.h:268
rtc9_get_time_t get_time
Definition: rtc9.h:300
uint8_t day
Definition: rtc9.h:257
Click ctx object definition.
Definition: rtc9.h:286
digital_out_t rst
Definition: rtc9.h:289