Skip to content

Instantly share code, notes, and snippets.

View hessammehr's full-sized avatar

Hessam Mehr hessammehr

View GitHub Profile
@hessammehr
hessammehr / pio_ctrl.py
Last active October 17, 2023 08:10
RP2040 PIO registers using uctypes for Micropython
from uctypes import BF_POS, BF_LEN, BFUINT32, ARRAY, UINT32, struct
PIO_BASE = [0x50200000, 0x50300000]
PIO_CTRL_FIELDS = {
'CLKDIV_RESTART': 8 << BF_POS | 4 << BF_LEN | BFUINT32,
'SM_RESTART': 4 << BF_POS | 4 << BF_LEN | BFUINT32,
'SM_ENABLE': 0 << BF_POS | 4 << BF_LEN | BFUINT32,
}