You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
esp32/adc: Updated the module to use new driver (esp_adc/adc_oneshot.h).
Tested and confired working state on several pins using:
- esp32
- esp32 C3
- esp32 S2
- esp32 S3
I am unable to test any more hardware as I do not own it yet.
esp32/ulp: Enable RISCV ULP by default on targets that support it
(esp32 S2 & S3) with an option of reverting back to FSM in a custom build.
To use FSM instead, add the line
`set(PREFER_FSM_ULP ON)` in your board's mpconfigboard.cmake
and add
`boards/sdkconfig.ulp_fsm` to the end of SDKCONFIG_DEFAULTS like so:
```
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.spiram_sx
boards/ESP32_GENERIC_S3/sdkconfig.board
boards/sdkconfig.ulp_fsm
)
```
To embed ULP code, define the sources and dependant files using the generated `ulp_embedded.h` file
The app will always be called `ulp_embedded` internally
An example board definition that uses custom ulp code located at `boards/${board}/ulp/main.c`
has the following mpconfigboard.cmake
```
set(MICROPY_SOURCE_BOARD
${MICROPY_SOURCE_BOARD}
${MICROPY_BOARD_DIR}/cmodules/modtest.c
)
set(ulp_embedded_sources ${MICROPY_BOARD_DIR}/ulp/main_pin.c)
set(ulp_dependants ${MICROPY_BOARD_DIR}/cmodules/modtest.c)
```
The `ulp_dependants` is only needed if you have custom c modules that want to reference ULP variables directly.
You can also read and write the embedded ULP variables using `ULP.read(address)` and `ULP.write(address, value)`
By default, when you embed a ULP app, all c variables with the prefix `var_` will be added as constant address offsets to the ULP class,
so you can call `ulp.read(ulp.VAR_TEST)` to get a value that way.
I have confirmed that it *is* possible to load the binary ULP code after flashing a built in version.
When any sources are defined like this, the ULP code will be automatically added the the firmware.
324
+
Any variables prefixed with *var_* will be automatically added to the ULP class and you can use them to reference a memory location for reading and writing
325
+
326
+
Example usage with embedded code::
327
+
328
+
import esp32
329
+
u = esp32.ULP()
330
+
u.run_embedded()
331
+
print(u.read(u.VAR_TEST))
332
+
333
+
334
+
Example usage with external code::
335
+
336
+
import esp32
337
+
u = esp32.ULP()
338
+
339
+
with open("test.bin","rb") as file:
340
+
buf = file.read()
341
+
342
+
u.run(buf)
343
+
print(u.read(0x500000dc))
344
+
345
+
Example usage with external code (FSM)::
346
+
347
+
import esp32
348
+
u = esp32.ULP()
349
+
350
+
with open("fsm.bin","rb") as file:
351
+
buf = file.read()
352
+
353
+
u.run(0x1c,buf)
354
+
print(u.write(0x500000dc, 42))
355
+
356
+
Example usage with embedded code using ADC1 channel 1 on ESP32 S3 (GPIO_2)::
357
+
358
+
import esp32
359
+
u = esp32.ULP()
360
+
361
+
u.adc_init(0,1)
362
+
u.set_wakeup_period(100)
363
+
u.run_embedded()
364
+
print(u.write(u.VAR_DO_ADC_SAMPLING, 1))
307
365
308
-
This class does not provide access to the RISCV ULP co-processor available
309
-
on the ESP32-S2 and ESP32-S3 chips.
366
+
.. note::
367
+
Exposed variables are relative address offsets from RTC_SLOW_MEM address, however you can use full address values also, if loading ULP code from outside the compilation process.
310
368
311
369
.. class:: ULP()
312
370
313
371
This class provides access to the Ultra-Low-Power co-processor.
0 commit comments