From 55b38a7b02ca403d84de930fe61bbbd0d1652eb6 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 12 Apr 2021 13:25:55 +0800 Subject: [PATCH] RAK4631 is almost feature complete --- docs/software/rak-wizblock.md | 24 ++++++----------- proto | 2 +- src/configuration.h | 4 +++ src/main.cpp | 9 ++++--- src/mesh/generated/mesh.pb.h | 1 + src/nrf52/main-nrf52.cpp | 34 ++++++++++++------------ variants/WisCore_RAK4631_Board/variant.h | 3 --- 7 files changed, 36 insertions(+), 41 deletions(-) diff --git a/docs/software/rak-wizblock.md b/docs/software/rak-wizblock.md index 95004c62..7f6b8be4 100644 --- a/docs/software/rak-wizblock.md +++ b/docs/software/rak-wizblock.md @@ -4,13 +4,17 @@ https://docs.rakwireless.com/Product-Categories/WisBlock/Quickstart/#wisblock-base-2 +FIXME - list required, recommended and optional components + GPS module: Supposedly "Install in slot A only" but I think installing on the back would fit better with the OLED. FIXME. https://docs.rakwireless.com/Product-Categories/WisBlock/RAK1910/Overview/#product-description -ST KPS22HB -baro sensor +ST LPS22HB +baro & temp sensor, i2c address 0x5c https://docs.rakwireless.com/Product-Categories/WisBlock/RAK1902/Overview/#product-description +https://www.st.com/en/mems-and-sensors/lps22hb.html +https://www.st.com/resource/en/datasheet/lps22hb.pdf OLED https://docs.rakwireless.com/Product-Categories/WisBlock/RAK1921/Overview/#product-features @@ -27,29 +31,17 @@ https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Datasheet/#spec ## TODO +* Turn off external 3V3 supply when not using GPS to save power! > 3V3_S is another 3.3 V power supply, it can be controlled by the MCU in order to disconnect the power sensors during idle periods to save power. 3V3_S is controlled by IO2 pin on the WisBlock Core board. Set IO2=1, 3V3_S is on. Set IO2=0, 3V3_S is off. - -* DONE solder header -* DONE attach antenna -* get building (LORA disabled) -* DONE FIX LEDs -* DONE FIX BUTTONs -* DONE FIX I2C assignment -* FIX LORA SPI -* FIX GPS GPIO assignment -* Disable Bluetooth -* Disable LORA -* Boot -* Enable LORA but no TX -* Enable LORA TX * Enable bluetooth * Relase as standard part of build (including UF2s) * Make this doc into a nice HOWTO: what to order, how to connect (which device in which slots), how to install software * Setup battery voltage sensing * Set bluetooth PIN support * Confirm low power draw +* Confirm that OLED works * send in PR to https://github.com/geeksville/WisBlock for boards define * \ No newline at end of file diff --git a/proto b/proto index ff66c549..6e05f72a 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit ff66c549498052a1a3cf75f8ad1a66a4adcdc413 +Subproject commit 6e05f72a1a75322bcbea21980386a61b2945fd4f diff --git a/src/configuration.h b/src/configuration.h index f0d3a0a5..1e58b700 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -409,6 +409,10 @@ along with this program. If not, see . #define HW_VENDOR HardwareModel_PPR +#elif defined(RAK4630) + +#define HW_VENDOR HardwareModel_RAK4631 + #elif NRF52_SERIES #define HW_VENDOR HardwareModel_NRF52_UNKNOWN diff --git a/src/main.cpp b/src/main.cpp index 54718875..c6bebe36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -427,11 +427,12 @@ void setup() readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time) #ifdef GENIEBLOCKS - I'm intentionally breaking your build so you see this note. Feel free to revert if not correct. I think you can - removed this code by instead defining PIN_GPS_RESET and use the shared code in GPS.cpp instead. + Im intentionally breaking your build so you see this note.Feel free to revert if not correct.I think you can + remove this GPS_RESET_N code by instead defining PIN_GPS_RESET and + use the shared code in GPS.cpp instead.- geeksville - // gps setup - pinMode(GPS_RESET_N, OUTPUT); + // gps setup + pinMode(GPS_RESET_N, OUTPUT); pinMode(GPS_EXTINT, OUTPUT); digitalWrite(GPS_RESET_N, HIGH); digitalWrite(GPS_EXTINT, LOW); diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index d31fee6f..eb771eba 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -21,6 +21,7 @@ typedef enum _HardwareModel { HardwareModel_TBEAM0p7 = 6, HardwareModel_T_ECHO = 7, HardwareModel_TLORA_V1_1p3 = 8, + HardwareModel_RAK4631 = 9, HardwareModel_LORA_RELAY_V1 = 32, HardwareModel_NRF52840DK = 33, HardwareModel_PPR = 34, diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index 2c5bcac8..abb99042 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -44,10 +44,23 @@ void getMacAddr(uint8_t *dmac) } } +static void initBrownout() +{ + auto vccthresh = POWER_POFCON_THRESHOLD_V17; + + auto err_code = sd_power_pof_enable(POWER_POFCON_POF_Enabled); + assert(err_code == NRF_SUCCESS); + + err_code = sd_power_pof_threshold_set(vccthresh); + assert(err_code == NRF_SUCCESS); + + // We don't bother with setting up brownout if soft device is disabled - because during production we always use softdevice +} + NRF52Bluetooth *nrf52Bluetooth; static bool bleOn = false; -static const bool useSoftDevice = false; // Set to false for easier debugging +static const bool useSoftDevice = true; // Set to false for easier debugging void setBluetoothEnable(bool on) { @@ -59,6 +72,9 @@ void setBluetoothEnable(bool on) else { nrf52Bluetooth = new NRF52Bluetooth(); nrf52Bluetooth->setup(); + + // We delay brownout init until after BLE because BLE starts soft device + initBrownout(); } } } else { @@ -81,20 +97,6 @@ int printf(const char *fmt, ...) return res; } -void initBrownout() -{ - auto vccthresh = POWER_POFCON_THRESHOLD_V17; - - if (useSoftDevice) { - auto err_code = sd_power_pof_enable(POWER_POFCON_POF_Enabled); - assert(err_code == NRF_SUCCESS); - - err_code = sd_power_pof_threshold_set(vccthresh); - assert(err_code == NRF_SUCCESS); - } - // We don't bother with setting up brownout if soft device is disabled - because during production we always use softdevice -} - void checkSDEvents() { if (useSoftDevice) { @@ -147,8 +149,6 @@ void nrf52Setup() // randomSeed(r); DEBUG_MSG("FIXME, call randomSeed\n"); // ::printf("TESTING PRINTF\n"); - - initBrownout(); } void cpuDeepSleep(uint64_t msecToWake) diff --git a/variants/WisCore_RAK4631_Board/variant.h b/variants/WisCore_RAK4631_Board/variant.h index 1b782839..00016d24 100644 --- a/variants/WisCore_RAK4631_Board/variant.h +++ b/variants/WisCore_RAK4631_Board/variant.h @@ -171,9 +171,6 @@ static const uint8_t SCK = PIN_SPI_SCK; #define GPS_RX_PIN PIN_SERIAL1_RX #define GPS_TX_PIN PIN_SERIAL1_TX -// Meshtastic specific flags -#define USE_SEGGER - #ifdef __cplusplus } #endif