added new reset logic; deep sleep fixes

This commit is contained in:
Verkehrsrot committed 2019-10-20 20:05:13 +02:00
1 parent f3b3838e09
commit bc034b1a67
15 files changed
+256 -186

No files matched your search

+5 -2
View File
@@ -51,10 +51,12 @@
enum sendprio_t { prio_low, prio_normal, prio_high };
enum timesource_t { _gps, _rtc, _lora, _unsynced };
enum runmode_t {
RUNMODE_POWERCYCLE = 0,
RUNMODE_NORMAL,
RUNMODE_UPDATE,
RUNMODE_WAKEUP
RUNMODE_WAKEUP,
RUNMODE_UPDATE
};
// Struct holding devices's runtime configuration
@@ -125,6 +127,7 @@ extern TaskHandle_t irqHandlerTask, ClockTask;
extern TimerHandle_t WifiChanTimer;
extern Timezone myTZ;
extern time_t userUTCTime;
extern RTC_DATA_ATTR runmode_t RTC_runmode;
// application includes
#include "led.h"
+9 -7
View File
@@ -22,7 +22,9 @@
#endif
extern TaskHandle_t lmicTask, lorasendTask;
extern RTC_DATA_ATTR int RTCseqnoUp, RTCseqnoDn;
extern RTC_NOINIT_ATTR u4_t RTCnetid, RTCdevaddr;
extern RTC_NOINIT_ATTR u1_t RTCnwkKey[16], RTCartKey[16];
extern RTC_NOINIT_ATTR int RTCseqnoUp, RTCseqnoDn;
// table of LORAWAN MAC commands
typedef struct {
@@ -31,7 +33,7 @@ typedef struct {
const uint8_t params;
} mac_t;
esp_err_t lora_stack_init(bool joined = false);
esp_err_t lora_stack_init(bool do_join);
void lora_setupForNetwork(bool preJoin);
void lmictask(void *pvParameters);
void gen_lora_deveui(uint8_t *pdeveui);
@@ -44,10 +46,10 @@ void showLoraKeys(void);
void lora_send(void *pvParameters);
void lora_enqueuedata(MessageBuffer_t *message);
void lora_queuereset(void);
static void IRAM_ATTR myEventCallback(void *pUserData, ev_t ev);
static void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
size_t nMsg);
static void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess);
static void IRAM_ATTR myEventCallback(void *pUserData, ev_t ev);
static void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port,
const uint8_t *pMsg, size_t nMsg);
static void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess);
void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[],
const uint8_t tablesize);
uint8_t getBattLevel(void);
@@ -57,7 +59,7 @@ const char *getCrName(rps_t rps);
#if (TIME_SYNC_LORAWAN)
static void user_request_network_time_callback(void *pVoidUserUTCTime,
int flagSuccess);
int flagSuccess);
#endif
#endif
+1 -2
View File
@@ -7,7 +7,7 @@
#include <esp_coexist.h> // needed for showing coex sw version
#include "globals.h"
#include "power.h"
#include "reset.h"
#include "i2c.h"
#include "blescan.h"
#include "wifiscan.h"
@@ -16,7 +16,6 @@
#include "beacon_array.h"
#include "ota.h"
#include "irqhandler.h"
#include "led.h"
#include "spislave.h"
#if (HAS_LORA)
+4 -4
View File
@@ -3,15 +3,12 @@
#include <Arduino.h>
#include <driver/adc.h>
#include <driver/rtc_io.h>
#include <esp_adc_cal.h>
#include "i2c.h"
#define DEFAULT_VREF 1100 // tbd: use adc2_vref_to_gpio() for better estimate
#define NO_OF_SAMPLES 64 // we do some multisampling to get better values
extern RTC_DATA_ATTR runmode_t RTC_runmode;
uint16_t read_voltage(void);
void calibrate_voltage(void);
bool batt_sufficient(void);
@@ -19,13 +16,16 @@ void enter_deepsleep(const int wakeup_sec, const gpio_num_t wakeup_gpio);
int64_t exit_deepsleep(void);
#ifdef HAS_PMU
#include <axp20x.h>
enum pmu_power_t { pmu_power_on, pmu_power_off, pmu_power_sleep };
void AXP192_powerevent_IRQ(void);
void AXP192_power(bool on);
void AXP192_power(pmu_power_t powerlevel);
void AXP192_init(void);
void AXP192_showstatus(void);
uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len);
uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len);
#endif // HAS_PMU
#endif
+1 -1
View File
@@ -24,6 +24,6 @@ typedef struct {
} cmd_t;
void rcommand(const uint8_t cmd[], const uint8_t cmdlength);
void do_reset();
void do_reset(bool warmstart);
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef _RESET_H
#define _RESET_H
#include <driver/rtc_io.h>
#include <rom/rtc.h>
#include "i2c.h"
void do_reset(bool warmstart);
void do_after_reset(int reason);
void enter_deepsleep(const int wakeup_sec, const gpio_num_t wakeup_gpio);
int64_t exit_deepsleep(void);
#endif // _RESET_H