MicroPython API Reference
Intarva’s MicroPython runtime is a bit-perfect implementation of the machine module, optimized for real-time simulation.
1. The machine Module
This is the primary module for hardware interaction. Every method is mapped to the Intarva Netlist Solver.
| Class / Method | Description & Supported Features |
|---|---|
Pin(id, mode, pull) |
Supports IN, OUT, PULL_UP, PULL_DOWN. Also supports irq() triggers. |
ADC(pin) |
16-bit resolution reading (read_u16()). Returns 0–65535. |
PWM(pin, freq, duty) |
Adjustable frequency (1Hz–1MHz). duty_u16() control. |
I2C(id, sda, scl) |
Supports scan(), readfrom(), writeto(). Bit-perfect I2C bus simulation. |
SPI(id, baud, sck, mosi) |
Full-duplex synchronous communication. |
RTC() |
Real-Time Clock synced to your host machine’s system time. |
2. Interrupts (IRQ)
Intarva supports high-speed interrupts. When a Net changes state, the board worker can immediately trigger a callback function.
from machine import Pin
def handler(pin):
print("Interrupt triggered on", pin)
btn = Pin(14, Pin.IN)
btn.irq(handler, trigger=Pin.IRQ_RISING)
Simulation Note: Interrupts are processed at the start of every engine sub-tick, ensuring zero-latency response to fast external signals.
3. Built-in Standard Libraries
Beyond the machine module, the following libraries are pre-baked into the WASM worker:
time:sleep(),sleep_ms(),ticks_ms(). (Simulation-time accurate).math: Full floating-point math support.neopixel: Native driver for WS2812B strips.ujson: Fast JSON serialization for data logging.struct: Handling binary data packs.