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 RTC8_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.evi = MIKROBUS( mikrobus, MIKROBUS_CS ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
85#define RTC8_REG_SECONDS 0x00
86#define RTC8_REG_MINUTES 0x01
87#define RTC8_REG_HOURS 0x02
88#define RTC8_REG_WEEKDAY 0x03
89#define RTC8_REG_DATE 0x04
90#define RTC8_REG_MONTH 0x05
91#define RTC8_REG_YEAR 0x06
92#define RTC8_REG_MINUTES_ALARM 0x07
93#define RTC8_REG_HOURS_ALARM 0x08
94#define RTC8_REG_WEEKDAY_ALARM 0x09
95#define RTC8_REG_TIMER_VALUE_0 0x0A
96#define RTC8_REG_TIMER_VALUE_1 0x0B
97#define RTC8_REG_TIMER_STATUS_0 0x0C
98#define RTC8_REG_TIMER_STATUS_1 0x0D
99#define RTC8_REG_STATUS 0x0E
100#define RTC8_REG_CONTROL1 0x0F
101#define RTC8_REG_CONTROL2 0x10
102#define RTC8_REG_GP_BITS 0x11
103#define RTC8_REG_CLOCK_INT_MASK 0x12
104#define RTC8_REG_EVENT_CONTROL 0x13
105#define RTC8_REG_COUNT_TS 0x14
106#define RTC8_REG_SECONDS_TS 0x15
107#define RTC8_REG_MINUTES_TS 0x16
108#define RTC8_REG_HOURS_TS 0x17
109#define RTC8_REG_DATE_TS 0x18
110#define RTC8_REG_MONTH_TS 0x19
111#define RTC8_REG_YEAR_TS 0x1A
112#define RTC8_REG_UNIX0 0x1B
113#define RTC8_REG_UNIX1 0x1C
114#define RTC8_REG_UNIX2 0x1D
115#define RTC8_REG_UNIX3 0x1E
116#define RTC8_REG_USER_RAM_1 0x1F
117#define RTC8_REG_USER_RAM_2 0x20
118#define RTC8_REG_PASSWORD_0 0x21
119#define RTC8_REG_PASSWORD_1 0x22
120#define RTC8_REG_PASSWORD_2 0x23
121#define RTC8_REG_PASSWORD_3 0x24
122#define RTC8_REG_EEPROM_ADDRESS 0x25
123#define RTC8_REG_EEPROM_DATA 0x26
124#define RTC8_REG_EEPROM_COM 0x27
125#define RTC8_REG_ID 0x28
126#define RTC8_REG_EEPROM_BACKUP 0x37
133#define RTC8_STATUS_EEPROM_BUSY 0x80
134#define RTC8_STATUS_CLOCK_INT_FLAG 0x40
135#define RTC8_STATUS_BACKUP_SWITCH_FLAG 0x20
136#define RTC8_STATUS_UPDATE_FLAG 0x10
137#define RTC8_STATUS_TIMER_FLAG 0x08
138#define RTC8_STATUS_ALARM_FLAG 0x04
139#define RTC8_STATUS_EVENT_FLAG 0x02
140#define RTC8_STATUS_POR_FLAG 0x01
141#define RTC8_STATUS_REG_CLEAR 0x00
148#define RTC8_CTRL1_TRPT_SINGLE_MODE 0x00
149#define RTC8_CTRL1_TRPT_REPEAT_MODE 0x80
150#define RTC8_CTRL1_WADA_WEEKDAY_ALARM 0x00
151#define RTC8_CTRL1_WADA_DATE_ALARM 0x20
152#define RTC8_CTRL1_USEL_SECOND_UPDATE 0x00
153#define RTC8_CTRL1_USEL_MINUTE_UPDATE 0x10
154#define RTC8_CTRL1_EERD_REFRESH_ACTIVE 0x00
155#define RTC8_CTRL1_EERD_REFRESH_NO_ACTIVE 0x08
156#define RTC8_CTRL1_TE_TIMER_STOPS 0x00
157#define RTC8_CTRL1_TE_TIMER_STARTS 0x04
158#define RTC8_CTRL1_TD_TIMER_CLK_4096Hz 0x00
159#define RTC8_CTRL1_TD_TIMER_CLK_64Hz 0x01
160#define RTC8_CTRL1_TD_TIMER_CLK_1Hz 0x02
161#define RTC8_CTRL1_TD_TIMER_CLK_1_60Hz 0x03
168#define RTC8_CTRL2_TIME_STAMP_DISABLE 0x00
169#define RTC8_CTRL2_TIME_STAMP_ENABLE 0x80
170#define RTC8_CTRL2_INT_CLOCK_DISABLE 0x00
171#define RTC8_CTRL2_INT_CLOCK_ENABLE 0x40
172#define RTC8_CTRL2_TIME_UPDATE_INTERRUPT 0x20
173#define RTC8_CTRL2_TIME_UPDATE_NO_INTERRUPT 0x00
174#define RTC8_CTRL2_TIMER_INTERRUPT 0x10
175#define RTC8_CTRL2_TIMER_NO_INTERRUPT 0x00
176#define RTC8_CTRL2_ALARM_INTERRUPT 0x08
177#define RTC8_CTRL2_ALARM_NO_INTERRUPT 0x00
178#define RTC8_CTRL2_EVENT_INTERRUPT 0x04
179#define RTC8_CTRL2_EVENT_NO_INTERRUPT 0x00
180#define RTC8_CTRL2_HOUR_MODE_12 0x02
181#define RTC8_CTRL2_HOUR_MODE_24 0x00
182#define RTC8_CTRL2_RESET_ACTIVE 0x01
183#define RTC8_CTRL2_NO_RESET 0x00
190#define RTC8_CLKIM_EVENT_INT_ENABLE 0x08
191#define RTC8_CLKIM_EVENT_INT_DISABLE 0x00
192#define RTC8_CLKIM_ALARM_INT_ENABLE 0x04
193#define RTC8_CLKIM_ALARM_INT_DISABLE 0x00
194#define RTC8_CLKIM_TIMER_INT_ENABLE 0x02
195#define RTC8_CLKIM_TIMER_INT_DISABLE 0x00
196#define RTC8_CLKIM_TIME_UPDATE_INT_ENABLE 0x01
197#define RTC8_CLKIM_TIME_UPDATE_INT_DISABLE 0x00
204#define RTC8_EC_EVENT_LOW_LEVEL 0x00
205#define RTC8_EC_EVENT_HIGH_LEVEL 0x40
206#define RTC8_EC_EVENT_PERIOD_256Hz 0x10
207#define RTC8_EC_EVENT_PERIOD_64Hz 0x20
208#define RTC8_EC_EVENT_PERIOD_8Hz 0x30
209#define RTC8_EC_EVENT_NO_FILTERING 0x00
210#define RTC8_EC_TIME_STAMP_RESET_ENABLE 0x04
211#define RTC8_EC_TIME_STAMP_RESET_DISABLE 0x00
212#define RTC8_EC_TSOW_EVF_CLEARED 0x00
213#define RTC8_EC_TSOW_EVF_NO_CLEARED 0x02
214#define RTC8_EC_TSS_TSE_ON_EVI 0x00
215#define RTC8_EC_TSS_TSE_ON_VBACKUP 0x01
222#define RTC8_EECMD_WRITE_ALL_EEPROM_REG 0x11
223#define RTC8_EECMD_READ_ALL_EEPROM_REG 0x12
224#define RTC8_EECMD_WRITE_ONE_EEPROM_REG 0x21
225#define RTC8_EECMD_READ_ONE_EEPROM_REG 0x22
232#define RTC8_ALARM_IS_ACTIVE 0x01
233#define RTC8_ALARM_NO_ACTIVE 0x00
err_t rtx8_get_time_and_date(rtc8_t *ctx, rtc8_time_t *time_s, rtc8_date_t *date_s)
Get RTC data ( Time and Data )
err_t rtc8_generic_read(rtc8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
err_t rtc8_get_alarm_flag(rtc8_t *ctx, uint8_t *alarm_flag)
Get Alarm flag.
err_t rtc8_set_alarm(rtc8_t *ctx, rtc8_alarm_t *alarm_s)
Set Alarm.
err_t rtc8_generic_write(rtc8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
err_t rtc8_default_cfg(rtc8_t *ctx)
Click Default Configuration function.
err_t rtc8_get_uinx_time(rtc8_t *ctx, uint32_t *unix_time)
Get current UNIX time.
uint8_t rtc8_get_int_pin(rtc8_t *ctx)
Get interrupt state.
void rtc8_cfg_setup(rtc8_cfg_t *cfg)
Config Object Initialization function.
err_t rtc8_reset_alarm_flag(rtc8_t *ctx)
Reset alarm.
err_t rtc8_get_status(rtc8_t *ctx, uint8_t *status)
Get status.
err_t rtc8_init(rtc8_t *ctx, rtc8_cfg_t *cfg)
Initialization function.
err_t rtc8_set_unix_time(rtc8_t *ctx, uint32_t unix_time)
Set UNIX time.
void rtc8_set_evi_pin(rtc8_t *ctx, uint8_t state)
Set EVI(External Event Input) pin.
err_t rtc8_set_time(rtc8_t *ctx, rtc8_time_t *time_s)
Set new time - 24 hour format.
err_t rtc8_read_data(rtc8_t *ctx, uint8_t reg, uint8_t *data_out)
Read one byte data from register in DEC format.
err_t rtc8_write_data(rtc8_t *ctx, uint8_t reg, uint8_t data_in)
Write data ( Convert and send data in BCD format )
err_t rtc8_set_date(rtc8_t *ctx, rtc8_date_t *date_s)
Set new date.
Alarm structure definition.
Definition rtc8.h:308
uint8_t hours
Definition rtc8.h:310
uint8_t minutes
Definition rtc8.h:311
uint8_t weekdays
Definition rtc8.h:309
Click configuration structure definition.
Definition rtc8.h:266
uint32_t i2c_speed
Definition rtc8.h:276
pin_name_t evi
Definition rtc8.h:272
pin_name_t scl
Definition rtc8.h:268
pin_name_t int_pin
Definition rtc8.h:273
pin_name_t sda
Definition rtc8.h:269
uint8_t i2c_address
Definition rtc8.h:277
Date structure definition.
Definition rtc8.h:296
uint8_t month
Definition rtc8.h:298
uint8_t day
Definition rtc8.h:297
uint8_t year
Definition rtc8.h:299
uint8_t weekdays
Definition rtc8.h:300
Click ctx object definition.
Definition rtc8.h:247
digital_out_t evi
Definition rtc8.h:249
digital_in_t int_pin
Definition rtc8.h:252
i2c_master_t i2c
Definition rtc8.h:255
uint8_t slave_address
Definition rtc8.h:258
Time structure definition.
Definition rtc8.h:285
uint8_t hours
Definition rtc8.h:286
uint8_t seconds
Definition rtc8.h:288
uint8_t minutes
Definition rtc8.h:287