Go to the documentation of this file.
37 #include "mikrosdk_version.h"
40 #if mikroSDK_GET_VERSION < 20800ul
41 #include "rcu_delays.h"
47 #include "drv_digital_out.h"
48 #include "drv_digital_in.h"
49 #include "drv_i2c_master.h"
62 #define RTC7_MAP_MIKROBUS( cfg, mikrobus ) \
63 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65 cfg.itb = MIKROBUS( mikrobus, MIKROBUS_AN ); \
66 cfg.ita = MIKROBUS( mikrobus, MIKROBUS_INT );
81 #define RTC7_SECONDS_ADDR 0x06
82 #define RTC7_MINUTES_ADDR 0x07
83 #define RTC7_HOURS_ADDR 0x08
84 #define RTC7_DAY_ADDR 0x09
85 #define RTC7_DATE_ADDR 0x0A
86 #define RTC7_MONTH_ADDR 0x0B
87 #define RTC7_YEAR_ADDR 0x0C
94 #define RTC7_TIMEDATE_BYTES 7
95 #define RTC7_SECONDS_BYTE 0
96 #define RTC7_MINUTES_BYTE 1
97 #define RTC7_HOURS_BYTE 2
98 #define RTC7_DAY_BYTE 3
99 #define RTC7_DATE_BYTE 4
100 #define RTC7_MONTH_BYTE 5
101 #define RTC7_YEAR_BYTE 6
108 #define RTC7_SECONDS_MASK 0x7F
109 #define RTC7_MINUTES_MASK 0x7F
110 #define RTC7_HOURS_MASK 0x1F
111 #define RTC7_DAY_MASK 0x07
112 #define RTC7_DATE_MASK 0x3F
113 #define RTC7_MONTH_MASK 0x1F
114 #define RTC7_YEAR_MASK 0xFF
121 #define RTC7_JULIAN_DAY_1970 2440588
122 #define RTC7_TIME_SEC_IN_MIN 60
123 #define RTC7_TIME_SEC_IN_HOUR 3600
124 #define RTC7_TIME_SEC_IN_24_HOURS 86400
131 #define RTC7_CONFIG1_REG 0x00
132 #define RTC7_CONFIG2_REG 0x01
133 #define RTC7_SLEEP_CONFIG_REG 0x02
134 #define RTC7_TIMER_CONFIG_REG 0x03
135 #define RTC7_INT_EN_REG 0x04
136 #define RTC7_INT_STATUS_REG 0x05
137 #define RTC7_ALM1_SEC_REG 0x0D
138 #define RTC7_ALM1_MIN_REG 0x0E
139 #define RTC7_ALM1_HRS_REG 0x0F
140 #define RTC7_ALM1_DAY_DATE_REG 0x10
141 #define RTC7_ALM2_MIN_REG 0x11
142 #define RTC7_ALM2_HRS_REG 0x12
143 #define RTC7_ALM2_DAY_DATE_REG 0x13
144 #define RTC7_TIMER_COUNT_REG 0x14
145 #define RTC7_TIMER_INIT_REG 0x15
146 #define RTC7_RAM0_REG_ADDR16H 0x16
147 #define RTC7_RAM63_REG_ADDR55H 0x55
148 #define RTC7_PWR_MGMT_REG 0x56
149 #define RTC7_TRICKLE_REG 0x57
150 #define RTC7_SPARE_REG 0x58
151 #define RTC7_SPARE_ST_REG 0x59
152 #define RTC7_TEST1_REG 0x64
153 #define RTC7_TEST2_REG 0x65
154 #define RTC7_TEST3_REG 0x66
155 #define RTC7_TCFG1_REG 0x67
156 #define RTC7_TCFG2_REG 0x68
157 #define RTC7_TCFG3_REG 0x69
158 #define RTC7_OTP1_B1_REG 0x6A
159 #define RTC7_OTP1_B2_REG 0x6B
160 #define RTC7_OTP1_B3_REG 0x6C
161 #define RTC7_OTP1_B4_REG 0x6D
162 #define RTC7_OTP2_B1_REG 0x6E
163 #define RTC7_OTP2_B2_REG 0x6F
164 #define RTC7_OTP2_B3_REG 0x70
165 #define RTC7_OTP2_B4_REG 0x71
166 #define RTC7_TCFG4_REG 0x72
167 #define RTC7_TCFG5_REG 0x73
168 #define RTC7_TEST_DIG_REG 0x74
175 #define RTC7_RESET_DIGITAL_BLOCK 0x00
176 #define RTC7_NOT_RESET_DIGITAL_BLOCK 0x01
177 #define RTC7_OUTPUT_FREQ_1HZ 0x00
178 #define RTC7_OUTPUT_FREQ_4098HZ 0x02
179 #define RTC7_OUTPUT_FREQ_8192HZ 0x04
180 #define RTC7_OUTPUT_FREQ_32768HZ 0x06
181 #define RTC7_ENABLE_OSC 0x00
182 #define RTC7_DISABLE_OSC 0x08
183 #define RTC7_INPUT_FREQ_1HZ 0x00
184 #define RTC7_INPUT_FREQ_50HZ 0x10
185 #define RTC7_INPUT_FREQ_60HZ 0x20
186 #define RTC7_INPUT_FREQ_32768HZ 0x30
187 #define RTC7_OUTPUT_SQUARE_WAVE 0x00
188 #define RTC7_OUTPUT_INTERRUPT 0x40
189 #define RTC7_DISABLE_EXT_CLOCK 0x00
190 #define RTC7_ENABLE_EXT_CLOCK 0x80
197 #define RTC7_SOLAR_MODE 0x00
198 #define RTC7_LUNAR_MODE 0x01
199 #define RTC7_WRITE_NOT_ALLOW 0x00
200 #define RTC7_WRITE_ALLOW 0x02
201 #define RTC7_READ_NOT_ALLOW 0x00
202 #define RTC7_READ_ALLOW 0x04
203 #define RTC7_I2C_TIMEOUT_DIS 0x00
204 #define RTC7_I2C_TIMEOUT_EN 0x08
205 #define RTC7_VOLTAGE_THRESH_1400MV 0x00
206 #define RTC7_VOLTAGE_THRESH_1800MV 0x10
207 #define RTC7_VOLTAGE_THRESH_2100MV 0x20
208 #define RTC7_VOLTAGE_THRESH_2500MV 0x30
209 #define RTC7_NORMAL_OP_MODE 0x00
210 #define RTC7_DATA_RETENTION_MODE 0x40
217 #define RTC7_SLEEP_PERIOD_NO_DELAY 0x00
218 #define RTC7_SLEEP_PERIOD_8_TO_16MS 0x01
219 #define RTC7_SLEEP_PERIOD_16_TO_24MS 0x02
220 #define RTC7_SLEEP_PERIOD_24_TO_32MS 0x03
221 #define RTC7_SLEEP_PERIOD_32_TO_40MS 0x04
222 #define RTC7_SLEEP_PERIOD_40_TO_48MS 0x05
223 #define RTC7_SLEEP_PERIOD_48_TO_56MS 0x06
224 #define RTC7_SLEEP_PERIOD_56_TO_64MS 0x07
225 #define RTC7_SLEEP_MANAGER_DIS 0x00
226 #define RTC7_SLEEP_MANAGER_EN 0x08
227 #define RTC7_DIN0_INTERR_FALL_EDGE 0x00
228 #define RTC7_DIN0_INTERR_RISE_EDGE 0x10
229 #define RTC7_DIN1_INTERR_FALL_EDGE 0x00
230 #define RTC7_DIN1_INTERR_RISE_EDGE 0x20
231 #define RTC7_AN_INTERR_FALL_EDGE 0x00
232 #define RTC7_AN_INTERR_RISE_EDGE 0x40
233 #define RTC7_SLEEP_MODE_DIS 0x00
234 #define RTC7_SLEEP_MODE_EN 0x80
241 #define RTC7_TIMER_FREQ_1024HZ 0x00
242 #define RTC7_TIMER_FREQ_256HZ 0x01
243 #define RTC7_TIMER_FREQ_64HZ 0x02
244 #define RTC7_TIMER_FREQ_16HZ 0x03
245 #define RTC7_TIMER_WILL_HALT 0x00
246 #define RTC7_TIMER_RELOADS_VALUE 0x04
247 #define RTC7_PULSE_INTERR_TM_IS_0 0x00
248 #define RTC7_PULSE_INTERR_TM_IS_1 0x08
249 #define RTC7_TIMER_DIS 0x00
250 #define RTC7_TIMER_EN 0x10
257 #define RTC7_ALARM1_INTERR_DIS 0x00
258 #define RTC7_ALARM1_INTERR_EN 0x01
259 #define RTC7_ALARM2_INTERR_DIS 0x00
260 #define RTC7_ALARM2_INTERR_EN 0x02
261 #define RTC7_TIMER_INTERR_DIS 0x00
262 #define RTC7_TIMER_INTERR_EN 0x04
263 #define RTC7_EXT_INTERR0_DIS 0x00
264 #define RTC7_EXT_INTERR0_EN 0x08
265 #define RTC7_EXT_INTERR1_DIS 0x00
266 #define RTC7_EXT_INTERR1_EN 0x10
267 #define RTC7_AN_INTERR_DIS 0x00
268 #define RTC7_AN_INTERR_EN 0x20
err_t rtc7_reset(rtc7_t *ctx)
Reset function.
err_t rtc7_set_timer(rtc7_t *ctx, uint8_t enable_timer, uint8_t timer_freq)
Timer Set function.
uint8_t year
Definition: rtc7.h:286
pin_name_t scl
Definition: rtc7.h:317
digital_in_t rst
Definition: rtc7.h:297
uint8_t rtc7_century
Definition: rtc7.h:307
uint8_t monthday
Definition: rtc7.h:284
uint8_t i2c_address
Definition: rtc7.h:327
uint8_t hours
Definition: rtc7.h:282
err_t rtc7_get_gmt_time(rtc7_t *ctx, rtc7_time_t *gmt_time)
Get Gmt Time function.
pin_name_t itb
Definition: rtc7.h:321
err_t rtc7_generic_read(rtc7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
Click configuration structure definition.
Definition: rtc7.h:315
uint8_t rtc7_check_interrupt(rtc7_t *ctx)
Interrupt Check function.
pin_name_t ita
Definition: rtc7.h:323
digital_in_t itb
Definition: rtc7.h:296
uint8_t seconds
Definition: rtc7.h:280
Click ctx object definition.
Definition: rtc7.h:294
uint8_t minutes
Definition: rtc7.h:281
int8_t current_time_zone
Definition: rtc7.h:306
err_t rtc7_write_reg(rtc7_t *ctx, uint8_t reg, uint8_t data_in)
Write one byte function.
pin_name_t sda
Definition: rtc7.h:318
uint8_t month
Definition: rtc7.h:285
err_t rtc7_get_local_time(rtc7_t *ctx, rtc7_time_t *local_time)
Get Local Time function.
uint8_t slave_address
Definition: rtc7.h:304
uint8_t rtc7_check_psw(rtc7_t *ctx)
Power Switch Control function.
i2c_master_t i2c
Definition: rtc7.h:301
void rtc7_cfg_setup(rtc7_cfg_t *cfg)
Config Object Initialization function.
err_t rtc7_set_osc(rtc7_t *ctx, uint8_t enable_osc, uint8_t clk_in, uint8_t clk_out)
Oscillator Set function.
pin_name_t rst
Definition: rtc7.h:322
digital_in_t ita
Definition: rtc7.h:298
err_t rtc7_init(rtc7_t *ctx, rtc7_cfg_t *cfg)
Initialization function.
err_t rtc7_read_reg(rtc7_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Read one byte function.
uint8_t weekdays
Definition: rtc7.h:283
uint32_t i2c_speed
Definition: rtc7.h:326
err_t rtc7_set_gmt_time(rtc7_t *ctx, rtc7_time_t *time)
Set Gmt Time function.
err_t rtc7_generic_write(rtc7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
err_t rtc7_init_time(rtc7_t *ctx, int8_t time_zone)
Initialization function.