Skip to content

Commit c38972b

Browse files
microdev1tannewt
authored andcommitted
update ulp implementation
1 parent 242a720 commit c38972b

6 files changed

Lines changed: 44 additions & 23 deletions

File tree

ports/espressif/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ INC += \
104104
-isystem esp-idf/components/soc/include \
105105
-isystem esp-idf/components/soc/$(IDF_TARGET)/include \
106106
-isystem esp-idf/components/spi_flash/include \
107-
-isystem esp-idf/components/ulp/include \
107+
-isystem esp-idf/components/ulp/ulp_fsm/include \
108108
-isystem esp-idf/components/ulp/ulp_riscv/include \
109109
-isystem esp-idf/components/ulp/ulp_common/include \
110110
-isystem esp-idf/components/ulp/ulp_common/include/$(IDF_TARGET) \

ports/espressif/common-hal/espulp/ULP.c

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,42 @@ void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t
9090
ulp_set_wakeup_period(0, 20000);
9191

9292
switch (self->arch) {
93+
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
9394
case FSM:
9495
ulp_load_binary(0, (const uint8_t *)program, length);
9596
ulp_run(0);
9697
break;
98+
#endif
99+
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
97100
case RISCV:
98-
#ifndef CONFIG_IDF_TARGET_ESP32
99101
ulp_riscv_load_binary((const uint8_t *)program, length);
100102
ulp_riscv_run();
101103
break;
102-
#endif
104+
#endif
103105
default:
104106
mp_raise_NotImplementedError(NULL);
105107
break;
106108
}
107109
}
108110

109111
void common_hal_espulp_ulp_halt(espulp_ulp_obj_t *self) {
110-
#ifdef CONFIG_IDF_TARGET_ESP32
111-
mp_raise_NotImplementedError(NULL);
112-
#else
113-
ulp_riscv_timer_stop();
114-
ulp_riscv_halt();
115-
#endif
112+
switch (self->arch) {
113+
/*
114+
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
115+
case FSM:
116+
break;
117+
#endif
118+
*/
119+
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
120+
case RISCV:
121+
ulp_riscv_timer_stop();
122+
ulp_riscv_halt();
123+
break;
124+
#endif
125+
default:
126+
mp_raise_NotImplementedError(NULL);
127+
break;
128+
}
116129

117130
// Release pins we were using.
118131
for (uint8_t i = 0; i < 32; i++) {
@@ -130,11 +143,19 @@ void common_hal_espulp_ulp_construct(espulp_ulp_obj_t *self, espulp_architecture
130143
mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_ULP);
131144
}
132145

133-
#ifdef CONFIG_IDF_TARGET_ESP32
134-
if (self->arch == RISCV) {
135-
mp_raise_NotImplementedError(NULL);
146+
switch (self->arch) {
147+
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
148+
case FSM:
149+
break;
150+
#endif
151+
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
152+
case RISCV:
153+
break;
154+
#endif
155+
default:
156+
mp_raise_NotImplementedError(NULL);
157+
break;
136158
}
137-
#endif
138159

139160
self->arch = arch;
140161
self->inited = true;

ports/espressif/common-hal/espulp/ULPAlarm.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,22 @@ void espulp_ulpalarm_set_alarm(const bool deep_sleep, const size_t n_alarms, con
8181

8282
// enable ulp interrupt
8383
switch (alarm->ulp->arch) {
84+
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
8485
case FSM:
8586
#ifdef CONFIG_IDF_TARGET_ESP32
86-
rtc_isr_register(&ulp_interrupt, NULL, RTC_CNTL_ULP_CP_INT_RAW);
87+
rtc_isr_register(&ulp_interrupt, NULL, RTC_CNTL_ULP_CP_INT_RAW, 0);
8788
#else
88-
rtc_isr_register(&ulp_interrupt, NULL, RTC_CNTL_ULP_CP_INT_ST);
89+
rtc_isr_register(&ulp_interrupt, NULL, RTC_CNTL_ULP_CP_INT_ST, 0);
8990
#endif
9091
REG_SET_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_ULP_CP_INT_ENA);
9192
break;
93+
#endif
94+
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
9295
case RISCV:
93-
#ifndef CONFIG_IDF_TARGET_ESP32
94-
rtc_isr_register(&ulp_interrupt, NULL, RTC_CNTL_COCPU_INT_ST);
96+
rtc_isr_register(&ulp_interrupt, NULL, RTC_CNTL_COCPU_INT_ST, 0);
9597
REG_SET_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_COCPU_INT_ENA);
9698
break;
97-
#endif
99+
#endif
98100
default:
99101
mp_raise_NotImplementedError(NULL);
100102
break;
@@ -110,8 +112,10 @@ void espulp_ulpalarm_prepare_for_deep_sleep(void) {
110112

111113
// disable ulp interrupt
112114
rtc_isr_deregister(&ulp_interrupt, NULL);
115+
#ifdef CONFIG_ULP_COPROC_TYPE_FSM
113116
REG_CLR_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_ULP_CP_INT_ENA);
114-
#ifndef CONFIG_IDF_TARGET_ESP32
117+
#endif
118+
#ifdef CONFIG_ULP_COPROC_TYPE_RISCV
115119
REG_CLR_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_COCPU_INT_ENA);
116120
#endif
117121

ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ CONFIG_ESP32S2_DATA_CACHE_16KB=y
77
CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y
88

99
CONFIG_ULP_COPROC_ENABLED=y
10-
CONFIG_ULP_COPROC_TYPE_RISCV=y
1110
CONFIG_ULP_COPROC_RESERVE_MEM=8176

ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1=y
88
CONFIG_ESP32S3_RTCDATA_IN_FAST_MEM=y
99

1010
CONFIG_ULP_COPROC_ENABLED=y
11-
CONFIG_ULP_COPROC_TYPE_RISCV=y
1211
CONFIG_ULP_COPROC_RESERVE_MEM=8176

ports/espressif/mpconfigport.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ CIRCUITPY_WIFI ?= 1
4848
ifeq ($(IDF_TARGET),esp32)
4949
# Modules
5050
CIRCUITPY_BLEIO = 0
51-
CIRCUITPY_ESPULP = 0
52-
CIRCUITPY_MEMORYMAP = 0
5351
CIRCUITPY_PARALLELDISPLAY = 0
5452
CIRCUITPY_RGBMATRIX = 0
5553
# Features

0 commit comments

Comments
 (0)