24#define RTC_CONTROL_1 0X00
25#define RTC_CONTROL_2 0X01
26#define RTC_CONTROL_3 0X02
29#define RTC_SECONDS 0X03
30#define RTC_MINUTES 0X04
33#define RTC_WEEKDAYS 0X07
38#define TIMER_A_FREQ_CTRL 0x10
39#define TIMER_A_REG 0x11
40#define TIMER_B_FREQ_CTRL 0x12
41#define TIMER_B_REG 0x13
44#define SECONDS_DATA 0X7F
45#define MINUTES_DATA 0X7F
46#define HOURS_DATA 0X3F
48#define WEEKDAYS_DATA 0X07
49#define MONTHS_DATA 0X1F
50#define YEARS_DATA 0XFF
85 time->
PM = (raw_hours & 0x20) >> 5;
86 time->
hours = bcd2bin(raw_hours & 0x1F);
91 time->
hours = bcd2bin(raw_hours & 0x3F);
106 if (buffer[0] & 0x08) {
137 current_mode_12h = (buffer[0] & 0x08) >> 3;
140 if (current_mode_12h == use_12hour_mode) {
145 if (use_12hour_mode) {
170 u8 status[1] = {0x58};
181 for (
int i = 1; i < 4; i++) {
rtc_status_t PCF8523_softreset(rtc_instance_t *rtc)
PCF8523 Driver API definitions. This file provides data structures and APIs for controlling the PCF85...
#define LOG_INFO(debug, fmt,...)
#define DBG_MOD_RTC
Real Time Clock.
void i2c_setMux(i2c_instance_t *inst, const uint8_t cr)
Set I2C MUX control register.
void i2c_writeData_b(i2c_instance_t *inst, u8 regAddr, u8 *data, u32 length)
Write data with an 8-bit register address over I2C and check rx ack for each transaction.
void i2c_readData_b(i2c_instance_t *inst, u8 regAddr, u8 *data, u32 length)
Read data with an 8-bit register address over I2C.
const rtc_api_t PCF8523_DRIVER
PCF8523 Driver Instance. Point your generic RTC pointer to this structure to use the PCF8523 hardware...
rtc_status_t PCF8523_getTime(rtc_instance_t *rtc)
Get time from PCF8523 RTC.
rtc_status_t PCF8523_getCSR(rtc_instance_t *rtc)
Get control/status register from PCF8523 RTC.
rtc_status_t PCF8523_setTimeSystem(rtc_instance_t *rtc, u8 use_12hour_mode)
Set time system (12-hour or 24-hour) on PCF8523 RTC.
rtc_status_t PCF8523_setTime(rtc_instance_t *rtc)
Set time on PCF8523 RTC.
rtc_status_t
RTC Status List.
@ RTC_SKIP
Skip the function */.
@ RTC_OK
Successful Operation */.
u8 convert_hour_register(u8 old_reg_val, u8 to_12h)
Convert hour register between 12-hour and 24-hour format.
struct rtc_instance rtc_instance_t
Forward declaration of RTC instance.
u8 hours
Hours (0-23 or 1-12) */.
u8 timesystem
Time System (0 = 24-hour, 1 = 12-hour) */.
u8 days
Day of the month (1-31) */.
u8 minutes
Minutes (0-59) */.
u8 seconds
Seconds (0-59) */.
u8 PM
PM Indicator for 12-hour format (0 = AM, 1 = PM) */.
u8 months
Month (1-12) */.
u8 weekdays
Day of the week (1-7) */.
rtc_data_t current_time
Current time data */.
i2c_instance_t * inst
Pointer to I2C instance */.