Browse Source

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>
pull/7135/head
Tim Radvan 4 years ago
committed by Damien George
parent
commit
f842a40df4
  1. 1
      examples/rp2/pio_uart_rx.py
  2. 6
      ports/rp2/modules/rp2.py
  3. 4
      ports/rp2/rp2_pio.c

1
examples/rp2/pio_uart_rx.py

@ -22,6 +22,7 @@ PIO_RX_PIN = Pin(3, Pin.IN, Pin.PULL_UP)
autopush=True, autopush=True,
push_thresh=8, push_thresh=8,
in_shiftdir=rp2.PIO.SHIFT_RIGHT, in_shiftdir=rp2.PIO.SHIFT_RIGHT,
fifo_join=PIO.JOIN_RX,
) )
def uart_rx_mini(): def uart_rx_mini():
# fmt: off # fmt: off

6
ports/rp2/modules/rp2.py

@ -31,7 +31,8 @@ class PIOASMEmit:
autopush=False, autopush=False,
autopull=False, autopull=False,
push_thresh=32, push_thresh=32,
pull_thresh=32 pull_thresh=32,
fifo_join=0
): ):
# uarray is a built-in module so importing it here won't require # uarray is a built-in module so importing it here won't require
# scanning the filesystem. # scanning the filesystem.
@ -40,7 +41,8 @@ class PIOASMEmit:
self.labels = {} self.labels = {}
execctrl = 0 execctrl = 0
shiftctrl = ( shiftctrl = (
(pull_thresh & 0x1F) << 25 fifo_join << 30
| (pull_thresh & 0x1F) << 25
| (push_thresh & 0x1F) << 20 | (push_thresh & 0x1F) << 20
| out_shiftdir << 19 | out_shiftdir << 19
| in_shiftdir << 18 | in_shiftdir << 18

4
ports/rp2/rp2_pio.c

@ -360,6 +360,10 @@ STATIC const mp_rom_map_elem_t rp2_pio_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SHIFT_LEFT), MP_ROM_INT(0) }, { MP_ROM_QSTR(MP_QSTR_SHIFT_LEFT), MP_ROM_INT(0) },
{ MP_ROM_QSTR(MP_QSTR_SHIFT_RIGHT), MP_ROM_INT(1) }, { MP_ROM_QSTR(MP_QSTR_SHIFT_RIGHT), MP_ROM_INT(1) },
{ MP_ROM_QSTR(MP_QSTR_JOIN_NONE), MP_ROM_INT(0) },
{ MP_ROM_QSTR(MP_QSTR_JOIN_TX), MP_ROM_INT(1) },
{ MP_ROM_QSTR(MP_QSTR_JOIN_RX), MP_ROM_INT(2) },
{ MP_ROM_QSTR(MP_QSTR_IRQ_SM0), MP_ROM_INT(0x100) }, { MP_ROM_QSTR(MP_QSTR_IRQ_SM0), MP_ROM_INT(0x100) },
{ MP_ROM_QSTR(MP_QSTR_IRQ_SM1), MP_ROM_INT(0x200) }, { MP_ROM_QSTR(MP_QSTR_IRQ_SM1), MP_ROM_INT(0x200) },
{ MP_ROM_QSTR(MP_QSTR_IRQ_SM2), MP_ROM_INT(0x400) }, { MP_ROM_QSTR(MP_QSTR_IRQ_SM2), MP_ROM_INT(0x400) },

Loading…
Cancel
Save