driver: fix sens_struct.h;
driver: fix timer wakeup dsleep; example: fix EXT1 wakeup dsleep; example: fix touch pad wakeup dsleep;
This commit is contained in:
@@ -588,11 +588,11 @@ esp_err_t touch_pad_proximity_get_meas_cnt(touch_pad_t touch_num, uint32_t *cnt)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (SENS.sar_touch_conf.touch_approach_pad0 == touch_num) {
|
||||
*cnt = SENS.sar_touch_status16.touch_approach_pad0_cnt;
|
||||
*cnt = SENS.sar_touch_appr_status.touch_approach_pad0_cnt;
|
||||
} else if (SENS.sar_touch_conf.touch_approach_pad1 == touch_num) {
|
||||
*cnt = SENS.sar_touch_status16.touch_approach_pad1_cnt;
|
||||
*cnt = SENS.sar_touch_appr_status.touch_approach_pad1_cnt;
|
||||
} else if (SENS.sar_touch_conf.touch_approach_pad2 == touch_num) {
|
||||
*cnt = SENS.sar_touch_status16.touch_approach_pad2_cnt;
|
||||
*cnt = SENS.sar_touch_appr_status.touch_approach_pad2_cnt;
|
||||
} else {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -636,7 +636,7 @@ esp_err_t touch_pad_sleep_channel_config(touch_pad_sleep_channel_t slp_config)
|
||||
esp_err_t touch_pad_sleep_channel_baseline_get(uint32_t *baseline)
|
||||
{
|
||||
if (baseline) {
|
||||
*baseline = REG_GET_FIELD(SENS_SAR_TOUCH_STATUS15_REG, SENS_TOUCH_SLP_BASELINE);
|
||||
*baseline = REG_GET_FIELD(SENS_SAR_TOUCH_SLP_STATUS_REG, SENS_TOUCH_SLP_BASELINE);
|
||||
} else {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -646,7 +646,7 @@ esp_err_t touch_pad_sleep_channel_baseline_get(uint32_t *baseline)
|
||||
esp_err_t touch_pad_sleep_channel_debounce_get(uint32_t *debounce)
|
||||
{
|
||||
if (debounce) {
|
||||
*debounce = REG_GET_FIELD(SENS_SAR_TOUCH_STATUS15_REG, SENS_TOUCH_SLP_DEBOUNCE);
|
||||
*debounce = REG_GET_FIELD(SENS_SAR_TOUCH_SLP_STATUS_REG, SENS_TOUCH_SLP_DEBOUNCE);
|
||||
} else {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -656,7 +656,7 @@ esp_err_t touch_pad_sleep_channel_debounce_get(uint32_t *debounce)
|
||||
esp_err_t touch_pad_sleep_channel_proximity_cnt_get(uint32_t *approach_cnt)
|
||||
{
|
||||
if (approach_cnt) {
|
||||
*approach_cnt = REG_GET_FIELD(SENS_SAR_TOUCH_STATUS16_REG, SENS_TOUCH_SLP_APPROACH_CNT);
|
||||
*approach_cnt = REG_GET_FIELD(SENS_SAR_TOUCH_APPR_STATUS_REG, SENS_TOUCH_SLP_APPROACH_CNT);
|
||||
} else {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "soc/sens_reg.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/rtc_wdt.h"
|
||||
#include "soc/uart_caps.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -136,19 +137,15 @@ void esp_deep_sleep(uint64_t time_in_us)
|
||||
|
||||
static void IRAM_ATTR suspend_uarts(void)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
REG_SET_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XOFF);
|
||||
for (int i = 0; i < SOC_UART_NUM; ++i) {
|
||||
uart_tx_wait_idle(i);
|
||||
/* Note: Set `UART_FORCE_XOFF` can't stop new Tx request. */
|
||||
}
|
||||
}
|
||||
|
||||
static void IRAM_ATTR resume_uarts(void)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
REG_CLR_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XOFF);
|
||||
REG_SET_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XON);
|
||||
REG_CLR_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XON);
|
||||
}
|
||||
/* Note: Set `UART_FORCE_XOFF` can't stop new Tx request. */
|
||||
}
|
||||
|
||||
static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags)
|
||||
@@ -182,7 +179,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags)
|
||||
s_config.sleep_duration > 0) {
|
||||
timer_wakeup_prepare();
|
||||
}
|
||||
uint32_t result = rtc_sleep_start(s_config.wakeup_triggers, 0,0);
|
||||
uint32_t result = rtc_sleep_start(s_config.wakeup_triggers, 0, 0);
|
||||
|
||||
// Restore CPU frequency
|
||||
rtc_clk_cpu_freq_set(cpu_freq);
|
||||
@@ -381,6 +378,8 @@ static void timer_wakeup_prepare(void)
|
||||
int64_t rtc_count_delta = rtc_time_us_to_slowclk(sleep_duration, period);
|
||||
|
||||
rtc_sleep_set_wakeup_time(s_config.rtc_ticks_at_sleep_start + rtc_count_delta);
|
||||
SET_PERI_REG_MASK(RTC_CNTL_INT_CLR_REG, RTC_CNTL_MAIN_TIMER_INT_CLR_M);
|
||||
SET_PERI_REG_MASK(RTC_CNTL_SLP_TIMER1_REG, RTC_CNTL_MAIN_TIMER_ALARM_EN_M);
|
||||
}
|
||||
|
||||
esp_err_t esp_sleep_enable_touchpad_wakeup(void)
|
||||
|
||||
@@ -1143,7 +1143,7 @@ extern "C" {
|
||||
#define SENS_TOUCH_PAD14_BASELINE_V 0x3FFFFF
|
||||
#define SENS_TOUCH_PAD14_BASELINE_S 0
|
||||
|
||||
#define SENS_SAR_TOUCH_STATUS15_REG (DR_REG_SENS_BASE + 0x0114)
|
||||
#define SENS_SAR_TOUCH_SLP_STATUS_REG (DR_REG_SENS_BASE + 0x0114)
|
||||
/* SENS_TOUCH_SLP_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
|
||||
/*description: */
|
||||
#define SENS_TOUCH_SLP_DEBOUNCE 0x00000007
|
||||
@@ -1157,7 +1157,7 @@ extern "C" {
|
||||
#define SENS_TOUCH_SLP_BASELINE_V 0x3FFFFF
|
||||
#define SENS_TOUCH_SLP_BASELINE_S 0
|
||||
|
||||
#define SENS_SAR_TOUCH_STATUS16_REG (DR_REG_SENS_BASE + 0x0118)
|
||||
#define SENS_SAR_TOUCH_APPR_STATUS_REG (DR_REG_SENS_BASE + 0x0118)
|
||||
/* SENS_TOUCH_SLP_APPROACH_CNT : RO ;bitpos:[31:24] ;default: 8'd0 ; */
|
||||
/*description: */
|
||||
#define SENS_TOUCH_SLP_APPROACH_CNT 0x000000FF
|
||||
|
||||
@@ -277,6 +277,14 @@ typedef volatile struct {
|
||||
};
|
||||
uint32_t val;
|
||||
} sar_touch_status[14];
|
||||
union {
|
||||
struct {
|
||||
uint32_t touch_slp_baseline:22;
|
||||
uint32_t reserved22: 7;
|
||||
uint32_t touch_slp_debounce: 3;
|
||||
};
|
||||
uint32_t val;
|
||||
} sar_touch_slp_status;
|
||||
union {
|
||||
struct {
|
||||
uint32_t touch_approach_pad2_cnt: 8;
|
||||
@@ -285,7 +293,7 @@ typedef volatile struct {
|
||||
uint32_t touch_slp_approach_cnt: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} sar_touch_status16;
|
||||
} sar_touch_appr_status;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sw_fstep: 16; /*frequency step for CW generator*/
|
||||
|
||||
Reference in New Issue
Block a user