Add RAK WisMesh Repeater Mini V2 and HP variants (#10918)
* fix(esp32): skip RTC timer wake on user shutdown Do not arm esp_sleep_enable_timer_wakeup when msecToWake is portMAX_DELAY (UI shutdown), matching nRF52 system_off semantics. fix(rak_wismesh_tap_v2): Tag OCV curve and 16MB partition Add OCV_ARRAY matching WisMesh Tag for accurate SOC. Use 16MB flash partition scheme for TAP V2 hardware. Co-authored-by: Cursor <cursoragent@cursor.com> * Trunkt * Add RAK WisMesh Repeater Mini V2 and HP variants Introduce rak_wismesh_repeater_mini (RAK4631) and rak_wismesh_repeater_mini_hp (RAK3401) with low-VDD System OFF. Skip LPCOMP battery wake on user-initiated shutdown to avoid immediate reboot near the LPCOMP threshold; keep LPCOMP for brownout-driven shutdown via variant_enableBatteryLpcompWake. * docs(variants): update RAK BOM numbers for Repeater Mini V2 & HP * chore: run trunk fmt --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
co-authored by
GitHub
Cursor
Ben Meadors
parent
952c825167
commit
834357e94c
@@ -23,6 +23,13 @@
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
|
||||
#ifdef LOW_VDD_SYSTEMOFF_DELAY_MS
|
||||
#include "Arduino.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "power/PowerHAL.h"
|
||||
#include "sleep.h"
|
||||
#endif
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
// P0
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
@@ -40,3 +47,48 @@ void initVariant()
|
||||
pinMode(PIN_3V3_EN, OUTPUT);
|
||||
digitalWrite(PIN_3V3_EN, HIGH);
|
||||
}
|
||||
|
||||
#ifdef LOW_VDD_SYSTEMOFF_DELAY_MS
|
||||
static bool lowVddSystemOff = false; // Set to true when VDD is unsafe for a while (brownout), forcing System OFF.
|
||||
// Strong override; must be noinline (see main-nrf52.cpp weak default).
|
||||
__attribute__((noinline)) bool variant_enableBatteryLpcompWake()
|
||||
{
|
||||
return lowVddSystemOff;
|
||||
}
|
||||
|
||||
// Hook called each nrf52Loop(); e.g. for low-VDD System OFF.
|
||||
void variant_nrf52LoopHook(void)
|
||||
{
|
||||
// If VDD stays unsafe for a while (brownout), force System OFF.
|
||||
// Skip when VBUS present to allow recovery while USB-powered.
|
||||
if (!powerHAL_isVBUSConnected()) {
|
||||
// Rate-limit VDD safety checks: powerHAL_isPowerLevelSafe() calls getVDDVoltage() each time.
|
||||
static constexpr uint32_t POWER_LEVEL_CHECK_INTERVAL_MS = 100;
|
||||
static uint32_t last_vdd_check_ms = 0;
|
||||
static bool last_power_level_safe = true;
|
||||
|
||||
const uint32_t now = millis();
|
||||
if (last_vdd_check_ms == 0 || (uint32_t)(now - last_vdd_check_ms) >= POWER_LEVEL_CHECK_INTERVAL_MS) {
|
||||
last_vdd_check_ms = now;
|
||||
last_power_level_safe = powerHAL_isPowerLevelSafe();
|
||||
}
|
||||
|
||||
// Do not use millis()==0 as a sentinel: at boot, millis() may be 0 while VDD is unsafe.
|
||||
static bool low_vdd_timer_armed = false;
|
||||
static uint32_t low_vdd_since_ms = 0;
|
||||
|
||||
if (!last_power_level_safe) {
|
||||
if (!low_vdd_timer_armed) {
|
||||
low_vdd_since_ms = now;
|
||||
low_vdd_timer_armed = true;
|
||||
}
|
||||
if ((uint32_t)(now - low_vdd_since_ms) >= (uint32_t)LOW_VDD_SYSTEMOFF_DELAY_MS) {
|
||||
lowVddSystemOff = true;
|
||||
cpuDeepSleep(portMAX_DELAY);
|
||||
}
|
||||
} else {
|
||||
low_vdd_timer_armed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user