25#define RTC_SECONDS 0X00
26#define RTC_MINUTES 0X01
28#define RTC_WEEKDAYS 0X03
34#define CONTROL_ADDR 0X0E
35#define STATUS_ADDR 0X0F
36#define AGING_ADDR 0X10
41#define SECONDS_DATA 0X7F
42#define MINUTES_DATA 0X7F
43#define _12HOURS_DATA 0X1F
44#define _24HOURS_DATA 0X3F
47#define MONTH_DATA 0X1F
102 current_mode_12h = (buffer[0] & 0x40) >> 6;
105 if (current_mode_12h == use_12hour_mode) {
114 if (use_12hour_mode) {
116 h_val = bcd2bin(buffer[0] & 0x3F);
120 if (h_val > 12) h_val -= 12;
123 if (h_val == 0) h_val = 12;
126 new_reg_val = 0x40 | (pm_flag << 5) | bin2bcd(h_val);
131 pm_flag = (buffer[0] & 0x20) >> 5;
132 h_val = bcd2bin(buffer[0] & 0x1F);
136 if (h_val < 12) h_val += 12;
139 if (h_val == 12) h_val = 0;
141 new_reg_val = bin2bcd(h_val);
157 if (buffer[0] & 0x40) {
const rtc_api_t DS3231_driver
DS3231 Driver API definitions. This file provides data structures and APIs for controlling the DS3231...
#define LOG_INFO(debug, fmt,...)
#define DBG_MOD_RTC
Real Time Clock.
rtc_status_t DS3231_getTime(rtc_instance_t *rtc)
Get time from DS3231 RTC.
rtc_status_t DS3231_setTimeSystem(rtc_instance_t *rtc, u8 use_12hour_mode)
Set time system (12-hour or 24-hour) on DS3231 RTC.
rtc_status_t DS3231_setTime(rtc_instance_t *rtc)
Set time on DS3231 RTC.
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.
rtc_status_t
RTC Status List.
@ RTC_SKIP
Skip the function */.
@ RTC_OK
Successful Operation */.
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 */.