espulp
– ESP Ultra Low Power Processor Module
The espulp
module adds ability to load and run
programs on the ESP32-Sx’s ultra-low-power RISC-V processor.
import espulp
import memorymap
shared_mem = memorymap.AddressRange(start=0x50000000, length=1024)
ulp = espulp.ULP()
with open("program.bin", "rb") as f:
program = f.read()
ulp.run(program)
print(shared_mem[0])
# ulp.halt()
Available on these boards
- espulp.get_rtc_gpio_number(pin: microcontroller.Pin) int | None
Return the RTC GPIO number of the given pin or None if not connected to RTC GPIO.
- class espulp.Architecture
The ULP architectures available.
- FSM: Architecture
The ULP Finite State Machine.
- RISCV: Architecture
The ULP RISC-V Coprocessor.
- class espulp.ULP(arch: Architecture = Architecture.FSM)
The ultra-low-power processor.
Raises an exception if another ULP has been instantiated. This ensures that is is only used by one piece of code at a time.
- Parameters:
arch (Architecture) – The ulp arch.
- __exit__() None
Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.
- run(program: circuitpython_typing.ReadableBuffer, *, entrypoint: int = 0, pins: Sequence[microcontroller.Pin] = ()) None
Loads the program into ULP memory and then runs the program.
The program will continue to run even Python is halted or in deep-sleep.
- Parameters:
program (ReadableBuffer) – the ULP binary.
entrypoint (int) – Specifies the offset (in bytes) of the first instruction from the start of the program (Only used by FSM ULP).
pins (Sequence[microcontroller.Pin]) – Pins made available to the ULP. The pins are claimed and not reset until
halt()
is called.
- halt() None
Halts the running program and releases the pins given in
run()
. Note: for the FSM ULP, a running ULP program is not actually interrupted. Instead, only the wakeup timer is stopped.
- arch: Architecture
The ulp architecture. (read-only)
- class espulp.ULPAlarm(ulp: ULP)
Trigger an alarm when the ULP requests wake-up.
Create an alarm that will be triggered when the ULP requests wake-up.
The alarm is not active until it is passed to an
alarm
-enabling function, such asalarm.light_sleep_until_alarms()
oralarm.exit_and_deep_sleep_until_alarms()
.- Parameters:
ulp (ULP) – The ulp instance