Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Service: merge STM32H7 and NANO RP2040 RTC functions #394

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 14 additions & 43 deletions src/utility/time/TimeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,10 @@ void samd_setRTC(unsigned long time);
unsigned long samd_getRTC();
#endif

#ifdef ARDUINO_NANO_RP2040_CONNECT
void rp2040_connect_initRTC();
void rp2040_connect_setRTC(unsigned long time);
unsigned long rp2040_connect_getRTC();
#endif

#ifdef BOARD_STM32H7
void stm32h7_initRTC();
void stm32h7_setRTC(unsigned long time);
unsigned long stm32h7_getRTC();
#ifdef ARDUINO_ARCH_MBED
void mbed_initRTC();
void mbed_setRTC(unsigned long time);
unsigned long mbed_getRTC();
#endif

#ifdef ARDUINO_ARCH_ESP32
Expand Down Expand Up @@ -337,10 +331,8 @@ void TimeServiceClass::initRTC()
{
#if defined (ARDUINO_ARCH_SAMD)
samd_initRTC();
#elif defined (ARDUINO_NANO_RP2040_CONNECT)
rp2040_connect_initRTC();
#elif defined (BOARD_STM32H7)
stm32h7_initRTC();
#elif defined (ARDUINO_ARCH_MBED)
mbed_initRTC();
#elif defined (ARDUINO_ARCH_ESP32)
esp32_initRTC();
#elif defined (ARDUINO_ARCH_ESP8266)
Expand All @@ -356,10 +348,8 @@ void TimeServiceClass::setRTC(unsigned long time)
{
#if defined (ARDUINO_ARCH_SAMD)
samd_setRTC(time);
#elif defined (ARDUINO_NANO_RP2040_CONNECT)
rp2040_connect_setRTC(time);
#elif defined (BOARD_STM32H7)
stm32h7_setRTC(time);
#elif defined (ARDUINO_ARCH_MBED)
mbed_setRTC(time);
#elif defined (ARDUINO_ARCH_ESP32)
esp32_setRTC(time);
#elif defined (ARDUINO_ARCH_ESP8266)
Expand All @@ -375,10 +365,8 @@ unsigned long TimeServiceClass::getRTC()
{
#if defined (ARDUINO_ARCH_SAMD)
return samd_getRTC();
#elif defined (ARDUINO_NANO_RP2040_CONNECT)
return rp2040_connect_getRTC();
#elif defined (BOARD_STM32H7)
return stm32h7_getRTC();
#elif defined (ARDUINO_ARCH_MBED)
return mbed_getRTC();
#elif defined (ARDUINO_ARCH_ESP32)
return esp32_getRTC();
#elif defined (ARDUINO_ARCH_ESP8266)
Expand Down Expand Up @@ -447,35 +435,18 @@ unsigned long samd_getRTC()
}
#endif

#ifdef ARDUINO_NANO_RP2040_CONNECT
void rp2040_connect_initRTC()
{
/* Nothing to do */
}

void rp2040_connect_setRTC(unsigned long time)
{
set_time(time);
}

unsigned long rp2040_connect_getRTC()
{
return time(NULL);
}
#endif

#ifdef BOARD_STM32H7
void stm32h7_initRTC()
#ifdef ARDUINO_ARCH_MBED
void mbed_initRTC()
{
/* Nothing to do */
}

void stm32h7_setRTC(unsigned long time)
void mbed_setRTC(unsigned long time)
{
set_time(time);
}

unsigned long stm32h7_getRTC()
unsigned long mbed_getRTC()
{
return time(NULL);
}
Expand Down
Loading