Browse Source
Use common NRF52 begin() and deduplicate() startup reason init
Use a common begin() method that can be called from derived classes
to contain the shared initialization code.
Signed-off-by: Frieder Schrempf <[email protected] >
pull/1201/head
Frieder Schrempf
6 months ago
No known key found for this signature in database
GPG Key ID: E7DD51F45F833802
41 changed files with
26 additions and
128 deletions
src/helpers/NRF52Board.h
variants/heltec_mesh_solar/MeshSolarBoard.cpp
variants/heltec_mesh_solar/MeshSolarBoard.h
variants/heltec_t114/T114Board.cpp
variants/heltec_t114/T114Board.h
variants/ikoka_handheld_nrf/IkokaNrf52Board.cpp
variants/ikoka_handheld_nrf/IkokaNrf52Board.h
variants/ikoka_nano_nrf/IkokaNanoNRFBoard.cpp
variants/ikoka_nano_nrf/IkokaNanoNRFBoard.h
variants/ikoka_stick_nrf/IkokaStickNRFBoard.cpp
variants/ikoka_stick_nrf/IkokaStickNRFBoard.h
variants/keepteen_lt1/KeepteenLT1Board.cpp
variants/keepteen_lt1/KeepteenLT1Board.h
variants/lilygo_techo/TechoBoard.cpp
variants/lilygo_techo/TechoBoard.h
variants/lilygo_techo_lite/TechoBoard.cpp
variants/lilygo_techo_lite/TechoBoard.h
variants/mesh_pocket/MeshPocket.cpp
variants/mesh_pocket/MeshPocket.h
variants/minewsemi_me25ls01/MinewsemiME25LS01Board.cpp
variants/minewsemi_me25ls01/MinewsemiME25LS01Board.h
variants/nano_g2_ultra/nano-g2.cpp
variants/nano_g2_ultra/nano-g2.h
variants/promicro/PromicroBoard.cpp
variants/promicro/PromicroBoard.h
variants/rak4631/RAK4631Board.cpp
variants/rak4631/RAK4631Board.h
variants/rak_wismesh_tag/RAKWismeshTagBoard.cpp
variants/rak_wismesh_tag/RAKWismeshTagBoard.h
variants/sensecap_solar/SenseCapSolarBoard.cpp
variants/sensecap_solar/SenseCapSolarBoard.h
variants/t1000-e/T1000eBoard.cpp
variants/t1000-e/T1000eBoard.h
variants/thinknode_m1/ThinkNodeM1Board.cpp
variants/thinknode_m1/ThinkNodeM1Board.h
variants/wio-tracker-l1/WioTrackerL1Board.cpp
variants/wio-tracker-l1/WioTrackerL1Board.h
variants/wio_wm1110/WioWM1110Board.cpp
variants/wio_wm1110/WioWM1110Board.h
variants/xiao_nrf52/XiaoNrf52Board.cpp
variants/xiao_nrf52/XiaoNrf52Board.h
@ -6,7 +6,12 @@
# if defined(NRF52_PLATFORM)
class NRF52Board : public mesh : : MainBoard {
protected :
uint8_t startup_reason ;
public :
virtual void begin ( ) { startup_reason = BD_STARTUP_NORMAL ; }
virtual uint8_t getStartupReason ( ) const override { return startup_reason ; }
float getMCUTemperature ( ) override ;
virtual void reboot ( ) override { NVIC_SystemReset ( ) ; }
} ;
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
}
void MeshSolarBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
meshSolarStart ( ) ;
@ -22,12 +22,8 @@
class MeshSolarBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
uint16_t getBattMilliVolts ( ) override {
return meshSolarGetBattVoltage ( ) ;
@ -19,8 +19,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void T114Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
NRF_POWER - > DCDCEN = 1 ;
pinMode ( PIN_VBAT_READ , INPUT ) ;
@ -10,12 +10,8 @@
# define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
class T114Board : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void IkokaNrf52Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
// ensure we have pull ups on the screen i2c, this isn't always available
// in hardware and it should only be 20k ohms. Disable the pullups if we
@ -7,12 +7,8 @@
# ifdef IKOKA_NRF52
class IkokaNrf52Board : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void IkokaNanoNRFBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
pinMode ( PIN_VBAT , INPUT ) ;
pinMode ( VBAT_ENABLE , OUTPUT ) ;
@ -7,12 +7,8 @@
# ifdef XIAO_NRF52
class IkokaNanoNRFBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void IkokaStickNRFBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
pinMode ( PIN_VBAT , INPUT ) ;
pinMode ( VBAT_ENABLE , OUTPUT ) ;
@ -7,12 +7,8 @@
# ifdef XIAO_NRF52
class IkokaStickNRFBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
@ -7,8 +7,7 @@
static BLEDfu bledfu ;
void KeepteenLT1Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
btn_prev_state = HIGH ;
pinMode ( PIN_VBAT_READ , INPUT ) ;
@ -6,14 +6,11 @@
class KeepteenLT1Board : public NRF52Board {
protected :
uint8_t startup_reason ;
uint8_t btn_prev_state ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# define BATTERY_SAMPLES 8
uint16_t getBattMilliVolts ( ) override {
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void TechoBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
Wire . begin ( ) ;
@ -14,19 +14,11 @@
# define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class TechoBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint16_t getBattMilliVolts ( ) override ;
bool startOTAUpdate ( const char * id , char reply [ ] ) override ;
uint8_t getStartupReason ( ) const override {
return startup_reason ;
}
const char * getManufacturerName ( ) const override {
return " LilyGo T-Echo " ;
}
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void TechoBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
Wire . begin ( ) ;
@ -14,19 +14,11 @@
# define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class TechoBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint16_t getBattMilliVolts ( ) override ;
bool startOTAUpdate ( const char * id , char reply [ ] ) override ;
uint8_t getStartupReason ( ) const override {
return startup_reason ;
}
const char * getManufacturerName ( ) const override {
return " LilyGo T-Echo " ;
}
@ -20,8 +20,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
}
void HeltecMeshPocket : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
Serial . begin ( 115200 ) ;
pinMode ( PIN_VBAT_READ , INPUT ) ;
@ -10,14 +10,8 @@
# define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
class HeltecMeshPocket : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
uint16_t getBattMilliVolts ( ) override {
int adcvalue = 0 ;
@ -5,8 +5,7 @@
# include <bluefruit.h>
void MinewsemiME25LS01Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
btn_prev_state = HIGH ;
pinMode ( PIN_VBAT_READ , INPUT ) ;
@ -23,7 +23,6 @@
class MinewsemiME25LS01Board : public NRF52Board {
protected :
uint8_t startup_reason ;
uint8_t btn_prev_state ;
public :
@ -42,8 +41,6 @@ public:
return ( ADC_MULTIPLIER * raw ) ;
}
uint8_t getStartupReason ( ) const override { return startup_reason ; }
const char * getManufacturerName ( ) const override {
return " Minewsemi " ;
}
@ -24,8 +24,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
void NanoG2Ultra : : begin ( )
{
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
// set user button
pinMode ( PIN_BUTTON1 , INPUT ) ;
@ -36,16 +36,11 @@
# define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class NanoG2Ultra : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint16_t getBattMilliVolts ( ) override ;
bool startOTAUpdate ( const char * id , char reply [ ] ) override ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
const char * getManufacturerName ( ) const override { return " Nano G2 Ultra " ; }
void powerOff ( ) override {
@ -7,8 +7,7 @@
static BLEDfu bledfu ;
void PromicroBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
btn_prev_state = HIGH ;
pinMode ( PIN_VBAT_READ , INPUT ) ;
@ -22,15 +22,12 @@
class PromicroBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
uint8_t btn_prev_state ;
float adc_mult = ADC_MULTIPLIER ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# define BATTERY_SAMPLES 8
uint16_t getBattMilliVolts ( ) override {
@ -19,8 +19,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void RAK4631Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
pinMode ( PIN_VBAT_READ , INPUT ) ;
# ifdef PIN_USER_BTN
pinMode ( PIN_USER_BTN , INPUT_PULLUP ) ;
@ -30,12 +30,8 @@
# define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
class RAK4631Board : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# define BATTERY_SAMPLES 8
@ -19,9 +19,8 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void RAKWismeshTagBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
// Enable DC/DC converter for improved power efficiency
uint8_t sd_enabled = 0 ;
sd_softdevice_is_enabled ( & sd_enabled ) ;
@ -9,12 +9,8 @@
# define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
class RAKWismeshTagBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED) && defined(LED_STATE_ON)
void onBeforeTransmit ( ) override {
@ -19,8 +19,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void SenseCapSolarBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
# if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
Wire . setPins ( PIN_WIRE_SDA , PIN_WIRE_SCL ) ;
@ -5,12 +5,8 @@
# include <helpers/NRF52Board.h>
class SenseCapSolarBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
@ -5,8 +5,7 @@
# include <bluefruit.h>
void T1000eBoard : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
btn_prev_state = HIGH ;
// Enable DC/DC converter for improved power efficiency
@ -6,7 +6,6 @@
class T1000eBoard : public NRF52Board {
protected :
uint8_t startup_reason ;
uint8_t btn_prev_state ;
public :
@ -34,8 +33,6 @@ public:
# endif
}
uint8_t getStartupReason ( ) const override { return startup_reason ; }
const char * getManufacturerName ( ) const override {
return " Seeed Tracker T1000-e " ;
}
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void ThinkNodeM1Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
Wire . begin ( ) ;
@ -14,19 +14,12 @@
# define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class ThinkNodeM1Board : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint16_t getBattMilliVolts ( ) override ;
bool startOTAUpdate ( const char * id , char reply [ ] ) override ;
uint8_t getStartupReason ( ) const override {
return startup_reason ;
}
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
digitalWrite ( P_LORA_TX_LED , HIGH ) ; // turn TX LED on
@ -19,8 +19,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void WioTrackerL1Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
btn_prev_state = HIGH ;
// Enable DC/DC converter for improved power efficiency
@ -6,12 +6,10 @@
class WioTrackerL1Board : public NRF52Board {
protected :
uint8_t startup_reason ;
uint8_t btn_prev_state ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {
@ -21,7 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void WioWM1110Board : : begin ( ) {
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
// Enable DC/DC converter for improved power efficiency
uint8_t sd_enabled = 0 ;
@ -12,12 +12,8 @@
# define Serial Serial1
class WioWM1110Board : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(LED_GREEN)
void onBeforeTransmit ( ) override {
@ -21,8 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
}
void XiaoNrf52Board : : begin ( ) {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL ;
NRF52Board : : begin ( ) ;
// Enable DC/DC converter for improved power efficiency
uint8_t sd_enabled = 0 ;
@ -7,12 +7,8 @@
# ifdef XIAO_NRF52
class XiaoNrf52Board : public NRF52Board {
protected :
uint8_t startup_reason ;
public :
void begin ( ) ;
uint8_t getStartupReason ( ) const override { return startup_reason ; }
# if defined(P_LORA_TX_LED)
void onBeforeTransmit ( ) override {