rcttime.cpp: mutex param added
This commit is contained in:
parent
c0abe0652e
commit
e18f9fdcae
@ -99,6 +99,7 @@ typedef struct {
|
||||
|
||||
enum sendprio_t { prio_low, prio_normal, prio_high };
|
||||
enum timesource_t { _gps, _rtc, _lora, _unsynced };
|
||||
enum mutexselect_t { no_mutex, do_mutex};
|
||||
|
||||
extern std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
|
||||
extern std::array<uint64_t, 0xff>::iterator it;
|
||||
|
@ -9,7 +9,7 @@
|
||||
extern RtcDS3231<TwoWire> Rtc; // make RTC instance globally available
|
||||
|
||||
uint8_t rtc_init(void);
|
||||
uint8_t set_rtctime(time_t t);
|
||||
uint8_t set_rtctime(time_t t, mutexselect_t mutex);
|
||||
void sync_rtctime(void);
|
||||
time_t get_rtctime(void);
|
||||
float get_rtctemp(void);
|
||||
|
@ -46,13 +46,14 @@ uint8_t rtc_init(void) {
|
||||
|
||||
} // rtc_init()
|
||||
|
||||
uint8_t set_rtctime(time_t t) { // t is UTC in seconds epoch time
|
||||
if (I2C_MUTEX_LOCK()) {
|
||||
Rtc.SetDateTime(RtcDateTime(t - SECS_YR_2000)); // epoch -> sec2000
|
||||
uint8_t set_rtctime(time_t t, mutexselect_t mutex) { // t is sec epoch time
|
||||
if (!mutex || I2C_MUTEX_LOCK()) {
|
||||
#ifdef RTC_INT // sync rtc 1Hz pulse on top of second
|
||||
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone); // off
|
||||
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeClock); // start
|
||||
#endif
|
||||
Rtc.SetDateTime(RtcDateTime(t - SECS_YR_2000)); // epoch -> sec2000
|
||||
if (mutex)
|
||||
I2C_MUTEX_UNLOCK();
|
||||
ESP_LOGI(TAG, "RTC time synced");
|
||||
return 1; // success
|
||||
|
Loading…
Reference in New Issue
Block a user