RP2040: Enable ExternalNotification and RangeTest Module, set randomSeed (#2664)

* Enable ExternalNotification (and RangeTest) Module

* Set a random seed at boot
This commit is contained in:
GUVWAF 2023-07-29 14:19:58 +02:00 committed by GitHub
parent 3d697f8cf4
commit ffcc1a0275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 4 deletions

View File

@ -458,6 +458,11 @@ void setup()
#ifdef ARCH_NRF52 #ifdef ARCH_NRF52
nrf52Setup(); nrf52Setup();
#endif #endif
#ifdef ARCH_RP2040
rp2040Setup();
#endif
// We do this as early as possible because this loads preferences from flash // 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 // but we need to do this after main cpu iniot (esp32setup), because we need the random seed set
nodeDB.init(); nodeDB.init();

View File

@ -68,7 +68,7 @@ extern uint32_t serialSinceMsec;
// This will suppress the current delay and instead try to run ASAP. // This will suppress the current delay and instead try to run ASAP.
extern bool runASAP; extern bool runASAP;
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds(); void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds();
meshtastic_DeviceMetadata getDeviceMetadata(); meshtastic_DeviceMetadata getDeviceMetadata();

View File

@ -24,7 +24,7 @@
#include "modules/esp32/AudioModule.h" #include "modules/esp32/AudioModule.h"
#include "modules/esp32/StoreForwardModule.h" #include "modules/esp32/StoreForwardModule.h"
#endif #endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) #if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)
#include "modules/ExternalNotificationModule.h" #include "modules/ExternalNotificationModule.h"
#include "modules/RangeTestModule.h" #include "modules/RangeTestModule.h"
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2) #if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(CONFIG_IDF_TARGET_ESP32S2)
@ -81,7 +81,7 @@ void setupModules()
storeForwardModule = new StoreForwardModule(); storeForwardModule = new StoreForwardModule();
#endif #endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) #if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)
externalNotificationModule = new ExternalNotificationModule(); externalNotificationModule = new ExternalNotificationModule();
new RangeTestModule(); new RangeTestModule();
#endif #endif

View File

@ -28,3 +28,11 @@ void getMacAddr(uint8_t *dmac)
dmac[1] = src.id[3]; dmac[1] = src.id[3];
dmac[0] = src.id[2]; 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());
}

View File

@ -19,6 +19,7 @@
// SDA = 4 // SDA = 4
// SCL = 5 // SCL = 5
#define EXT_NOTIFY_OUT 22
#define BUTTON_PIN 17 #define BUTTON_PIN 17
#define LED_PIN PIN_LED #define LED_PIN PIN_LED

View File

@ -19,6 +19,7 @@
// SDA = 4 // SDA = 4
// SCL = 5 // SCL = 5
#define EXT_NOTIFY_OUT 22
#define BUTTON_PIN 17 #define BUTTON_PIN 17
#define BATTERY_PIN 26 #define BATTERY_PIN 26