TTGO T-Beam V10 power (AXP192 PMU) fixes
This commit is contained in:
parent
6dbbf14ef8
commit
3f97a5cad6
@ -371,7 +371,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius,
|
|||||||
uint32_t mem, uint8_t reset1, uint8_t reset2) {
|
uint32_t mem, uint8_t reset1, uint8_t reset2) {
|
||||||
uint16_t temp = celsius * 10;
|
uint16_t temp = celsius * 10;
|
||||||
uint16_t volt = voltage / 10;
|
uint16_t volt = voltage / 10;
|
||||||
#ifdef BAT_MEASURE_ADC
|
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||||
#if (PAYLOAD_ENCODER == 3)
|
#if (PAYLOAD_ENCODER == 3)
|
||||||
buffer[cursor++] = LPP_BATT_CHANNEL;
|
buffer[cursor++] = LPP_BATT_CHANNEL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,33 +28,34 @@ void AXP192_init(void) {
|
|||||||
pmu.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
pmu.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
// I2C access of AXP202X library currently is not mutexable
|
||||||
|
// so we need to disable AXP interrupts
|
||||||
|
|
||||||
|
|
||||||
// I2C access of AXP202X library currently is not mutexable
|
#ifdef PMU_INT
|
||||||
// so we need to disable AXP interrupts
|
pinMode(PMU_INT, INPUT_PULLUP);
|
||||||
|
attachInterrupt(digitalPinToInterrupt(PMU_INT),
|
||||||
#ifdef PMU_INT
|
[] {
|
||||||
pinMode(PMU_INT, INPUT_PULLUP);
|
ESP_LOGI(TAG, "Power source changed");
|
||||||
attachInterrupt(digitalPinToInterrupt(PMU_INT),
|
// put your code here
|
||||||
[] {
|
},
|
||||||
ESP_LOGI(TAG, "Power source changed");
|
FALLING);
|
||||||
// put your code here
|
pmu.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ |
|
||||||
},
|
AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ,
|
||||||
FALLING);
|
1);
|
||||||
pmu.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ |
|
pmu.clearIRQ();
|
||||||
AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ,
|
#endif // PMU_INT
|
||||||
1);
|
*/
|
||||||
pmu.clearIRQ();
|
|
||||||
#endif // PMU_INT
|
|
||||||
*/
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "AXP192 PMU initialized.");
|
ESP_LOGI(TAG, "AXP192 PMU initialized.");
|
||||||
|
|
||||||
if (pmu.isBatteryConnect())
|
if (pmu.isBatteryConnect())
|
||||||
if (pmu.isChargeing())
|
if (pmu.isChargeing())
|
||||||
ESP_LOGI(TAG, "Running on battery, charging.");
|
ESP_LOGI(TAG, "Battery deteced, charging.");
|
||||||
else
|
else
|
||||||
ESP_LOGI(TAG, "Running on battery, not charging.");
|
ESP_LOGI(TAG, "Battery deteced, not charging.");
|
||||||
else if (pmu.isVBUSPlug())
|
else
|
||||||
ESP_LOGI(TAG, "Running on USB power.");
|
ESP_LOGI(TAG, "No Battery deteced.");
|
||||||
}
|
}
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
} else
|
} else
|
||||||
|
@ -263,14 +263,10 @@ void get_config(uint8_t val[]) {
|
|||||||
|
|
||||||
void get_status(uint8_t val[]) {
|
void get_status(uint8_t val[]) {
|
||||||
ESP_LOGI(TAG, "Remote command: get device status");
|
ESP_LOGI(TAG, "Remote command: get device status");
|
||||||
#ifdef BAT_MEASURE_ADC
|
|
||||||
uint16_t voltage = read_voltage();
|
|
||||||
#else
|
|
||||||
uint16_t voltage = 0;
|
|
||||||
#endif
|
|
||||||
payload.reset();
|
payload.reset();
|
||||||
payload.addStatus(voltage, uptime() / 1000, temperatureRead(), getFreeRAM(),
|
payload.addStatus(read_voltage(), uptime() / 1000, temperatureRead(),
|
||||||
rtc_get_reset_reason(0), rtc_get_reset_reason(1));
|
getFreeRAM(), rtc_get_reset_reason(0),
|
||||||
|
rtc_get_reset_reason(1));
|
||||||
SendPayload(STATUSPORT, prio_high);
|
SendPayload(STATUSPORT, prio_high);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -300,7 +296,7 @@ void get_bme(uint8_t val[]) {
|
|||||||
|
|
||||||
void get_batt(uint8_t val[]) {
|
void get_batt(uint8_t val[]) {
|
||||||
ESP_LOGI(TAG, "Remote command: get battery voltage");
|
ESP_LOGI(TAG, "Remote command: get battery voltage");
|
||||||
#ifdef BAT_MEASURE_ADC
|
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||||
payload.reset();
|
payload.reset();
|
||||||
payload.addVoltage(read_voltage());
|
payload.addVoltage(read_voltage());
|
||||||
SendPayload(BATTPORT, prio_normal);
|
SendPayload(BATTPORT, prio_normal);
|
||||||
|
@ -10,7 +10,8 @@ void sendcycle() {
|
|||||||
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
||||||
void SendPayload(uint8_t port, sendprio_t prio) {
|
void SendPayload(uint8_t port, sendprio_t prio) {
|
||||||
|
|
||||||
MessageBuffer_t SendBuffer; // contains MessageSize, MessagePort, MessagePrio, Message[]
|
MessageBuffer_t
|
||||||
|
SendBuffer; // contains MessageSize, MessagePort, MessagePrio, Message[]
|
||||||
|
|
||||||
SendBuffer.MessageSize = payload.getSize();
|
SendBuffer.MessageSize = payload.getSize();
|
||||||
SendBuffer.MessagePrio = prio;
|
SendBuffer.MessagePrio = prio;
|
||||||
@ -117,7 +118,7 @@ void sendData() {
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BAT_MEASURE_ADC
|
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||||
case BATT_DATA:
|
case BATT_DATA:
|
||||||
payload.reset();
|
payload.reset();
|
||||||
payload.addVoltage(read_voltage());
|
payload.addVoltage(read_voltage());
|
||||||
|
Loading…
Reference in New Issue
Block a user