Sprzet: ESP32-S2-MINI, CC1101 SMA, LM317T i zasilanie z zapalniczki
check / check-without-hardware (push) Canceled after 0s
check / check-without-hardware (push) Canceled after 0s
This commit is contained in:
1 parent
40c152afca
commit
d53299ba11
14 files changed
+218
-147
No files matched your search
+9
-6
@@ -4,7 +4,9 @@
|
||||
|
||||
#define FW_VERSION "2.0.0-rc.1"
|
||||
|
||||
/* ESP32-C3 SuperMini + CC1101 433 MHz (3,3 V). */
|
||||
/* ESP32-S2-MINI (ESP32-S2FN4R2) + CC1101 433 MHz (3,3 V).
|
||||
* GPIO19/20 to natywne USB, GPIO26-32 obsluguja flash/PSRAM w obudowie,
|
||||
* GPIO0/45/46 to piny strapping - nie uzywac ich do CC1101 ani przycisku. */
|
||||
#define PIN_CC1101_SCK 4
|
||||
#define PIN_CC1101_MISO 5
|
||||
#define PIN_CC1101_MOSI 6
|
||||
@@ -13,21 +15,22 @@
|
||||
|
||||
#define PIN_BUTTON 3
|
||||
#define BTN_ACTIVE_LEVEL 0
|
||||
/* Wbudowana niebieska LED na GPIO8 jest aktywna stanem niskim. */
|
||||
#define PIN_LED 8
|
||||
#define LED_ACTIVE_LEVEL 0
|
||||
/* Wbudowana niebieska LED S2 Mini na GPIO15 jest aktywna stanem wysokim. */
|
||||
#define PIN_LED 15
|
||||
#define LED_ACTIVE_LEVEL 1
|
||||
|
||||
/* Opcje wylaczone do czasu zmontowania i przetestowania sprzetu. */
|
||||
#ifndef PIN_LF_TRIGGER
|
||||
#define PIN_LF_TRIGGER -1
|
||||
#endif
|
||||
/* LF dzieli z przyciskiem GPIO wakeup LOW na ESP32-C3. */
|
||||
/* LF dzieli z przyciskiem GPIO wakeup LOW; na ESP32-S2 wakeup wymaga pinu
|
||||
* RTC (GPIO0-21). Proponowane GPIO14, bo GPIO1 zajmuje ADC zasilania. */
|
||||
#define LF_ACTIVE_LEVEL 0
|
||||
#ifndef PIN_ACC
|
||||
#define PIN_ACC -1
|
||||
#endif
|
||||
#ifndef PIN_VBAT_ADC
|
||||
#define PIN_VBAT_ADC 0
|
||||
#define PIN_VBAT_ADC 1
|
||||
#endif
|
||||
#define VBAT_DIVIDER_R1 1000000.0f
|
||||
#define VBAT_DIVIDER_R2 270000.0f
|
||||
|
||||
+17
-3
@@ -1,6 +1,7 @@
|
||||
/* Symulator diagnostyczny TPMS. Sztuczne cisnienie moze ukryc usterke opony. */
|
||||
#include <Arduino.h>
|
||||
#include <esp_sleep.h>
|
||||
#include <soc/soc_caps.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "config.h"
|
||||
@@ -208,11 +209,24 @@ void setup(void)
|
||||
}
|
||||
|
||||
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
|
||||
bool transmit = cause != ESP_SLEEP_WAKEUP_GPIO;
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
/* Chipy z GPIO wakeup w deep sleep (np. ESP32-C3). */
|
||||
bool pin_wake = cause == ESP_SLEEP_WAKEUP_GPIO;
|
||||
#else
|
||||
/* ESP32-S2: budzenie z pinow RTC zglasza EXT1. */
|
||||
bool pin_wake = cause == ESP_SLEEP_WAKEUP_EXT1;
|
||||
#endif
|
||||
bool transmit = !pin_wake;
|
||||
g_app->begin(millis(), transmit);
|
||||
#if PIN_LF_TRIGGER >= 0
|
||||
uint64_t wake_mask = cause == ESP_SLEEP_WAKEUP_GPIO
|
||||
? esp_sleep_get_gpio_wakeup_status() : 0;
|
||||
uint64_t wake_mask = 0;
|
||||
if (pin_wake) {
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
wake_mask = esp_sleep_get_gpio_wakeup_status();
|
||||
#else
|
||||
wake_mask = esp_sleep_get_ext1_wakeup_status();
|
||||
#endif
|
||||
}
|
||||
if ((wake_mask & (1ULL << PIN_LF_TRIGGER)) != 0) {
|
||||
g_app->send_current();
|
||||
}
|
||||
|
||||
+13
-2
@@ -2,7 +2,10 @@
|
||||
#include <Arduino.h>
|
||||
#include <esp_sleep.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <soc/soc_caps.h>
|
||||
#if SOC_BT_SUPPORTED
|
||||
#include <esp32-hal-bt.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "power.h"
|
||||
@@ -14,7 +17,10 @@ void power_init(void)
|
||||
gpio_hold_dis((gpio_num_t)PIN_CC1101_CS);
|
||||
gpio_hold_dis((gpio_num_t)PIN_CC1101_SCK);
|
||||
gpio_hold_dis((gpio_num_t)PIN_CC1101_MOSI);
|
||||
#if SOC_BT_SUPPORTED
|
||||
/* ESP32-S2 nie ma radia Bluetooth; btStop istnieje tylko na chipach z BT. */
|
||||
btStop();
|
||||
#endif
|
||||
#if PIN_VBAT_ADC >= 0
|
||||
analogSetPinAttenuation(PIN_VBAT_ADC, ADC_11db);
|
||||
#endif
|
||||
@@ -58,8 +64,9 @@ void power_deep_sleep(uint32_t seconds)
|
||||
esp_sleep_enable_timer_wakeup((uint64_t)seconds * 1000000ULL);
|
||||
|
||||
#if PIN_BUTTON >= 0 || PIN_LF_TRIGGER >= 0
|
||||
/* ESP32-C3 uzywa GPIO wakeup zamiast EXT0/EXT1. Oba wejscia sa
|
||||
* aktywne nisko, wiec moga wspoldzielic jeden tryb GPIO_LOW. */
|
||||
/* Budzenie z pinow RTC (na ESP32-S2: GPIO0-21). Oba wejscia sa aktywne
|
||||
* nisko, wiec moga wspoldzielic jeden tryb. ESP32-S2 nie obsluguje
|
||||
* GPIO wakeup w deep sleep - uzywa EXT1 ANY_LOW. */
|
||||
uint64_t wake_mask = 0;
|
||||
#if PIN_BUTTON >= 0
|
||||
wake_mask |= 1ULL << PIN_BUTTON;
|
||||
@@ -67,7 +74,11 @@ void power_deep_sleep(uint32_t seconds)
|
||||
#if PIN_LF_TRIGGER >= 0
|
||||
wake_mask |= 1ULL << PIN_LF_TRIGGER;
|
||||
#endif
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
esp_deep_sleep_enable_gpio_wakeup(wake_mask, ESP_GPIO_WAKEUP_GPIO_LOW);
|
||||
#else
|
||||
esp_sleep_enable_ext1_wakeup(wake_mask, ESP_EXT1_WAKEUP_ANY_LOW);
|
||||
#endif
|
||||
#endif
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
Reference in new issue
Block a user