diff --git a/src/main.cpp b/src/main.cpp index 101ef51d8..8559c32f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -458,6 +458,11 @@ void setup() #ifdef ARCH_NRF52 nrf52Setup(); #endif + +#ifdef ARCH_RP2040 + rp2040Setup(); +#endif + // We do this as early as possible because this loads preferences from flash // but we need to do this after main cpu iniot (esp32setup), because we need the random seed set nodeDB.init(); diff --git a/src/main.h b/src/main.h index b513d6478..301e8a10c 100644 --- a/src/main.h +++ b/src/main.h @@ -68,7 +68,7 @@ extern uint32_t serialSinceMsec; // This will suppress the current delay and instead try to run ASAP. extern bool runASAP; -void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds(); +void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds(); meshtastic_DeviceMetadata getDeviceMetadata(); diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 61de2c265..3f1fed427 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -24,7 +24,7 @@ #include "modules/esp32/AudioModule.h" #include "modules/esp32/StoreForwardModule.h" #endif -#if defined(ARCH_ESP32) || defined(ARCH_NRF52) +#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) #include "modules/ExternalNotificationModule.h" #include "modules/RangeTestModule.h" #if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2) @@ -81,7 +81,7 @@ void setupModules() storeForwardModule = new StoreForwardModule(); #endif -#if defined(ARCH_ESP32) || defined(ARCH_NRF52) +#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) externalNotificationModule = new ExternalNotificationModule(); new RangeTestModule(); #endif @@ -92,4 +92,4 @@ void setupModules() // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra // acks routingModule = new RoutingModule(); -} +} \ No newline at end of file diff --git a/src/platform/rp2040/main-rp2040.cpp b/src/platform/rp2040/main-rp2040.cpp index 5e24bf03c..1d7f8fe70 100644 --- a/src/platform/rp2040/main-rp2040.cpp +++ b/src/platform/rp2040/main-rp2040.cpp @@ -27,4 +27,12 @@ void getMacAddr(uint8_t *dmac) dmac[2] = src.id[4]; dmac[1] = src.id[3]; dmac[0] = src.id[2]; +} + +void rp2040Setup() +{ + /* Sets a random seed to make sure we get different random numbers on each boot. + Taken from CPU cycle counter and ROSC oscillator, so should be pretty random. + */ + randomSeed(rp2040.hwrand32()); } \ No newline at end of file diff --git a/variants/rpipico/variant.h b/variants/rpipico/variant.h index fb4b9bd75..71d1bd159 100644 --- a/variants/rpipico/variant.h +++ b/variants/rpipico/variant.h @@ -19,6 +19,7 @@ // SDA = 4 // SCL = 5 +#define EXT_NOTIFY_OUT 22 #define BUTTON_PIN 17 #define LED_PIN PIN_LED diff --git a/variants/rpipicow/variant.h b/variants/rpipicow/variant.h index 59f8d2ec2..ac393d4d3 100644 --- a/variants/rpipicow/variant.h +++ b/variants/rpipicow/variant.h @@ -19,6 +19,7 @@ // SDA = 4 // SCL = 5 +#define EXT_NOTIFY_OUT 22 #define BUTTON_PIN 17 #define BATTERY_PIN 26