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