Go to the documentation of this file.
37 #include "drv_digital_out.h"
38 #include "drv_digital_in.h"
39 #include "drv_i2c_master.h"
51 #define RTC6_MAP_MIKROBUS( cfg, mikrobus ) \
52 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
53 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
54 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
61 #define RTC6_REG_SECONDS 0x00
62 #define RTC6_REG_MINUTES 0x01
63 #define RTC6_REG_HOURS 0x02
64 #define RTC6_REG_DAY 0x03
65 #define RTC6_REG_DATE 0x04
66 #define RTC6_REG_MONTH 0x05
67 #define RTC6_REG_YEARS 0x06
68 #define RTC6_REG_CONTROL 0x07
69 #define RTC6_REG_OSC_TRIM 0x08
70 #define RTC6_REG_EEUNLOCK 0x09
71 #define RTC6_REG_ALARM0_SECOND 0x0A
72 #define RTC6_REG_ALARM0_MINUTE 0x0B
73 #define RTC6_REG_ALARM0_HOUR 0x0C
74 #define RTC6_REG_ALARM0_DAY 0x0D
75 #define RTC6_REG_ALARM0_DATE 0x0E
76 #define RTC6_REG_ALARM0_MONTH 0x0F
77 #define RTC6_REG_ALARM1_SECOND 0x11
78 #define RTC6_REG_ALARM1_MINUTE 0x12
79 #define RTC6_REG_ALARM1_HOUR 0x13
80 #define RTC6_REG_ALARM1_DAY 0x14
81 #define RTC6_REG_ALARM1_DATE 0x15
82 #define RTC6_REG_ALARM1_MONTH 0x16
83 #define RTC6_REG_POWER_DOWN_MINUTE 0x18
84 #define RTC6_REG_POWER_DOWN_HOUR 0x19
85 #define RTC6_REG_POWER_DOWN_DATE 0x1A
86 #define RTC6_REG_POWER_DOWN_MONTH 0x1B
87 #define RTC6_REG_POWER_UP_MINUTE 0x1C
88 #define RTC6_REG_POWER_UP_HOUR 0x1D
89 #define RTC6_REG_POWER_UP_DATE 0x1E
90 #define RTC6_REG_POWER_UP_MONTH 0x1F
97 #define RTC6_OSCILLATOR_ENABLE 0x80
98 #define RTC6_OSCILLATOR_DISABLE 0x00
105 #define RTC6_FORMAT_12_HOURS 0x40
106 #define RTC6_FORMAT_24_HOURS 0x00
113 #define RTC6_SWO_1HZ 0x01
114 #define RTC6_SWO_4_096KHZ 0x02
115 #define RTC6_SWO_8_192KHZ 0x03
116 #define RTC6_SWO_32_768KHZ 0x04
120 #define RTC6_MONTH_JANUARY 0x00
121 #define RTC6_MONTH_FEBRUARY 0x01
122 #define RTC6_MONTH_MARCH 0x02
123 #define RTC6_MONTH_APRIL 0x03
124 #define RTC6_MONTH_MAY 0x04
125 #define RTC6_MONTH_JUNE 0x05
126 #define RTC6_MONTH_JULY 0x06
127 #define RTC6_MONTH_AUGUST 0x07
128 #define RTC6_MONTH_SEPTEMBER 0x08
129 #define RTC6_MONTH_OCTOBER 0x09
130 #define RTC6_MONTH_NOVEMBER 0x0A
131 #define RTC6_MONTH_DECEMBER 0x0B
138 #define RTC6_DAY_MONDAY 0x00
139 #define RTC6_DAY_TUESDAY 0x01
140 #define RTC6_DAY_WEDNESDAY 0x02
141 #define RTC6_DAY_THURSDAY 0x03
142 #define RTC6_DAY_FRIDAY 0x04
143 #define RTC6_DAY_SATURDAY 0x05
144 #define RTC6_DAY_SUNDAY 0x06
151 #define RTC6_DEVICE_SLAVE_ADDR 0x6F
152 #define RTC6_SRAM_SLAVE_ADDR 0xDE
153 #define RTC6_EEPROM_SLAVE_ADDR 0x57
160 #define RTC6_ALARM_0 0x00
161 #define RTC6_ALARM_1 0x01
168 #define RTC6_RETVAL uint8_t
171 #define RTC6_INIT_ERROR 0xFF
178 #define SET_ERROR 0x02
179 #define DEVICE_ERROR 0x01
180 #define DEVICE_OK 0x00
187 #define RTC6_TIMEDATE_BYTES 0x07
188 #define RTC6_SECONDS_BYTE 0x00
189 #define RTC6_MINUTES_BYTE 0x01
190 #define RTC6_HOUR_BYTE 0x02
191 #define RTC6_DAY_BYTE 0x03
192 #define RTC6_DATE_BYTE 0x04
193 #define RTC6_MONTH_BYTE 0x05
194 #define RTC6_YEAR_BYTE 0x06
201 #define RTC6_RAM_SIZE 64
202 #define RTC6_RAM_START 0x20
203 #define RTC6_RAM_END 0x5f
204 #define RTC6_EEPROM_SIZE 1024
205 #define RTC6_EEPROM_START 0
206 #define RTC6_EEPROM_END 1024
207 #define RTC6_EEPROM_PAGE_SIZE 8
208 #define RTC6_EEPROM_STATUS 0xFF
216 #define TIME_SEC_IN_MIN 60
217 #define TIME_SEC_IN_HOUR 3600
218 #define TIME_SEC_IN_DAY 86400
219 #define TIME_SEC_IN_MONTH 2629743
220 #define TIME_SEC_IN_YEAR_365 31536000
221 #define TIME_SEC_IN_LEAP_YEAR 31622400
222 #define TIME_SEC_IN_YEAR_365_25 31557600
uint8_t hours
Definition: rtc6.h:239
void rtc6_write_sram(rtc6_t *ctx, uint8_t addr, uint8_t data_in)
Writes data to the SRAM.
int8_t time_zone_cfg
Definition: rtc6.h:289
uint8_t rtc6_is_power_failure(rtc6_t *ctx)
Checks if a power failure has occured.
i2c_master_t i2c
Definition: rtc6.h:258
void rtc6_repeat_alarm(rtc6_t *ctx, uint8_t alarm, uint32_t sec)
Repeat Alarm.
void rtc6_default_cfg(rtc6_t *ctx, int8_t time_zone, rtc6_time_t *utc_time, rtc6_time_t *alarm_time)
Click Default Configuration function.
void rtc6_cfg_setup(rtc6_cfg_t *cfg)
Config Object Initialization function.
void rtc6_write_eeprom_protect_on(rtc6_t *ctx)
Write protect on.
uint8_t monthday
Definition: rtc6.h:241
int8_t time_zone
Definition: rtc6.h:264
RTC6_RETVAL rtc6_init(rtc6_t *ctx, rtc6_cfg_t *cfg)
Initialization function.
uint8_t rtc6_eeprom_is_locked(rtc6_t *ctx)
Lock check function.
void rtc6_generic_write(rtc6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void rtc6_read_alarm(rtc6_t *ctx, uint8_t alarm, rtc6_time_t *get_alarm)
Reads the alarm time.
#define RTC6_RETVAL
Definition: rtc6.h:168
void rtc6_write_eeprom(rtc6_t *ctx, uint8_t addr, uint8_t *data_in, uint8_t data_size)
Writes data to EEPROM.
Click time data object.
Definition: rtc6.h:236
pin_name_t sda
Definition: rtc6.h:276
pin_name_t int_pin
Definition: rtc6.h:280
Click configuration structure definition.
Definition: rtc6.h:272
void rtc6_read_eeprom(rtc6_t *ctx, uint8_t addr, uint8_t *data_out, uint8_t data_size)
Reads data from EEPROM.
void rtc6_disable_swo(rtc6_t *ctx)
Disables Square Wave Output.
void rtc6_get_last_power_failure(rtc6_t *ctx, rtc6_time_t *last_time)
Gets the time of the last power failure.
void rtc6_get_local_time(rtc6_t *ctx, rtc6_time_t *local_time)
Calculates the current local time.
void rtc6_disable_alarm(rtc6_t *ctx, uint8_t alarm)
Disables the alarm.
uint8_t minutes
Definition: rtc6.h:238
uint8_t rtc6_init_fun(rtc6_t *ctx, int8_t time_zone)
uint8_t rtc6_is_leap_year(rtc6_t *ctx)
Checks if the current year is a leap one.
uint8_t month
Definition: rtc6.h:242
uint32_t rtc6_get_gmt_unix_time(rtc6_t *ctx)
Calculates the current GMT time in UNIX epoch time.
uint8_t seconds
Definition: rtc6.h:237
uint8_t rtc6_is_active_alarm(rtc6_t *ctx)
Check if the alarm is activated.
uint8_t i2c_address
Definition: rtc6.h:285
void rtc6_get_gmt_time(rtc6_t *ctx, rtc6_time_t *gmt_time)
Gets the current GMT time set in the RTC.
void rtc6_set_gmt_time(rtc6_t *ctx, rtc6_time_t *set_time)
Sets the UTC GMT time.
digital_in_t int_pin
Definition: rtc6.h:254
void rtc6_read_unique_id(rtc6_t *ctx, uint8_t *unique_id)
Reads unique ID.
uint16_t year
Definition: rtc6.h:243
void rtc6_set_alarm(rtc6_t *ctx, uint8_t alarm, uint8_t trigger, rtc6_time_t *time)
Sets the desired alarm.
uint8_t slave_address
Definition: rtc6.h:262
uint32_t rtc6_get_local_unix_time(rtc6_t *ctx)
Calculates the current local time in UNIX epoch time.
Click ctx object definition.
Definition: rtc6.h:251
uint32_t i2c_speed
Definition: rtc6.h:284
uint8_t weekdays
Definition: rtc6.h:240
void rtc6_enable_swo(rtc6_t *ctx, uint8_t swo)
Enable Square Wave Output.
uint8_t rtc6_read_sram(rtc6_t *ctx, uint8_t addr)
Reads data from an SRAM.
void rtc6_write_eeprom_protect_off(rtc6_t *ctx)
Write protect off.
void rtc6_generic_read(rtc6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void rtc6_battery_enable(rtc6_t *ctx)
Enables automatic switch to battery.
pin_name_t scl
Definition: rtc6.h:275