Update ESP-IDF examples

This commit is contained in:
valeros
2020-09-01 21:48:00 +03:00
parent ff997d3677
commit 1ceb7b9d92
73 changed files with 1492 additions and 846 deletions
-1
View File
@@ -11,4 +11,3 @@
platform = espressif32
framework = espidf
board = esp32dev
build_flags = -DCONFIG_WIFI_SSID=\"ESP_AP\" -DCONFIG_WIFI_PASSWORD=\"MYPASS\"
@@ -6,3 +6,4 @@ CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
CONFIG_BOOTLOADER_LOG_LEVEL=2
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
CONFIG_LOG_DEFAULT_LEVEL=2
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
+5 -7
View File
@@ -1,8 +1,6 @@
idf_component_register(SRCS "ulp_example_main.c")
# idf_component_register(SRCS "ulp_example_main.c"
# INCLUDE_DIRS ""
# REQUIRES soc nvs_flash ulp)
idf_component_register(SRCS "ulp_example_main.c"
INCLUDE_DIRS ""
REQUIRES soc nvs_flash ulp)
#
# ULP support additions to component CMakeLists.txt.
#
@@ -12,7 +10,7 @@ set(ulp_app_name ulp_main)
# 2. Specify all assembly source files.
# Files should be placed into a separate directory (in this case, ulp/),
# which should not be added to COMPONENT_SRCS.
set(ulp_s_sources "../ulp/pulse_cnt.S")
set(ulp_s_sources "../ulp/pulse_cnt.S" "../ulp/wake_up.S")
#
# 3. List all the component source files which include automatically
# generated ULP export file, ${ulp_app_name}.h:
@@ -20,4 +18,4 @@ set(ulp_exp_dep_srcs "ulp_example_main.c")
#
# 4. Call function to build ULP binary and embed in project using the argument
# values above.
ulp_embed_binary(${ulp_app_name} ${ulp_s_sources} ${ulp_exp_dep_srcs})
ulp_embed_binary(${ulp_app_name} "${ulp_s_sources}" "${ulp_exp_dep_srcs}")
@@ -22,10 +22,10 @@
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end");
static void init_ulp_program();
static void update_pulse_count();
static void init_ulp_program(void);
static void update_pulse_count(void);
void app_main()
void app_main(void)
{
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
if (cause != ESP_SLEEP_WAKEUP_ULP) {
@@ -41,7 +41,7 @@ void app_main()
esp_deep_sleep_start();
}
static void init_ulp_program()
static void init_ulp_program(void)
{
esp_err_t err = ulp_load_binary(0, ulp_main_bin_start,
(ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
@@ -49,7 +49,8 @@ static void init_ulp_program()
/* GPIO used for pulse counting. */
gpio_num_t gpio_num = GPIO_NUM_0;
assert(rtc_gpio_desc[gpio_num].reg && "GPIO used for pulse counting must be an RTC IO");
int rtcio_num = rtc_io_number_get(gpio_num);
assert(rtc_gpio_is_valid_gpio(gpio_num) && "GPIO used for pulse counting must be an RTC IO");
/* Initialize some variables used by ULP program.
* Each 'ulp_xyz' variable corresponds to 'xyz' variable in the ULP program.
@@ -63,7 +64,7 @@ static void init_ulp_program()
ulp_debounce_counter = 3;
ulp_debounce_max_count = 3;
ulp_next_edge = 0;
ulp_io_number = rtc_gpio_desc[gpio_num].rtc_num; /* map from GPIO# to RTC_IO# */
ulp_io_number = rtcio_num; /* map from GPIO# to RTC_IO# */
ulp_edge_count_to_wake_up = 10;
/* Initialize selected GPIO as RTC IO, enable input, disable pullup and pulldown */
@@ -91,7 +92,7 @@ static void init_ulp_program()
ESP_ERROR_CHECK(err);
}
static void update_pulse_count()
static void update_pulse_count(void)
{
const char* namespace = "plusecnt";
const char* count_key = "count";
-11
View File
@@ -144,14 +144,3 @@ edge_detected:
jump wake_up, eq
/* Not yet. End program */
halt
.global wake_up
wake_up:
/* Check if the system can be woken up */
READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
and r0, r0, 1
jump wake_up, eq
/* Wake up the SoC, end program */
wake
halt
+16
View File
@@ -0,0 +1,16 @@
/* ULP assembly files are passed through C preprocessor first, so include directives
and C macros may be used in these files
*/
#include "soc/rtc_cntl_reg.h"
#include "soc/soc_ulp.h"
.global wake_up
wake_up:
/* Check if the system can be woken up */
READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
and r0, r0, 1
jump wake_up, eq
/* Wake up the SoC, end program */
wake
halt