Files
northskysl d9542eb709 STM32 RTC Hardware Support & User Interface for Watch and Calendar (#128)
* Update rg_main.c

Added a menu to view and configure RTC parameters. It is activated by pressing 'TIME' button in retro-go main menu.

* Update main.c

Enable LSE oscillator and enable it as RTC clock source. Additionally enable CRS Sync LSE.

* Added time display to RTC menu

Added time display to RTC menu and also modified RTC initialization code so that it does not set the RTC date and time. Assuming that a fresh RTC has sensible values.

* Add date display to time menu

Added date display to time menu

* Fix predivs for LSE

Fixed predivs for LSE clock

* move RTC stuff to rg_rtc

Consolidate all RTC functions to rg_rtc. So far getters have been implemented only.

* Time setup UI + setters for Time

Setters for Time have been implemented and Time setup has been added into the UI to use them.

* Date setup added

Date setup with callbacks added

* Add real time datetime display

Modified the time menu to display and update in real time.

* Add a function to return Unix time

Unix time is returned as a 64-bit time_t. Casting to uint32_t will yield time in seconds since 1st Jan 1970.

* Fix setters' return type

Fixing warnings about wrong setter return type.

* Update rg_rtc.h

Missed the .h while updating return types of setters.

* Update rg_rtc.c

Add a nicer year display

* Reactivate LSI

This should fix an issue with DACs that causes Brightness control not to work.
2021-08-12 14:34:00 +02:00

61 lines
2.0 KiB
C

#ifndef _GW_RTC_H_
#define _GW_RTC_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"
#include "odroid_system.h"
/* Exported constants --------------------------------------------------------*/
extern RTC_TimeTypeDef GW_currentTime;
extern RTC_DateTypeDef GW_currentDate;
extern const char * GW_RTC_Weekday[];
/* Exported functions prototypes ---------------------------------------------*/
// Getters
uint8_t GW_GetCurrentHour(void);
uint8_t GW_GetCurrentMinute(void);
uint8_t GW_GetCurrentSecond(void);
uint8_t GW_GetCurrentMonth(void);
uint8_t GW_GetCurrentDay(void);
uint8_t GW_GetCurrentWeekday(void);
uint8_t GW_GetCurrentYear(void);
time_t GW_GetUnixTime(void);
// Setters
void GW_SetCurrentHour(const uint8_t hour);
void GW_SetCurrentMinute(const uint8_t minute);
void GW_SetCurrentSecond(const uint8_t second);
void GW_SetCurrentMonth(const uint8_t month);
void GW_SetCurrentDay(const uint8_t day);
void GW_SetCurrentWeekday(const uint8_t weekday);
void GW_SetCurrentYear(const uint8_t year);
// Callbacks for UI purposes
bool hour_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool minute_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool second_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool month_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool day_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool weekday_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool year_update_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool time_display_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
bool date_display_cb(odroid_dialog_choice_t *option, odroid_dialog_event_t event, uint32_t repeat);
#ifdef __cplusplus
}
#endif
#endif