diff --git a/core/MySensorsCore.cpp b/core/MySensorsCore.cpp index eb999ad..678b66e 100644 --- a/core/MySensorsCore.cpp +++ b/core/MySensorsCore.cpp @@ -686,7 +686,7 @@ void _nodeLock(const char* str) CORE_DEBUG(PSTR("MCO:NLK:TSL\n")); // sleep transport #endif setIndication(INDICATION_SLEEP); - (void)hwSleep((unsigned long)1000*60*30); // Sleep for 30 min before resending LOCKED message + (void)hwSleep((uint32_t)1000*60*30); // Sleep for 30 min before resending LOCKED message setIndication(INDICATION_WAKEUP); } #else @@ -702,7 +702,7 @@ void _checkNodeLock(void) // Node is locked, check if unlock pin is asserted, else hang the node hwPinMode(MY_NODE_UNLOCK_PIN, INPUT_PULLUP); // Make a short delay so we are sure any large external nets are fully pulled - unsigned long enter = hwMillis(); + uint32_t enter = hwMillis(); while (hwMillis() - enter < 2) {} if (hwDigitalRead(MY_NODE_UNLOCK_PIN) == 0) { // Pin is grounded, reset lock counter diff --git a/core/MySensorsCore.h b/core/MySensorsCore.h index 78bcfbe..3008e28 100644 --- a/core/MySensorsCore.h +++ b/core/MySensorsCore.h @@ -411,7 +411,7 @@ void receive(const MyMessage &message) __attribute__((weak)); /** * @brief Callback for incoming time messages */ -void receiveTime(unsigned long) __attribute__((weak)); +void receiveTime(uint32_t) __attribute__((weak)); /** * @brief Node presenation */ diff --git a/hal/architecture/MyHw.h b/hal/architecture/MyHw.h index 3fd9c36..cd45a54 100644 --- a/hal/architecture/MyHw.h +++ b/hal/architecture/MyHw.h @@ -65,7 +65,7 @@ typedef uint8_t unique_id_t[16]; * @param ms Time to sleep, in [ms]. * @return MY_WAKE_UP_BY_TIMER. */ -int8_t hwSleep(unsigned long ms); +int8_t hwSleep(uint32_t ms); /** * Sleep for a defined time, using minimum power, or until woken by interrupt. @@ -74,7 +74,7 @@ int8_t hwSleep(unsigned long ms); * @param ms Time to sleep, in [ms]. * @return MY_WAKE_UP_BY_TIMER when woken by timer, or interrupt number when woken by interrupt. */ -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms); +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms); /** * Sleep for a defined time, using minimum power, or until woken by one of the interrupts. @@ -86,7 +86,7 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms); * @return MY_WAKE_UP_BY_TIMER when woken by timer, or interrupt number when woken by interrupt. */ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms); + uint32_t ms); /** * Retrieve unique hardware ID diff --git a/hal/architecture/MyHwAVR.cpp b/hal/architecture/MyHwAVR.cpp index b23cbf8..b862f92 100644 --- a/hal/architecture/MyHwAVR.cpp +++ b/hal/architecture/MyHwAVR.cpp @@ -119,7 +119,7 @@ void hwPowerDown(const uint8_t wdto) ADCSRA |= (1 << ADEN); } -void hwInternalSleep(unsigned long ms) +void hwInternalSleep(uint32_t ms) { // Sleeping with watchdog only supports multiples of 16ms. // Round up to next multiple of 16ms, to assure we sleep at least the @@ -138,19 +138,19 @@ void hwInternalSleep(unsigned long ms) } } -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { hwInternalSleep(ms); return MY_WAKE_UP_BY_TIMER; } -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { return hwSleep(interrupt,mode,INVALID_INTERRUPT_NUM,0u,ms); } int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms) + uint32_t ms) { // ATMega328P supports following modes to wake from sleep: LOW, CHANGE, RISING, FALLING // Datasheet states only LOW can be used with INT0/1 to wake from sleep, which is incorrect. @@ -208,9 +208,9 @@ inline void hwRandomNumberInit() // This function initializes the random number generator with a seed // of 32 bits. This method is good enough to earn FIPS 140-2 conform // random data. This should reach to generate 32 Bit for randomSeed(). - unsigned long seed = 0; - unsigned long start = millis(); - unsigned long timeout = start + 20; + uint32_t seed = 0; + uint32_t start = millis(); + uint32_t timeout = start + 20; // Trigger floating effect of an unconnected pin pinMode(MY_SIGNING_SOFT_RANDOMSEED_PIN, INPUT_PULLUP); diff --git a/hal/architecture/MyHwESP8266.cpp b/hal/architecture/MyHwESP8266.cpp index a11e1da..fcce169 100644 --- a/hal/architecture/MyHwESP8266.cpp +++ b/hal/architecture/MyHwESP8266.cpp @@ -89,14 +89,14 @@ ssize_t hwGetentropy(void *__buffer, size_t __length) return __length; } -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { // TODO: Not supported! (void)ms; return MY_SLEEP_NOT_POSSIBLE; } -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { // TODO: Not supported! (void)interrupt; @@ -106,7 +106,7 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) } int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms) + uint32_t ms) { // TODO: Not supported! (void)interrupt1; diff --git a/hal/architecture/MyHwLinuxGeneric.cpp b/hal/architecture/MyHwLinuxGeneric.cpp index 8c6649d..6256e66 100644 --- a/hal/architecture/MyHwLinuxGeneric.cpp +++ b/hal/architecture/MyHwLinuxGeneric.cpp @@ -68,7 +68,7 @@ void hwWriteConfig(int addr, uint8_t value) void hwRandomNumberInit() { - unsigned long seed=0; + uint32_t seed=0; if (randomFp != NULL) { fclose(randomFp); @@ -87,7 +87,7 @@ ssize_t hwGetentropy(void *__buffer, size_t __length) return(fread(__buffer, 1, __length, randomFp)); } -unsigned long hwMillis() +uint32_t hwMillis() { return millis(); } @@ -100,7 +100,7 @@ bool hwUniqueID(unique_id_t *uniqueID) } // Not supported! -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { (void)ms; @@ -108,7 +108,7 @@ int8_t hwSleep(unsigned long ms) } // Not supported! -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { (void)interrupt; (void)mode; @@ -119,7 +119,7 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) // Not supported! int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms) + uint32_t ms) { (void)interrupt1; (void)mode1; diff --git a/hal/architecture/MyHwLinuxGeneric.h b/hal/architecture/MyHwLinuxGeneric.h index b02e216..3c57b98 100644 --- a/hal/architecture/MyHwLinuxGeneric.h +++ b/hal/architecture/MyHwLinuxGeneric.h @@ -1,4 +1,4 @@ -/* +/* * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each @@ -59,7 +59,7 @@ inline void hwWriteConfig(int addr, uint8_t value); inline void hwRandomNumberInit(); ssize_t hwGetentropy(void *__buffer, size_t __length); #define MY_HW_HAS_GETENTROPY -inline unsigned long hwMillis(); +inline uint32_t hwMillis(); #ifdef MY_RF24_IRQ_PIN static pthread_mutex_t hw_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/hal/architecture/MyHwNRF5.cpp b/hal/architecture/MyHwNRF5.cpp index 00afe48..024c4eb 100644 --- a/hal/architecture/MyHwNRF5.cpp +++ b/hal/architecture/MyHwNRF5.cpp @@ -210,7 +210,7 @@ void hwReboot() static volatile bool nrf5_rtc_event_triggered; static volatile bool nrf5_pwr_hfclk; -void hwSleepPrepare(unsigned long ms) +void hwSleepPrepare(uint32_t ms) { // Enable low power sleep mode NRF_POWER->TASKS_LOWPWR = 1; @@ -271,7 +271,7 @@ void hwSleepPrepare(unsigned long ms) } } -void hwSleepEnd(unsigned long ms) +void hwSleepEnd(uint32_t ms) { // Start HFCLK if (nrf5_pwr_hfclk) { @@ -319,7 +319,7 @@ inline void hwSleep() __WFE(); } -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { hwSleepPrepare(ms); while (nrf5_rtc_event_triggered == false) { @@ -329,13 +329,13 @@ int8_t hwSleep(unsigned long ms) return MY_WAKE_UP_BY_TIMER; } -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { return hwSleep(interrupt, mode, INVALID_INTERRUPT_NUM, 0u, ms); } int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, - uint8_t mode2, unsigned long ms) + uint8_t mode2, uint32_t ms) { // Disable interrupts until going to sleep, otherwise interrupts occurring // between attachInterrupt() diff --git a/hal/architecture/MyHwSAMD.cpp b/hal/architecture/MyHwSAMD.cpp index c83eca7..2533da6 100644 --- a/hal/architecture/MyHwSAMD.cpp +++ b/hal/architecture/MyHwSAMD.cpp @@ -95,14 +95,14 @@ void hwReboot(void) while (true); } -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { // TODO: Not supported! (void)ms; return MY_SLEEP_NOT_POSSIBLE; } -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { // TODO: Not supported! (void)interrupt; @@ -112,7 +112,7 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) } int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms) + uint32_t ms) { // TODO: Not supported! (void)interrupt1; diff --git a/hal/architecture/MyHwSTM32F1.cpp b/hal/architecture/MyHwSTM32F1.cpp index f213ba0..ccd7013 100644 --- a/hal/architecture/MyHwSTM32F1.cpp +++ b/hal/architecture/MyHwSTM32F1.cpp @@ -89,14 +89,14 @@ void hwWriteConfig(const int addr, uint8_t value) hwWriteConfigBlock(&value, reinterpret_cast(addr), 1); } -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { // TODO: Not supported! (void)ms; return MY_SLEEP_NOT_POSSIBLE; } -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { // TODO: Not supported! (void)interrupt; @@ -106,7 +106,7 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) } int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms) + uint32_t ms) { // TODO: Not supported! (void)interrupt1; diff --git a/hal/architecture/MyHwTeensy3.cpp b/hal/architecture/MyHwTeensy3.cpp index c9e7702..6355ce9 100644 --- a/hal/architecture/MyHwTeensy3.cpp +++ b/hal/architecture/MyHwTeensy3.cpp @@ -60,14 +60,14 @@ void hwReboot(void) while (true); } -int8_t hwSleep(unsigned long ms) +int8_t hwSleep(uint32_t ms) { // TODO: Not supported! (void)ms; return MY_SLEEP_NOT_POSSIBLE; } -int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) +int8_t hwSleep(uint8_t interrupt, uint8_t mode, uint32_t ms) { // TODO: Not supported! (void)interrupt; @@ -77,7 +77,7 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) } int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, - unsigned long ms) + uint32_t ms) { // TODO: Not supported! (void)interrupt1;