examples: split source files for one of the ulp examples

This commit is contained in:
Renz Bagaporo 2020-03-03 16:15:29 +08:00
parent d497c4babd
commit 07830df4d3
5 changed files with 19 additions and 14 deletions

View File

@ -2,7 +2,7 @@
This example demonstrates how to program the ULP coprocessor to count pulses on an IO while the main CPUs are either running some other code or are in deep sleep. See the README.md file in the upper level 'examples' directory for more information about examples.
ULP program written in assembly can be found in `ulp/pulse_cnt.S`. The build system assembles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application.
ULP program written in assembly can be found across `ulp/pulse_cnt.S` and `ulp/wake_up.S` (demonstrating multiple ULP source files). The build system assembles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application.
At runtime, the main code running on the ESP32 (found in main.c) loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_load_binary` function. Main code configures the ULP program by setting up values of some variables and then starts it using `ulp_run`. Once the ULP program is started, it runs periodically, with the period set by the main program. The main program enables ULP wakeup source and puts the chip into deep sleep mode.

View File

@ -15,7 +15,7 @@ set(ULP_APP_NAME ulp_${COMPONENT_NAME})
# 2. Specify all assembly source files here.
# 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:

View File

@ -11,7 +11,7 @@ ULP_APP_NAME ?= ulp_$(COMPONENT_NAME)
# Files should be placed into a separate directory (in this case, ulp/),
# which should not be added to COMPONENT_SRCDIRS.
ULP_S_SOURCES = $(addprefix $(COMPONENT_PATH)/ulp/, \
pulse_cnt.S \
pulse_cnt.S wake_up.S\
)
#
# 3. List all the component object files which include automatically

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

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