LibDriver PCF8563
Loading...
Searching...
No Matches
driver_pcf8563.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_PCF8563_H
38#define DRIVER_PCF8563_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
78
89
98
107
111typedef struct pcf8563_time_s
112{
113 uint16_t year;
114 uint8_t month;
115 uint8_t week;
116 uint8_t date;
117 uint8_t hour;
118 uint8_t minute;
119 uint8_t second;
121
125typedef struct pcf8563_handle_s
126{
127 uint8_t (*iic_init)(void);
128 uint8_t (*iic_deinit)(void);
129 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
130 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
131 void (*debug_print)(const char *const fmt, ...);
132 void (*delay_ms)(uint32_t ms);
133 void (*receive_callback)(uint8_t type);
134 uint8_t inited;
136
152
156
163
170#define DRIVER_PCF8563_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
171
178#define DRIVER_PCF8563_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
179
186#define DRIVER_PCF8563_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
187
194#define DRIVER_PCF8563_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
195
202#define DRIVER_PCF8563_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
203
210#define DRIVER_PCF8563_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
211
218#define DRIVER_PCF8563_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
219
226#define DRIVER_PCF8563_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
227
231
238
247uint8_t pcf8563_info(pcf8563_info_t *info);
248
260
271uint8_t pcf8563_init(pcf8563_handle_t *handle);
272
283uint8_t pcf8563_deinit(pcf8563_handle_t *handle);
284
298
312
325
338
351
364
377
390
403
416
429uint8_t pcf8563_set_minute_alarm(pcf8563_handle_t *handle, uint8_t minute);
430
442uint8_t pcf8563_get_minute_alarm(pcf8563_handle_t *handle, uint8_t *minute);
443
456
469
482uint8_t pcf8563_set_hour_alarm(pcf8563_handle_t *handle, uint8_t hour);
483
495uint8_t pcf8563_get_hour_alarm(pcf8563_handle_t *handle, uint8_t *hour);
496
509
522
535uint8_t pcf8563_set_day_alarm(pcf8563_handle_t *handle, uint8_t day);
536
548uint8_t pcf8563_get_day_alarm(pcf8563_handle_t *handle, uint8_t *day);
549
562
575
588uint8_t pcf8563_set_week_alarm(pcf8563_handle_t *handle, uint8_t week);
589
601uint8_t pcf8563_get_week_alarm(pcf8563_handle_t *handle, uint8_t *week);
602
615
628
641
654
667
680
693
706
718uint8_t pcf8563_set_timer_value(pcf8563_handle_t *handle, uint8_t value);
719
731uint8_t pcf8563_get_timer_value(pcf8563_handle_t *handle, uint8_t *value);
732
745
758
771
784
797
810
823
827
834
848uint8_t pcf8563_set_reg(pcf8563_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
849
863uint8_t pcf8563_get_reg(pcf8563_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
864
868
872
873#ifdef __cplusplus
874}
875#endif
876
877#endif
uint8_t pcf8563_info(pcf8563_info_t *info)
get chip's information
uint8_t pcf8563_set_week_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable week alarm
uint8_t pcf8563_set_hour_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable hour alarm
uint8_t pcf8563_set_timer_enable(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable timer enable
pcf8563_timer_freq_t
pcf8563 timer freq enumeration definition
uint8_t pcf8563_set_day_alarm(pcf8563_handle_t *handle, uint8_t day)
set day alarm
uint8_t pcf8563_get_week_alarm(pcf8563_handle_t *handle, uint8_t *week)
get week alarm
uint8_t pcf8563_deinit(pcf8563_handle_t *handle)
close the chip
uint8_t pcf8563_get_minute_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the minute alarm status
pcf8563_bool_t
pcf8563 bool enumeration definition
uint8_t pcf8563_get_rtc_stop(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the rtc stop status
uint8_t pcf8563_set_clock_out(pcf8563_handle_t *handle, pcf8563_clock_out_t clk)
set clock out
uint8_t pcf8563_set_hour_alarm(pcf8563_handle_t *handle, uint8_t hour)
set hour alarm
uint8_t pcf8563_get_interrupt_mode(pcf8563_handle_t *handle, pcf8563_interrupt_mode_t *mode)
get the interrupt mode
uint8_t pcf8563_get_hour_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the hour alarm status
uint8_t pcf8563_get_alarm_interrupt(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get alarm interrupt status
uint8_t pcf8563_get_timer_freq(pcf8563_handle_t *handle, pcf8563_timer_freq_t *freq)
get timer freq
uint8_t pcf8563_set_timer_interrupt(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable timer interrupt
uint8_t pcf8563_set_test_mode(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable test mode
uint8_t pcf8563_set_minute_alarm(pcf8563_handle_t *handle, uint8_t minute)
set minute alarm
uint8_t pcf8563_set_timer_freq(pcf8563_handle_t *handle, pcf8563_timer_freq_t freq)
set timer freq
uint8_t pcf8563_set_clock_out_enable(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable clock out enable
pcf8563_interrupt_mode_t
pcf8563 interrupt mode enumeration definition
uint8_t pcf8563_init(pcf8563_handle_t *handle)
initialize the chip
struct pcf8563_info_s pcf8563_info_t
pcf8563 information structure definition
uint8_t pcf8563_get_hour_alarm(pcf8563_handle_t *handle, uint8_t *hour)
get hour alarm
uint8_t pcf8563_get_clock_out_enable(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get clock out enable status
pcf8563_clock_out_t
pcf8563 clock out enumeration definition
uint8_t pcf8563_get_timer_interrupt(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get timer interrupt status
uint8_t pcf8563_set_time(pcf8563_handle_t *handle, pcf8563_time_t *t)
set the current time
uint8_t pcf8563_get_day_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the day alarm status
uint8_t pcf8563_get_minute_alarm(pcf8563_handle_t *handle, uint8_t *minute)
get minute alarm
struct pcf8563_time_s pcf8563_time_t
pcf8563 time structure definition
uint8_t pcf8563_get_day_alarm(pcf8563_handle_t *handle, uint8_t *day)
get day alarm
uint8_t pcf8563_get_clock_out(pcf8563_handle_t *handle, pcf8563_clock_out_t *clk)
get clock out
uint8_t pcf8563_get_timer_value(pcf8563_handle_t *handle, uint8_t *value)
get timer value
uint8_t pcf8563_irq_handler(pcf8563_handle_t *handle)
irq handler
uint8_t pcf8563_set_alarm_interrupt(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable alarm interrupt
uint8_t pcf8563_set_week_alarm(pcf8563_handle_t *handle, uint8_t week)
set week alarm
uint8_t pcf8563_set_day_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable day alarm
uint8_t pcf8563_set_minute_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable minute alarm
uint8_t pcf8563_set_rtc_stop(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable rtc stop
struct pcf8563_handle_s pcf8563_handle_t
pcf8563 handle structure definition
uint8_t pcf8563_set_interrupt_mode(pcf8563_handle_t *handle, pcf8563_interrupt_mode_t mode)
set the interrupt mode
uint8_t pcf8563_get_power_on_reset(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the power on reset status
pcf8563_interrupt_event_t
pcf8563 interrupt event enumeration definition
uint8_t pcf8563_get_timer_enable(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get timer enable status
uint8_t pcf8563_set_timer_value(pcf8563_handle_t *handle, uint8_t value)
set timer value
uint8_t pcf8563_get_week_alarm_enable(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the week alarm status
uint8_t pcf8563_get_time(pcf8563_handle_t *handle, pcf8563_time_t *t)
get the current time
uint8_t pcf8563_get_test_mode(pcf8563_handle_t *handle, pcf8563_bool_t *enable)
get the test mode status
uint8_t pcf8563_clear_status(pcf8563_handle_t *handle, pcf8563_interrupt_event_t event)
clear status
uint8_t pcf8563_set_power_on_reset(pcf8563_handle_t *handle, pcf8563_bool_t enable)
enable or disable power on reset
@ PCF8563_TIMER_FREQ_64HZ
@ PCF8563_TIMER_FREQ_1_DIV_60HZ
@ PCF8563_TIMER_FREQ_4P096KHZ
@ PCF8563_TIMER_FREQ_1HZ
@ PCF8563_BOOL_TRUE
@ PCF8563_BOOL_FALSE
@ PCF8563_INTERRUPT_MODE_PULSE
@ PCF8563_INTERRUPT_MODE_LEVEL
@ PCF8563_CLOCK_OUT_32P768KHZ
@ PCF8563_CLOCK_OUT_32HZ
@ PCF8563_CLOCK_OUT_1P024KHZ
@ PCF8563_CLOCK_OUT_1HZ
@ PCF8563_INTERRUPT_EVENT_TIMER
@ PCF8563_INTERRUPT_EVENT_ALARM
uint8_t pcf8563_get_reg(pcf8563_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t pcf8563_set_reg(pcf8563_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
pcf8563 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
pcf8563 information structure definition
uint32_t driver_version
char manufacturer_name[32]
pcf8563 time structure definition