Disable RS485 driver and systick before deep sleep

- The RS485 driver consumes about 150 mW if enabled
- The systick somehow can wake up the CPU from stop mode
This commit is contained in:
Thomas Kolb 2021-06-12 02:00:54 +02:00
parent 189ea810d9
commit 5ceb014d1b

View file

@ -15,6 +15,7 @@
#include "measurement.h" #include "measurement.h"
#include "deepsleep.h" #include "deepsleep.h"
#include "pinout.h"
#include "config.h" #include "config.h"
volatile int wait_frame = 1; volatile int wait_frame = 1;
@ -223,8 +224,13 @@ int main(void)
} else { } else {
// charge control already idle // charge control already idle
if((timebase_ms - charge_control_idle_since) > DEEPSLEEP_DELAY) { if((timebase_ms - charge_control_idle_since) > DEEPSLEEP_DELAY) {
rs485_enqueue("PWR:DEEPSLEEP:ENTRY\n"); systick_counter_disable();
// force the RS485 driver into receive mode. The RS485
// driver alone consumes 150 mW if enabled.
gpio_clear(RS485_PORT, RS485_DE_PIN);
deepsleep(DEEPSLEEP_DURATION); deepsleep(DEEPSLEEP_DURATION);
gpio_set(RS485_PORT, RS485_DE_PIN);
systick_counter_enable();
rs485_enqueue("PWR:DEEPSLEEP:EXIT\n"); rs485_enqueue("PWR:DEEPSLEEP:EXIT\n");
charge_control_was_idle = false; charge_control_was_idle = false;
} }