espulp – ESP Ultra Low Power Processor Module — Adafruit CircuitPython 1 documentation (original) (raw)

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.

deinit() → None

Deinitialises the ULP and releases it for another program.

__enter__() → ULP

No-op used by Context Managers.

__exit__() → None

Automatically deinitializes the hardware when exiting a context. SeeLifetime and ContextManagers for more info.

set_wakeup_period(period_index: int, period_us: int) → None

Sets the wakeup period for the ULP.

Parameters:

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:

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() or alarm.exit_and_deep_sleep_until_alarms().

Parameters:

ulp (ULP) – The ulp instance