10#include "driver/i2c_master.h"
13#define DS3231_I2C_ADDR_DEFAULT 0x68
14#define DS3231_I2C_CLK_SPEED 100000UL
15#define DS3231_TIMEOUT_MS 50
16#define DS3231_LOCK_TIMEOUT_MS 1000
esp_err_t ds3231_squarewave_set_freq(ds3231_handle_t ds3231_handle, ds3231_squarewave_freq_t freq)
Set square wave frequency.
ds3231_time_format_t
Time format of the device.
Definition ds3231.h:25
@ DS3231_TIME_FORMAT_24H
Definition ds3231.h:27
@ DS3231_TIME_FORMAT_12H
Definition ds3231.h:26
ds3231_squarewave_freq_t
Square wave output on the INT/SQW pin.
Definition ds3231.h:33
@ DS3231_FREQ_8192HZ
Definition ds3231.h:37
@ DS3231_FREQ_1024HZ
Definition ds3231.h:35
@ DS3231_FREQ_1HZ
Definition ds3231.h:34
@ DS3231_FREQ_4096HZ
Definition ds3231.h:36
esp_err_t ds3231_alarm1_set_time(ds3231_handle_t ds3231_handle, ds3231_alarm1_match_t interr, struct tm timeinfo, ds3231_time_format_t format)
Set the time of interrupt.
esp_err_t ds3231_get_time(ds3231_handle_t ds3231_handle, struct tm *timeinfo, ds3231_time_format_t *format)
Get the current date and time.
ds3231_alarms_t
Alarms whose interrupts are enabled.
Definition ds3231.h:43
@ DS3231_ALARM_A1_A2
Definition ds3231.h:47
@ DS3231_ALARM_A1
Definition ds3231.h:45
@ DS3231_ALARM_NONE
Definition ds3231.h:44
@ DS3231_ALARM_A2
Definition ds3231.h:46
ds3231_alarm2_match_t
Match mode of alarm 2.
Definition ds3231.h:75
@ DS3231_ALARM2_INTERR_MATCH_MIN
Definition ds3231.h:77
@ DS3231_ALARM2_INTERR_HOURMINDAY
Definition ds3231.h:80
@ DS3231_ALARM2_INTERR_PER_MIN
Definition ds3231.h:76
@ DS3231_ALARM2_INTERR_MATCH_HOURMIN
Definition ds3231.h:78
@ DS3231_ALARM2_INTERR_MATCH_HOURMINDATE
Definition ds3231.h:79
esp_err_t ds3231_alarm1_interr_disable(ds3231_handle_t ds3231_handle)
Disable interrupts for alarm 1.
ds3231_alarm1_match_t
Match mode of alarm 1.
Definition ds3231.h:63
@ DS3231_ALARM1_INTERR_HOURMINSECDAY
Definition ds3231.h:68
@ DS3231_ALARM1_INTERR_MATCH_MINSEC
Definition ds3231.h:66
@ DS3231_ALARM1_INTERR_HOURMINSECDATE
Definition ds3231.h:69
@ DS3231_ALARM1_INTERR_MATCH_HOURMINSEC
Definition ds3231.h:67
@ DS3231_ALARM1_INTERR_PER_SEC
Definition ds3231.h:64
@ DS3231_ALARM1_INTERR_MATCH_SEC
Definition ds3231.h:65
ds3231_alarm_flags_t
Alarm flags which sets by the device when the time matches the alarm.
Definition ds3231.h:53
@ DS3231_ALARM2_FLAG_INTERR
Definition ds3231.h:56
@ DS3231_ALARM1_FLAG_INTERR
Definition ds3231.h:55
@ DS3231_ALARM1_ALARM2_FLAGS_INTERR
Definition ds3231.h:57
@ DS3231_ALARM_NO_INTERR
Definition ds3231.h:54
esp_err_t ds3231_squarewave_32khz_enable(ds3231_handle_t ds3231_handle)
Enable 32 kHz output.
esp_err_t ds3231_create(i2c_master_bus_handle_t i2c_bus, ds3231_handle_t *ds3231_handle)
Initialize device handle.
esp_err_t ds3231_squarewave_battery_disable(ds3231_handle_t ds3231_handle)
Disallow the device to run the square wave when powered from the battery.
void ds3231_delete(ds3231_handle_t ds3231_handle)
Free device handle.
esp_err_t ds3231_alarm_interr_get_status(ds3231_handle_t ds3231_handle, ds3231_alarms_t *interr)
Get which alarm interrupts are enabled.
esp_err_t ds3231_squarewave_get_freq(ds3231_handle_t ds3231_handle, ds3231_squarewave_freq_t *freq)
Get square wave frequency.
esp_err_t ds3231_alarm2_set_time(ds3231_handle_t ds3231_handle, ds3231_alarm2_match_t interr, struct tm timeinfo, ds3231_time_format_t format)
Set the time of interrupt.
esp_err_t ds3231_set_aging(ds3231_handle_t ds3231_handle, int8_t age)
Set the aging offset.
esp_err_t ds3231_get_time_valid(ds3231_handle_t ds3231_handle, bool *time_valid)
Check validity of the time module saved.
void * ds3231_handle_t
Handle of a DS3231 device.
Definition ds3231.h:86
esp_err_t ds3231_squarewave_battery_enable(ds3231_handle_t ds3231_handle)
Allow the device to run the square wave when powered from the battery.
esp_err_t ds3231_alarm_get_flags(ds3231_handle_t ds3231_handle, ds3231_alarm_flags_t *interr)
Get the flags of which alarm was triggered.
esp_err_t ds3231_alarm1_get_time(ds3231_handle_t ds3231_handle, ds3231_alarm1_match_t *interr, struct tm *timeinfo, ds3231_time_format_t *format)
Read alarm 1 config (match mode and alarm time).
esp_err_t ds3231_osc_battery_set_status(ds3231_handle_t ds3231_handle, bool enabled)
Enable or disable the oscillator when running on battery.
esp_err_t ds3231_get_temperature(ds3231_handle_t ds3231_handle, float *temp)
Read temperature from the chip.
esp_err_t ds3231_get_aging(ds3231_handle_t ds3231_handle, int8_t *age)
Get the aging offset.
esp_err_t ds3231_squarewave_enable(ds3231_handle_t ds3231_handle)
Enable generating of the square wave.
esp_err_t ds3231_squarewave_disable(ds3231_handle_t ds3231_handle)
Disable generating of the square wave.
esp_err_t ds3231_alarm1_interr_enable(ds3231_handle_t ds3231_handle)
Enable interrupts for alarm 1.
esp_err_t ds3231_alarm2_interr_disable(ds3231_handle_t ds3231_handle)
Disable interrupts for alarm 2.
esp_err_t ds3231_osc_battery_get_status(ds3231_handle_t ds3231_handle, bool *enabled)
Check whether the oscillator is enabled when running on battery or not.
esp_err_t ds3231_alarm2_get_time(ds3231_handle_t ds3231_handle, ds3231_alarm2_match_t *interr, struct tm *timeinfo, ds3231_time_format_t *format)
Read alarm 2 config (match mode and alarm time).
esp_err_t ds3231_alarm_clear_flags(ds3231_handle_t ds3231_handle, ds3231_alarm_flags_t interr)
Clear interrupt flags.
esp_err_t ds3231_get_time_format(ds3231_handle_t ds3231_handle, ds3231_time_format_t *timeformat)
Get the current time format.
esp_err_t ds3231_set_time(ds3231_handle_t ds3231_handle, struct tm timeinfo, ds3231_time_format_t format)
Set current date time.
esp_err_t ds3231_squarewave_32khz_disable(ds3231_handle_t ds3231_handle)
Disable 32 kHz output.
esp_err_t ds3231_alarm2_interr_enable(ds3231_handle_t ds3231_handle)
Enable interrupts for alarm 2.