mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
pulse_counter_ulp: Fix whitespace
This commit is contained in:
parent
bc8dd18bf5
commit
ad3b75601e
2 changed files with 118 additions and 118 deletions
|
@ -13,7 +13,7 @@ set(ulp_app_name ulp_main)
|
||||||
## 2. Specify all assembly source files.
|
## 2. Specify all assembly source files.
|
||||||
## Files should be placed into a separate directory (in this case, ulp/),
|
## Files should be placed into a separate directory (in this case, ulp/),
|
||||||
## which should not be added to COMPONENT_SRCS.
|
## which should not be added to COMPONENT_SRCS.
|
||||||
##TODO
|
##TODO
|
||||||
set(ulp_s_sources "../ulp/pulse_cnt.S" "../ulp/wake_up.S")
|
set(ulp_s_sources "../ulp/pulse_cnt.S" "../ulp/wake_up.S")
|
||||||
##
|
##
|
||||||
## 3. List all the component source files which include automatically
|
## 3. List all the component source files which include automatically
|
||||||
|
|
|
@ -31,161 +31,161 @@
|
||||||
#include "soc/soc_ulp.h"
|
#include "soc/soc_ulp.h"
|
||||||
#include "soc/sens_reg.h"
|
#include "soc/sens_reg.h"
|
||||||
|
|
||||||
/* Define variables, which go into .bss section (zero-initialized data) */
|
/* Define variables, which go into .bss section (zero-initialized data) */
|
||||||
.bss
|
.bss
|
||||||
/* Next input signal edge expected: 0 (negative) or 1 (positive) */
|
/* Next input signal edge expected: 0 (negative) or 1 (positive) */
|
||||||
.global next_edge
|
.global next_edge
|
||||||
next_edge:
|
next_edge:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Counter started when signal value changes.
|
/* Counter started when signal value changes.
|
||||||
Edge is "debounced" when the counter reaches zero. */
|
Edge is "debounced" when the counter reaches zero. */
|
||||||
.global debounce_counter
|
.global debounce_counter
|
||||||
debounce_counter:
|
debounce_counter:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Value to which debounce_counter gets reset.
|
/* Value to which debounce_counter gets reset.
|
||||||
Set by the main program. */
|
Set by the main program. */
|
||||||
.global debounce_max_count
|
.global debounce_max_count
|
||||||
debounce_max_count:
|
debounce_max_count:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Number of rising signal edges acquired since last read */
|
/* Number of rising signal edges acquired since last read */
|
||||||
.global rising_edge_count
|
.global rising_edge_count
|
||||||
rising_edge_count:
|
rising_edge_count:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Number of falling signal edges acquired since last read */
|
/* Number of falling signal edges acquired since last read */
|
||||||
.global falling_edge_count
|
.global falling_edge_count
|
||||||
falling_edge_count:
|
falling_edge_count:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Number of times program run since last read */
|
/* Number of times program run since last read */
|
||||||
.global run_count
|
.global run_count
|
||||||
run_count:
|
run_count:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Total number of signal edges acquired */
|
/* Total number of signal edges acquired */
|
||||||
.global edge_count_total
|
.global edge_count_total
|
||||||
edge_count_total:
|
edge_count_total:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* RTC IO number used to sample the input signal.
|
/* RTC IO number used to sample the input signal.
|
||||||
Set by main program. */
|
Set by main program. */
|
||||||
.global io_number
|
.global io_number
|
||||||
io_number:
|
io_number:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Estimate of how long each execution of the ULP program takes. Managed
|
/* Estimate of how long each execution of the ULP program takes. Managed
|
||||||
* entirely by main program, it is only defined here to survive deep sleep */
|
* entirely by main program, it is only defined here to survive deep sleep */
|
||||||
.global mean_exec_time
|
.global mean_exec_time
|
||||||
mean_exec_time:
|
mean_exec_time:
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
/* Code goes into .text section */
|
/* Code goes into .text section */
|
||||||
.text
|
.text
|
||||||
.global entry
|
.global entry
|
||||||
entry:
|
entry:
|
||||||
/* Increment run_count */
|
/* Increment run_count */
|
||||||
move r3, run_count
|
move r3, run_count
|
||||||
ld r2, r3, 0
|
ld r2, r3, 0
|
||||||
add r2, r2, 1
|
add r2, r2, 1
|
||||||
st r2, r3, 0
|
st r2, r3, 0
|
||||||
|
|
||||||
/* Load io_number */
|
/* Load io_number */
|
||||||
move r3, io_number
|
move r3, io_number
|
||||||
ld r3, r3, 0
|
ld r3, r3, 0
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2
|
#if CONFIG_IDF_TARGET_ESP32S2
|
||||||
/* ESP32S2 powers down RTC periph when entering deep sleep and thus by association SENS_SAR_IO_MUX_CONF_REG */
|
/* ESP32S2 powers down RTC periph when entering deep sleep and thus by association SENS_SAR_IO_MUX_CONF_REG */
|
||||||
WRITE_RTC_FIELD(SENS_SAR_IO_MUX_CONF_REG, SENS_IOMUX_CLK_GATE_EN, 1)
|
WRITE_RTC_FIELD(SENS_SAR_IO_MUX_CONF_REG, SENS_IOMUX_CLK_GATE_EN, 1)
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
/* ESP32S3 powers down RTC periph when entering deep sleep and thus by association SENS_SAR_PERI_CLK_GATE_CONF_REG */
|
/* ESP32S3 powers down RTC periph when entering deep sleep and thus by association SENS_SAR_PERI_CLK_GATE_CONF_REG */
|
||||||
WRITE_RTC_FIELD(SENS_SAR_PERI_CLK_GATE_CONF_REG, SENS_IOMUX_CLK_EN, 1);
|
WRITE_RTC_FIELD(SENS_SAR_PERI_CLK_GATE_CONF_REG, SENS_IOMUX_CLK_EN, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Lower 16 IOs and higher need to be handled separately,
|
/* Lower 16 IOs and higher need to be handled separately,
|
||||||
* because r0-r3 registers are 16 bit wide.
|
* because r0-r3 registers are 16 bit wide.
|
||||||
* Check which IO this is.
|
* Check which IO this is.
|
||||||
*/
|
*/
|
||||||
move r0, r3
|
move r0, r3
|
||||||
jumpr read_io_high, 16, ge
|
jumpr read_io_high, 16, ge
|
||||||
|
|
||||||
/* Read the value of lower 16 RTC IOs into R0 */
|
/* Read the value of lower 16 RTC IOs into R0 */
|
||||||
READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S, 16)
|
READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S, 16)
|
||||||
rsh r0, r0, r3
|
rsh r0, r0, r3
|
||||||
jump read_done
|
jump read_done
|
||||||
|
|
||||||
/* Read the value of RTC IOs 16-17, into R0 */
|
/* Read the value of RTC IOs 16-17, into R0 */
|
||||||
read_io_high:
|
read_io_high:
|
||||||
READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S + 16, 2)
|
READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S + 16, 2)
|
||||||
sub r3, r3, 16
|
sub r3, r3, 16
|
||||||
rsh r0, r0, r3
|
rsh r0, r0, r3
|
||||||
|
|
||||||
read_done:
|
read_done:
|
||||||
and r0, r0, 1
|
and r0, r0, 1
|
||||||
/* State of input changed? */
|
/* State of input changed? */
|
||||||
move r3, next_edge
|
move r3, next_edge
|
||||||
ld r3, r3, 0
|
ld r3, r3, 0
|
||||||
add r3, r0, r3
|
add r3, r0, r3
|
||||||
and r3, r3, 1
|
and r3, r3, 1
|
||||||
jump changed, eq
|
jump changed, eq
|
||||||
/* Not changed */
|
/* Not changed */
|
||||||
/* Reset debounce_counter to debounce_max_count */
|
/* Reset debounce_counter to debounce_max_count */
|
||||||
move r3, debounce_max_count
|
move r3, debounce_max_count
|
||||||
move r2, debounce_counter
|
move r2, debounce_counter
|
||||||
ld r3, r3, 0
|
ld r3, r3, 0
|
||||||
st r3, r2, 0
|
st r3, r2, 0
|
||||||
/* End program */
|
/* End program */
|
||||||
halt
|
halt
|
||||||
|
|
||||||
.global changed
|
.global changed
|
||||||
changed:
|
changed:
|
||||||
/* Input state changed */
|
/* Input state changed */
|
||||||
/* Has debounce_counter reached zero? */
|
/* Has debounce_counter reached zero? */
|
||||||
move r3, debounce_counter
|
move r3, debounce_counter
|
||||||
ld r2, r3, 0
|
ld r2, r3, 0
|
||||||
add r2, r2, 0 /* dummy ADD to use "jump if ALU result is zero" */
|
add r2, r2, 0 /* dummy ADD to use "jump if ALU result is zero" */
|
||||||
jump edge_detected, eq
|
jump edge_detected, eq
|
||||||
/* Not yet. Decrement debounce_counter */
|
/* Not yet. Decrement debounce_counter */
|
||||||
sub r2, r2, 1
|
sub r2, r2, 1
|
||||||
st r2, r3, 0
|
st r2, r3, 0
|
||||||
/* End program */
|
/* End program */
|
||||||
halt
|
halt
|
||||||
|
|
||||||
.global edge_detected
|
.global edge_detected
|
||||||
edge_detected:
|
edge_detected:
|
||||||
/* Reset debounce_counter to debounce_max_count */
|
/* Reset debounce_counter to debounce_max_count */
|
||||||
move r3, debounce_max_count
|
move r3, debounce_max_count
|
||||||
move r2, debounce_counter
|
move r2, debounce_counter
|
||||||
ld r3, r3, 0
|
ld r3, r3, 0
|
||||||
st r3, r2, 0
|
st r3, r2, 0
|
||||||
/* Flip next_edge */
|
/* Flip next_edge */
|
||||||
move r3, next_edge
|
move r3, next_edge
|
||||||
ld r2, r3, 0
|
ld r2, r3, 0
|
||||||
add r2, r2, 1
|
add r2, r2, 1
|
||||||
and r2, r2, 1
|
and r2, r2, 1
|
||||||
st r2, r3, 0
|
st r2, r3, 0
|
||||||
/* Jump to increment of current edge counter */
|
/* Jump to increment of current edge counter */
|
||||||
add r2, r2, 0 /* dummy ADD to use "jump if ALU result is zero" */
|
add r2, r2, 0 /* dummy ADD to use "jump if ALU result is zero" */
|
||||||
jump rising, eq
|
jump rising, eq
|
||||||
|
|
||||||
.global falling
|
.global falling
|
||||||
falling:
|
falling:
|
||||||
/* Increment falling_edge_count */
|
/* Increment falling_edge_count */
|
||||||
move r3, falling_edge_count
|
move r3, falling_edge_count
|
||||||
ld r2, r3, 0
|
ld r2, r3, 0
|
||||||
add r2, r2, 1
|
add r2, r2, 1
|
||||||
st r2, r3, 0
|
st r2, r3, 0
|
||||||
/* End program */
|
/* End program */
|
||||||
halt
|
halt
|
||||||
|
|
||||||
.global rising
|
.global rising
|
||||||
rising:
|
rising:
|
||||||
/* Increment rising_edge_count */
|
/* Increment rising_edge_count */
|
||||||
move r3, rising_edge_count
|
move r3, rising_edge_count
|
||||||
ld r2, r3, 0
|
ld r2, r3, 0
|
||||||
add r2, r2, 1
|
add r2, r2, 1
|
||||||
st r2, r3, 0
|
st r2, r3, 0
|
||||||
/* End program */
|
/* End program */
|
||||||
halt
|
halt
|
||||||
|
|
Loading…
Reference in a new issue