123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- #ifndef TM_RTC_H
- #define TM_RTC_H 171
- #ifdef __cplusplus
- extern C {
- #endif
- #include "stm32f4xx.h"
- #include "attributes.h"
- #ifndef RTC_SYNC_PREDIV
- #define RTC_SYNC_PREDIV 0x3FF
- #endif
- #ifndef RTC_ASYNC_PREDIV
- #define RTC_ASYNC_PREDIV 0x1F
- #endif
- #ifndef RTC_PRIORITY
- #define RTC_PRIORITY 0x04
- #endif
- #ifndef RTC_WAKEUP_SUBPRIORITY
- #define RTC_WAKEUP_SUBPRIORITY 0x00
- #endif
- #ifndef RTC_ALARM_SUBPRIORITY
- #define RTC_ALARM_SUBPRIORITY 0x01
- #endif
-
-
- typedef struct {
- uint8_t seconds;
- uint16_t subseconds;
- uint8_t minutes;
- uint8_t hours;
- uint8_t day;
- uint8_t date;
- uint8_t month;
- uint8_t year;
- uint32_t unix;
- } TM_RTC_t;
- typedef TM_RTC_t TM_RTC_Time_t;
- typedef enum {
- TM_RTC_Result_Ok,
- TM_RTC_Result_Error
- } TM_RTC_Result_t;
- typedef enum {
- TM_RTC_Format_BIN = 0x00,
- TM_RTC_Format_BCD
- } TM_RTC_Format_t;
- typedef enum {
- TM_RTC_Int_Disable = 0x00,
- TM_RTC_Int_60s,
- TM_RTC_Int_30s,
- TM_RTC_Int_15s,
- TM_RTC_Int_10s,
- TM_RTC_Int_5s,
- TM_RTC_Int_2s,
- TM_RTC_Int_1s,
- TM_RTC_Int_500ms,
- TM_RTC_Int_250ms,
- TM_RTC_Int_125ms
- } TM_RTC_Int_t;
- typedef enum {
- TM_RTC_ClockSource_Internal = 0x00,
- TM_RTC_ClockSource_External
- } TM_RTC_ClockSource_t;
- typedef enum {
- TM_RTC_AlarmType_DayInWeek,
- TM_RTC_AlarmType_DayInMonth
- } TM_RTC_AlarmType_t;
- typedef enum {
- TM_RTC_Alarm_A = 0x00,
- TM_RTC_Alarm_B
- } TM_RTC_Alarm_t;
- typedef struct {
- TM_RTC_AlarmType_t alarmtype;
- uint8_t seconds;
- uint8_t minutes;
- uint8_t hours;
- uint8_t day;
- } TM_RTC_AlarmTime_t;
- void TM_RTC_SetDataTimeUnix(uint32_t unixTime);
- void TM_RTC_Correction(float utc);
- uint32_t TM_RTC_Init(TM_RTC_ClockSource_t source);
- uint32_t TM_RTC_GetUnixTimeStamp(TM_RTC_t* data);
- void TM_RTC_GetDateTimeFromUnix(TM_RTC_t* data, uint32_t unix);
- void TM_RTC_Interrupts(TM_RTC_Int_t int_value);
- TM_RTC_Result_t TM_RTC_SetDateTime(TM_RTC_t* data, TM_RTC_Format_t format);
- TM_RTC_Result_t TM_RTC_SetDateTimeString(char* str);
- void TM_RTC_GetDateTime(TM_RTC_t* data, TM_RTC_Format_t format);
- uint8_t TM_RTC_GetDaysInMonth(uint8_t month, uint8_t year);
- uint16_t TM_RTC_GetDaysInYear(uint8_t year);
- void TM_RTC_WriteBackupRegister(uint8_t location, uint32_t value);
- uint32_t TM_RTC_ReadBackupRegister(uint8_t location);
- void TM_RTC_SetAlarm(TM_RTC_Alarm_t Alarm, TM_RTC_AlarmTime_t* AlarmTime, TM_RTC_Format_t format);
- void TM_RTC_DisableAlarm(TM_RTC_Alarm_t Alarm);
- void TM_RTC_RequestHandler(void);
- void TM_RTC_AlarmAHandler(void);
- void TM_RTC_AlarmBHandler(void);
- void RTC_SetDebugProfTime(void);
- void RTC_SetProfTime(char *date);
- uint32_t RTC_GetUnixTime(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|