PyMCU Libraries#
Architectural Shift: MicroPython Compatibility
PyMCU’s standard library is being restructured. The official user-facing API will soon be aligned with the MicroPython / CircuitPython machine and board modules.
The modules documented below (pymcu.hal.* and pymcu.drivers.*) are considered internal foundations (HAL). While they work perfectly, they are designed to be wrapped by the upcoming compatibility layers. Users are strongly encouraged to use the machine module (when available) for better portability across different hardware.
The PyMCU internal library provides hardware abstraction layer (HAL) modules and device drivers. All modules compile to tight native machine code — there is no Python runtime on the device.
Internal HAL modules#
Module |
Import path |
Description |
|---|---|---|
|
Digital I/O, pin interrupts |
|
|
Serial communication |
|
|
Analog-to-digital conversion |
|
|
Analog output — refused on every part PyMCU targets today, and says what to use instead |
|
|
Hardware timers |
|
|
Pulse-width modulation |
|
|
Measuring the pulses on a pin, and sending a gated carrier |
|
|
SPI bus (hardware + soft) |
|
|
I2C bus (hardware + soft) |
|
|
Non-volatile byte storage |
|
|
Watchdog timer |
|
|
Sleep modes |
|
|
Busy-wait delays |
Device drivers#
Driver |
Import path |
Description |
|---|---|---|
|
Temperature and humidity sensor |
Third-party libraries#
Writing a PyMCU library — package layout, manifest, architecture dispatch and publishing, for anyone shipping a driver of their own.
Cross-backend parity#
HAL Parity — a generated report comparing the public API each architecture backend offers against the facade, and auditing the CircuitPython and MicroPython compatibility layers for chip-specific code that should live in the HAL instead.
Design principles#
All HAL classes are @inline — they have zero SRAM cost. Instantiating a Pin or UART
compiles to register writes; no struct is allocated on the MCU. See Type System
for details on the Zero-Cost Abstraction model.