mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-04 01:05:44 +00:00
5188221584 changed LED_RED/GREEN to
LED_WHITE/BLUE, but didn't convert all uses of LED_GREEN.
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
#include <Arduino.h>
|
|
#include <Wire.h>
|
|
|
|
#include "SenseCapSolarBoard.h"
|
|
|
|
#ifdef NRF52_POWER_MANAGEMENT
|
|
const PowerMgtConfig power_config = {
|
|
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
|
|
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
|
|
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
|
|
};
|
|
|
|
void SenseCapSolarBoard::initiateShutdown(uint8_t reason) {
|
|
bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
|
|
reason == SHUTDOWN_REASON_BOOT_PROTECT);
|
|
|
|
pinMode(VBAT_ENABLE, OUTPUT);
|
|
digitalWrite(VBAT_ENABLE, enable_lpcomp ? LOW : HIGH);
|
|
|
|
if (enable_lpcomp) {
|
|
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
|
|
}
|
|
|
|
enterSystemOff(reason);
|
|
}
|
|
#endif // NRF52_POWER_MANAGEMENT
|
|
|
|
void SenseCapSolarBoard::begin() {
|
|
NRF52BoardDCDC::begin();
|
|
|
|
pinMode(BATTERY_PIN, INPUT);
|
|
pinMode(VBAT_ENABLE, OUTPUT);
|
|
digitalWrite(VBAT_ENABLE, LOW);
|
|
analogReadResolution(12);
|
|
analogReference(AR_INTERNAL_3_0);
|
|
delay(50);
|
|
|
|
#ifdef PIN_USER_BTN
|
|
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
|
#elif defined(PIN_BUTTON1)
|
|
pinMode(PIN_BUTTON1, INPUT_PULLUP);
|
|
#endif
|
|
|
|
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
|
|
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
|
|
#endif
|
|
|
|
Wire.begin();
|
|
|
|
#ifdef LED_WHITE
|
|
pinMode(LED_WHITE, OUTPUT);
|
|
digitalWrite(LED_WHITE, HIGH);
|
|
#endif
|
|
#ifdef LED_BLUE
|
|
pinMode(LED_BLUE, OUTPUT);
|
|
digitalWrite(LED_BLUE, LOW);
|
|
#endif
|
|
|
|
#ifdef P_LORA_TX_LED
|
|
pinMode(P_LORA_TX_LED, OUTPUT);
|
|
digitalWrite(P_LORA_TX_LED, LOW);
|
|
#endif
|
|
|
|
#ifdef NRF52_POWER_MANAGEMENT
|
|
checkBootVoltage(&power_config);
|
|
#endif
|
|
|
|
delay(10); // give sx1262 some time to power up
|
|
}
|