15#ifndef STM32_DS3231_DS3231_H_
16#define STM32_DS3231_DS3231_H_
73#define DS3231_I2C_ADDRESS (0x68U << 1)
76#define DS3231_DEFAULT_MAX_ATTEMPTS 3U
79#define DS3231_I2C_TIMEOUT_MS 100U
82#define DS3231_YEAR_MIN 2000U
85#define DS3231_YEAR_MAX 2099U
88#define DS3231_EPOCH_MIN 946684800U
91#define DS3231_EPOCH_MAX 4102444799U
DS3231_Status_t ds3231GetEpoch(DS3231_t *dev, uint32_t *epochSeconds)
Read the current time as seconds since 1970-01-01 00:00:00.
DS3231_Status_t ds3231SetTime(DS3231_t *dev, const DS3231_TIME_t *time)
Set the date and time.
DS3231_Status_t ds3231TimeToEpoch(const DS3231_TIME_t *time, uint32_t *epochSeconds)
Convert a date and time to seconds since 1970-01-01 00:00:00 (UTC, no leap seconds).
DS3231_Status_t ds3231EpochToTime(uint32_t epochSeconds, DS3231_TIME_t *time)
Convert seconds since 1970-01-01 00:00:00 (UTC, no leap seconds) to a date and time.
@ DS3231_ERR_INVALID_DATA
DS3231_Status_t ds3231GetTime(DS3231_t *dev, DS3231_TIME_t *time)
Read the current date and time.
bool ds3231IsTimeValid(const DS3231_TIME_t *time)
Check that a date and time are valid for the DS3231.
DS3231_Status_t ds3231SetEpoch(DS3231_t *dev, uint32_t epochSeconds)
Set the time from seconds since 1970-01-01 00:00:00.
DS3231_Status_t ds3231ClearOscillatorStopFlag(DS3231_t *dev)
Clear the oscillator stop flag.
DS3231_Status_t ds3231IsOscillatorStopped(DS3231_t *dev, bool *stopped)
Find out whether the oscillator has stopped since the flag was last cleared.
DS3231_Status_t ds3231Init(DS3231_t *dev, I2C_HandleTypeDef *hi2c, uint8_t maxAttempts)
Set up a driver handle and check that a DS3231 answers on the bus.
: Header for main.c file. This file contains the common defines of the application.
A calendar date and time, always 24-hour clock.
HAL_StatusTypeDef lastStatus