diff --git a/src/utility/time/RTCMillis.cpp b/src/utility/time/RTCMillis.cpp index d7debd26..7ceb2743 100644 --- a/src/utility/time/RTCMillis.cpp +++ b/src/utility/time/RTCMillis.cpp @@ -21,7 +21,7 @@ #include "AIoTC_Config.h" -#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) +#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) #include #include "RTCMillis.h" @@ -61,4 +61,4 @@ unsigned long RTCMillis::get() return _last_rtc_update_value; } -#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 */ +#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 || ARDUINO_RASPBERRY_PI_PICO_W */ diff --git a/src/utility/time/RTCMillis.h b/src/utility/time/RTCMillis.h index ab35b953..03d35294 100644 --- a/src/utility/time/RTCMillis.h +++ b/src/utility/time/RTCMillis.h @@ -18,7 +18,7 @@ #ifndef ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ #define ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ -#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) +#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) /************************************************************************************** * INCLUDE @@ -45,6 +45,6 @@ class RTCMillis }; -#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 */ +#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 || ARDUINO_RASPBERRY_PI_PICO_W */ #endif /* ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ */ diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 1801c298..fb7272fc 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -27,7 +27,7 @@ #include "NTPUtils.h" #include "TimeService.h" -#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) +#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) #include "RTCMillis.h" #elif defined(ARDUINO_ARCH_SAMD) #include @@ -41,7 +41,7 @@ * GLOBAL VARIABLES **************************************************************************************/ -#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) +#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) RTCMillis rtc; #elif defined(ARDUINO_ARCH_SAMD) RTCZero rtc; @@ -89,6 +89,12 @@ void renesas_setRTC(unsigned long time); unsigned long renesas_getRTC(); #endif +#ifdef ARDUINO_RASPBERRY_PI_PICO_W +void pico_w_initRTC(); +void pico_w_setRTC(unsigned long time); +unsigned long pico_w_getRTC(); +#endif + #endif /* HAS_NOTECARD */ /************************************************************************************** @@ -356,6 +362,7 @@ void TimeServiceClass::initRTC() #elif defined (ARDUINO_ARCH_RENESAS) renesas_initRTC(); #elif defined (ARDUINO_RASPBERRY_PI_PICO_W) + pico_w_initRTC(); #else #error "RTC not available for this architecture" #endif @@ -376,6 +383,7 @@ void TimeServiceClass::setRTC(unsigned long time) #elif defined (ARDUINO_ARCH_RENESAS) renesas_setRTC(time); #elif defined (ARDUINO_RASPBERRY_PI_PICO_W) + pico_w_setRTC(time); #else #error "RTC not available for this architecture" #endif @@ -396,7 +404,7 @@ unsigned long TimeServiceClass::getRTC() #elif defined (ARDUINO_ARCH_RENESAS) return renesas_getRTC(); #elif defined (ARDUINO_RASPBERRY_PI_PICO_W) - return 1; + return pico_w_getRTC(); #else #error "RTC not available for this architecture" #endif @@ -548,6 +556,23 @@ unsigned long renesas_getRTC() } #endif +#ifdef ARDUINO_RASPBERRY_PI_PICO_W +void pico_w_initRTC() +{ + rtc.begin(); +} + +void pico_w_setRTC(unsigned long time) +{ + rtc.set(time); +} + +unsigned long pico_w_getRTC() +{ + return rtc.get(); +} +#endif + #endif /* HAS_NOTECARD */ /******************************************************************************