123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #pragma once
- #ifndef DS3231_H
- #define DS3231_H
- /**
- * @brief Clock sructure.
- * @note structure of ds3231 data.
- */
- typedef struct {
- /**
- * @brief 00h: Seconds
- */
- uint8_t Sec;
- /**
- * @brief 01h: Minutes
- */
- uint8_t Min;
- /**
- * @brief 02h: Hours
- */
- uint8_t Hr;
- /**
- * @brief 03h: Week Day
- */
- uint8_t WD;
- /**
- * @brief 04h: Day of Month
- */
- uint8_t Day;
- /**
- * @brief 05h: Month
- */
- uint8_t Mon;
- /**
- * @brief 06h: Year
- */
- uint8_t Year;
- /**
- * @brief 07h: Alarm 1 Seconds
- */
- uint8_t A1SS;
- /**
- * @brief 08h: Alarm 1 Minutes
- */
- uint8_t A1MM;
- /**
- * @brief 09h: Alarm 1 Hours
- */
- uint8_t A1HH;
- /**
- * @brief 0Ah: Alarm 1 Day / Date
- */
- uint8_t A1DD;
- /**
- * @brief 0Bh: Alarm 2 Minutes
- */
- uint8_t A2MM;
- /**
- * @brief 0Ch: Alarm 2 Hours
- */
- uint8_t A2HH;
- /**
- * @brief 0Dh: Alarm 2 Day / Date
- */
- uint8_t A2DD;
- /**
- * @brief 0Eh: Control
- */
- uint8_t Ctrl;
- /**
- * @brief 0Fh: Control/Status
- */
- uint8_t CtSt;
- /**
- * @brief 10h: Aging Offset
- */
- uint8_t AgOffset;
- /**
- * @brief 11h: MSB of Temp
- */
- uint8_t TempH;
- /**
- * @brief 12h: LSB of Temp
- */
- uint8_t TempL;
- } rtc_t;
- i2c_status_t RTC_Init(void);
- i2c_status_t RTC_ReadAll(rtc_t * data);
- i2c_status_t RTC_ReadTime(rtc_t * data);
- i2c_status_t RTC_WriteTimeCalendar(rtc_t * data);
- i2c_status_t RTC_WriteTime(rtc_t * data);
- i2c_status_t RTC_WriteHHMM(rtc_t * data);
- i2c_status_t RTC_WriteCalendar(rtc_t * data);
- uint8_t bcd2bin(uint8_t bcd);
- uint8_t bin2bcd(uint8_t bin);
- #endif // DS3231_H
|