8000 rp2/rp2_pio: Add fifo_join support for PIO. · micropython/micropython@641e253 · GitHub
[go: up one dir, main page]

Skip to content

Commit 641e253

Browse files
committed
rp2/rp2_pio: Add fifo_join support for PIO.
The PIO state machines on the RP2040 have 4 word deep TX and RX FIFOs. If you only need one direction, you can "merge" them into either a single 8 word deep TX or RX FIFO. We simply add constants to the PIO object, and set the appropriate bits in `shiftctrl`. Resolves #6854. Signed-off-by: Tim Radvan <tim@tjvr.org>
1 parent d87f42b commit 641e253

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

examples/rp2/pio_uart_rx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
autopush=True,
2323
push_thresh=8,
2424
in_shiftdir=rp2.PIO.SHIFT_RIGHT,
25+
fifo_join=PIO.JOIN_RX,
2526
)
2627
def uart_rx_mini():
2728
# fmt: off

ports/rp2/modules/rp2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ def __init__(
3131
autopush=False,
3232
autopull=False,
3333
push_thresh=32,
34-
pull_thresh=32
34+
pull_thresh=32,
35+
fifo_join=0
3536
):
3637
from array import array
3738

3839
self.labels = {}
3940
execctrl = 0
4041
shiftctrl = (
41-
(pull_thresh & 0x1F) << 25
42+
fifo_join << 30
43+
| (pull_thresh & 0x1F) << 25
4244
| (push_thresh & 0x1F) << 20
4345
| out_shiftdir << 19
4446
| in_shiftdir << 18

ports/rp2/rp2_pio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ STATIC const mp_rom_map_elem_t rp2_pio_locals_dict_table[] = {
363363
{ MP_ROM_QSTR(MP_QSTR_IRQ_SM1), MP_ROM_INT(0x200) },
364364
{ MP_ROM_QSTR(MP_QSTR_IRQ_SM2), MP_ROM_INT(0x400) },
365365
{ MP_ROM_QSTR(MP_QSTR_IRQ_SM3), MP_ROM_INT(0x800) },
366+
367+
{ MP_ROM_QSTR(MP_QSTR_JOIN_NONE), MP_ROM_INT(0) },
368+
{ MP_ROM_QSTR(MP_QSTR_JOIN_TX), MP_ROM_INT(1) },
369+
{ MP_ROM_QSTR(MP_QSTR_JOIN_RX), MP_ROM_INT(2) },
366370
};
367371
STATIC MP_DEFINE_CONST_DICT(rp2_pio_locals_dict, rp2_pio_locals_dict_table);
368372

0 commit comments

Comments
 (0)
0