PMU edits
This commit is contained in:
31
Boards.h
31
Boards.h
@@ -256,6 +256,7 @@
|
|||||||
const int pin_led_tx = 4;
|
const int pin_led_tx = 4;
|
||||||
|
|
||||||
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
||||||
|
#define IS_ESP32S3 true
|
||||||
#define HAS_DISPLAY true
|
#define HAS_DISPLAY true
|
||||||
#define HAS_NP true
|
#define HAS_NP true
|
||||||
#define HAS_BLUETOOTH false
|
#define HAS_BLUETOOTH false
|
||||||
@@ -270,8 +271,8 @@
|
|||||||
#define DIO2_AS_RF_SWITCH false
|
#define DIO2_AS_RF_SWITCH false
|
||||||
#define HAS_RF_SWITCH_RX_TX true
|
#define HAS_RF_SWITCH_RX_TX true
|
||||||
#define HAS_LORA_LNA true
|
#define HAS_LORA_LNA true
|
||||||
#define LORA_LNA_GAIN 17
|
#define LORA_LNA_GAIN 30
|
||||||
#define LORA_LNA_GVT 12
|
#define LORA_LNA_GVT 14
|
||||||
|
|
||||||
const int pin_cs = 39;
|
const int pin_cs = 39;
|
||||||
const int pin_sclk = 38;
|
const int pin_sclk = 38;
|
||||||
@@ -285,10 +286,18 @@
|
|||||||
const int pin_tcxo_enable = -1;
|
const int pin_tcxo_enable = -1;
|
||||||
|
|
||||||
const int pin_btn_usr1 = 4;
|
const int pin_btn_usr1 = 4;
|
||||||
const int pin_led_rx = 11;
|
|
||||||
const int pin_led_tx = 12;
|
|
||||||
const int pin_np = 48;
|
const int pin_np = 48;
|
||||||
|
|
||||||
|
#if HAS_NP == false
|
||||||
|
#if defined(EXTERNAL_LEDS)
|
||||||
|
const int pin_led_rx = 48;
|
||||||
|
const int pin_led_tx = 48;
|
||||||
|
#else
|
||||||
|
const int pin_led_rx = 48;
|
||||||
|
const int pin_led_tx = 48;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif BOARD_MODEL == BOARD_MESHADVENTURER
|
#elif BOARD_MODEL == BOARD_MESHADVENTURER
|
||||||
#define HAS_DISPLAY true
|
#define HAS_DISPLAY true
|
||||||
#define HAS_BLUETOOTH true
|
#define HAS_BLUETOOTH true
|
||||||
@@ -302,8 +311,8 @@
|
|||||||
#define DIO2_AS_RF_SWITCH false
|
#define DIO2_AS_RF_SWITCH false
|
||||||
#define HAS_RF_SWITCH_RX_TX true
|
#define HAS_RF_SWITCH_RX_TX true
|
||||||
#define HAS_LORA_LNA true
|
#define HAS_LORA_LNA true
|
||||||
#define LORA_LNA_GAIN 17
|
#define LORA_LNA_GAIN 30
|
||||||
#define LORA_LNA_GVT 12
|
#define LORA_LNA_GVT 14
|
||||||
|
|
||||||
const int pin_cs = 18;
|
const int pin_cs = 18;
|
||||||
const int pin_sclk = 5;
|
const int pin_sclk = 5;
|
||||||
@@ -1051,7 +1060,7 @@
|
|||||||
#define HAS_BLUETOOTH false
|
#define HAS_BLUETOOTH false
|
||||||
#define HAS_BLE true
|
#define HAS_BLE true
|
||||||
#define HAS_CONSOLE false
|
#define HAS_CONSOLE false
|
||||||
#define HAS_PMU false
|
#define HAS_PMU true
|
||||||
#define HAS_NP false
|
#define HAS_NP false
|
||||||
#define HAS_SD false
|
#define HAS_SD false
|
||||||
#define HAS_TCXO true
|
#define HAS_TCXO true
|
||||||
@@ -1078,8 +1087,6 @@
|
|||||||
#define I2C_SDA 8 //P1.04
|
#define I2C_SDA 8 //P1.04
|
||||||
#define I2C_SCL 7 //P0.11
|
#define I2C_SCL 7 //P0.11
|
||||||
|
|
||||||
#define LED_ON LOW
|
|
||||||
#define LED_OFF HIGH
|
|
||||||
#define PIN_LED_RED 22 //P0.15
|
#define PIN_LED_RED 22 //P0.15
|
||||||
const int pin_led_rx = PIN_LED_RED;
|
const int pin_led_rx = PIN_LED_RED;
|
||||||
const int pin_led_tx = PIN_LED_RED;
|
const int pin_led_tx = PIN_LED_RED;
|
||||||
@@ -1094,10 +1101,10 @@
|
|||||||
const int pin_mosi = 14; //P1.15
|
const int pin_mosi = 14; //P1.15
|
||||||
const int pin_miso = 15; //P0.02
|
const int pin_miso = 15; //P0.02
|
||||||
const int pin_busy = 16; //P0.29
|
const int pin_busy = 16; //P0.29
|
||||||
const int pin_dio = 11; //P0.10
|
const int pin_dio = 11; //P0.10
|
||||||
|
const int pin_rxen = 2; //P0.17
|
||||||
|
const int pin_txen = -1;
|
||||||
const int pin_tcxo_enable = -1;
|
const int pin_tcxo_enable = -1;
|
||||||
const int pin_rxen = 2; //P0.17
|
|
||||||
const int pin_txen = -1;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error An unsupported nRF board was selected. Cannot compile RNode firmware.
|
#error An unsupported nRF board was selected. Cannot compile RNode firmware.
|
||||||
|
|||||||
11
Config.h
11
Config.h
@@ -110,7 +110,16 @@
|
|||||||
#define CSMA_CW_PER_BAND_WINDOWS 15
|
#define CSMA_CW_PER_BAND_WINDOWS 15
|
||||||
#define CSMA_BAND_1_MAX_AIRTIME 7
|
#define CSMA_BAND_1_MAX_AIRTIME 7
|
||||||
#define CSMA_BAND_N_MIN_AIRTIME 85
|
#define CSMA_BAND_N_MIN_AIRTIME 85
|
||||||
#define CSMA_INFR_THRESHOLD_DB 11
|
|
||||||
|
// Increase threshold for specific boards
|
||||||
|
#if BOARD_MODEL == BOARD_MESHADVENTURER_S3 || BOARD_MODEL == BOARD_MESHADVENTURER
|
||||||
|
#define CSMA_INFR_THRESHOLD_DB 14
|
||||||
|
#elif BOARD_MODEL == BOARD_PROMICRO
|
||||||
|
#define CSMA_INFR_THRESHOLD_DB 13
|
||||||
|
#else
|
||||||
|
#define CSMA_INFR_THRESHOLD_DB 11
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CSMA_RFENV_RECAL_MS 2500
|
#define CSMA_RFENV_RECAL_MS 2500
|
||||||
#define CSMA_RFENV_RECAL_LIMIT_DB -83
|
#define CSMA_RFENV_RECAL_LIMIT_DB -83
|
||||||
bool interference_detected = false;
|
bool interference_detected = false;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
#elif BOARD_MODEL == BOARD_HELTEC32_V2 || BOARD_MODEL == BOARD_LORA32_V1_0
|
#elif BOARD_MODEL == BOARD_HELTEC32_V2 || BOARD_MODEL == BOARD_LORA32_V1_0
|
||||||
#define DISP_RST 16
|
#define DISP_RST 16
|
||||||
#define DISP_ADDR 0x3C
|
#define DISP_ADDR 0x3C
|
||||||
#define SCL_OLED 15
|
#define OBSCL_OLED 15
|
||||||
#define SDA_OLED 4
|
#define SDA_OLED 4
|
||||||
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
#define DISP_RST 21
|
#define DISP_RST 21
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
||||||
#define DISP_RST -1
|
#define DISP_RST -1
|
||||||
#define DISP_ADDR 0x3C
|
#define DISP_ADDR 0x3C
|
||||||
#define SCL_OLED 0
|
#define SCL_OLED 44
|
||||||
#define SDA_OLED 42
|
#define SDA_OLED 42
|
||||||
#elif BOARD_MODEL == BOARD_MESHADVENTURER
|
#elif BOARD_MODEL == BOARD_MESHADVENTURER
|
||||||
#define DISP_RST -1
|
#define DISP_RST -1
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -142,7 +142,7 @@ firmware-genericesp32: check_bt_buffers
|
|||||||
arduino-cli compile --log --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x35\""
|
arduino-cli compile --log --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x35\""
|
||||||
|
|
||||||
firmware-meshadventurer_s3: check_bt_buffers
|
firmware-meshadventurer_s3: check_bt_buffers
|
||||||
arduino-cli compile --log --fqbn esp32:esp32:esp32s3 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0xF2\""
|
arduino-cli compile --log --fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0xF2\""
|
||||||
|
|
||||||
firmware-meshadventurer: check_bt_buffers
|
firmware-meshadventurer: check_bt_buffers
|
||||||
arduino-cli compile --log --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0xF4\""
|
arduino-cli compile --log --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0xF4\""
|
||||||
@@ -180,8 +180,8 @@ upload-genericesp32:
|
|||||||
|
|
||||||
upload-meshadventurer_s3:
|
upload-meshadventurer_s3:
|
||||||
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
||||||
@sleep 1
|
# @sleep 1
|
||||||
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin)
|
# rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin)
|
||||||
@sleep 3
|
@sleep 3
|
||||||
python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
||||||
|
|
||||||
|
|||||||
23
Power.h
23
Power.h
@@ -164,6 +164,22 @@ float pmu_temperature = PMU_TEMP_MIN-1;
|
|||||||
bool bat_voltage_dropping = false;
|
bool bat_voltage_dropping = false;
|
||||||
float bat_delay_v = 0;
|
float bat_delay_v = 0;
|
||||||
float bat_state_change_v = 0;
|
float bat_state_change_v = 0;
|
||||||
|
#elif BOARD_MODEL == BOARD_PROMICRO
|
||||||
|
#define BAT_V_MIN 3.15
|
||||||
|
#define BAT_V_MAX 4.165
|
||||||
|
#define BAT_V_CHG 4.48
|
||||||
|
#define BAT_V_FLOAT 4.33
|
||||||
|
#define BAT_SAMPLES 7
|
||||||
|
const uint8_t pin_vbat = 17;
|
||||||
|
float bat_p_samples[BAT_SAMPLES];
|
||||||
|
float bat_v_samples[BAT_SAMPLES];
|
||||||
|
uint8_t bat_samples_count = 0;
|
||||||
|
int bat_discharging_samples = 0;
|
||||||
|
int bat_charging_samples = 0;
|
||||||
|
int bat_charged_samples = 0;
|
||||||
|
bool bat_voltage_dropping = false;
|
||||||
|
float bat_delay_v = 0;
|
||||||
|
float bat_state_change_v = 0;
|
||||||
#elif BOARD_MODEL == BOARD_TECHO
|
#elif BOARD_MODEL == BOARD_TECHO
|
||||||
#define BAT_V_MIN 3.15
|
#define BAT_V_MIN 3.15
|
||||||
#define BAT_V_MAX 4.16
|
#define BAT_V_MAX 4.16
|
||||||
@@ -202,7 +218,7 @@ void measure_temperature() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void measure_battery() {
|
void measure_battery() {
|
||||||
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_HELTEC32_V4 || BOARD_MODEL == BOARD_TDECK || BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_HELTEC_T114 || BOARD_MODEL == BOARD_TECHO
|
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_HELTEC32_V4 || BOARD_MODEL == BOARD_TDECK || BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_HELTEC_T114 || BOARD_MODEL == BOARD_PROMICRO || BOARD_MODEL == BOARD_TECHO
|
||||||
battery_installed = true;
|
battery_installed = true;
|
||||||
#if BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_HELTEC32_V4
|
#if BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_HELTEC32_V4
|
||||||
battery_indeterminate = false;
|
battery_indeterminate = false;
|
||||||
@@ -218,6 +234,8 @@ void measure_battery() {
|
|||||||
float battery_measurement = (float)(analogRead(pin_vbat)) / 4095.0*6.7828;
|
float battery_measurement = (float)(analogRead(pin_vbat)) / 4095.0*6.7828;
|
||||||
#elif BOARD_MODEL == BOARD_HELTEC_T114
|
#elif BOARD_MODEL == BOARD_HELTEC_T114
|
||||||
float battery_measurement = (float)(analogRead(pin_vbat)) * 0.017165;
|
float battery_measurement = (float)(analogRead(pin_vbat)) * 0.017165;
|
||||||
|
#elif BOARD_MODEL == BOARD_PROMICRO
|
||||||
|
float battery_measurement = (float)(analogRead(pin_vbat)) * 0.017165;
|
||||||
#elif BOARD_MODEL == BOARD_TECHO
|
#elif BOARD_MODEL == BOARD_TECHO
|
||||||
float battery_measurement = (float)(analogRead(pin_vbat)) * 0.007067;
|
float battery_measurement = (float)(analogRead(pin_vbat)) * 0.007067;
|
||||||
#else
|
#else
|
||||||
@@ -225,6 +243,7 @@ void measure_battery() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bat_v_samples[bat_samples_count%BAT_SAMPLES] = battery_measurement;
|
bat_v_samples[bat_samples_count%BAT_SAMPLES] = battery_measurement;
|
||||||
|
|
||||||
bat_p_samples[bat_samples_count%BAT_SAMPLES] = ((battery_voltage-BAT_V_MIN) / (BAT_V_MAX-BAT_V_MIN))*100.0;
|
bat_p_samples[bat_samples_count%BAT_SAMPLES] = ((battery_voltage-BAT_V_MIN) / (BAT_V_MAX-BAT_V_MIN))*100.0;
|
||||||
|
|
||||||
bat_samples_count++;
|
bat_samples_count++;
|
||||||
@@ -411,7 +430,7 @@ bool init_pmu() {
|
|||||||
pmu_temp_sensor_ready = true;
|
pmu_temp_sensor_ready = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1 || BOARD_MODEL == BOARD_TDECK || BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_TECHO
|
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1 || BOARD_MODEL == BOARD_TDECK || BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_TECHO || BOARD_MODEL == BOARD_PROMICRO
|
||||||
pinMode(pin_vbat, INPUT);
|
pinMode(pin_vbat, INPUT);
|
||||||
return true;
|
return true;
|
||||||
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
|
|||||||
@@ -135,14 +135,14 @@ void setup() {
|
|||||||
boot_seq();
|
boot_seq();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_HELTEC_T114 && BOARD_MODEL != BOARD_PROMICRO && BOARD_MODEL != BOARD_TECHO && BOARD_MODEL != BOARD_T3S3 && BOARD_MODEL != BOARD_TBEAM_S_V1 && BOARD_MODEL != BOARD_HELTEC32_V4
|
#if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_HELTEC_T114 && BOARD_MODEL != BOARD_MESHADVENTURER_S3 && BOARD_MODEL != BOARD_PROMICRO && BOARD_MODEL != BOARD_TECHO && BOARD_MODEL != BOARD_T3S3 && BOARD_MODEL != BOARD_TBEAM_S_V1 && BOARD_MODEL != BOARD_HELTEC32_V4
|
||||||
// Some boards need to wait until the hardware UART is set up before booting
|
// Some boards need to wait until the hardware UART is set up before booting
|
||||||
// the full firmware. In the case of the RAK4631 and Heltec T114, the line below will wait
|
// the full firmware. In the case of the RAK4631 and Heltec T114, the line below will wait
|
||||||
// until a serial connection is actually established with a master. Thus, it
|
// until a serial connection is actually established with a master. Thus, it
|
||||||
// is disabled on this platform.
|
// is disabled on this platform.
|
||||||
while (!Serial);
|
while (!Serial);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serial_interrupt_init();
|
serial_interrupt_init();
|
||||||
|
|
||||||
// Configure input and output pins
|
// Configure input and output pins
|
||||||
|
|||||||
@@ -385,10 +385,10 @@ uint8_t boot_vector = 0x00;
|
|||||||
void led_id_on() { }
|
void led_id_on() { }
|
||||||
void led_id_off() { }
|
void led_id_off() { }
|
||||||
#elif BOARD_MODEL == BOARD_PROMICRO
|
#elif BOARD_MODEL == BOARD_PROMICRO
|
||||||
void led_rx_on() { digitalWrite(pin_led_rx, LED_ON); }
|
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
|
||||||
void led_rx_off() { digitalWrite(pin_led_rx, LED_OFF); }
|
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
|
||||||
void led_tx_on() { digitalWrite(pin_led_tx, LED_ON); }
|
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
|
||||||
void led_tx_off() { digitalWrite(pin_led_tx, LED_OFF); }
|
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
|
||||||
void led_id_on() { }
|
void led_id_on() { }
|
||||||
void led_id_off() { }
|
void led_id_off() { }
|
||||||
#elif BOARD_MODEL == BOARD_HELTEC_T114
|
#elif BOARD_MODEL == BOARD_HELTEC_T114
|
||||||
|
|||||||
Reference in New Issue
Block a user