Skip to content

Commit ddac37a

Browse files
authored
Merge pull request #6011 from tannewt/tannewt-patch-1
Explain read and write size to/from PIO FIFOs
2 parents 3409243 + 22928fe commit ddac37a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

ports/raspberrypi/bindings/rp2pio/StateMachine.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_stop_obj, rp2pio_statemachine_stop
360360
//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
361361
//| """Write the data contained in ``buffer`` to the state machine. If the buffer is empty, nothing happens.
362362
//|
363+
//| Writes to the FIFO will match the input buffer's element size. For example, bytearray elements
364+
//| will perform 8 bit writes to the PIO FIFO. The RP2040's memory bus will duplicate the value into
365+
//| the other byte positions. So, pulling more data in the PIO assembly will read the duplicated values.
366+
//|
367+
//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired
368+
//| size.
369+
//|
363370
//| :param ~circuitpython_typing.ReadableBuffer buffer: Write out the data in this buffer
364371
//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]``
365372
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``"""
@@ -408,6 +415,14 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_write_obj, 2, rp2pio_statemachine
408415
//| """Read into ``buffer``. If the number of bytes to read is 0, nothing happens. The buffer
409416
//| includes any data added to the fifo even if it was added before this was called.
410417
//|
418+
//| Reads from the FIFO will match the input buffer's element size. For example, bytearray elements
419+
//| will perform 8 bit reads from the PIO FIFO. The alignment within the 32 bit value depends on
420+
//| ``in_shift_right``. When ``in_shift_right`` is True, the upper N bits will be read. The lower
421+
//| bits will be read when ``in_shift_right`` is False.
422+
//|
423+
//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired
424+
//| size.
425+
//|
411426
//| :param ~circuitpython_typing.WriteableBuffer buffer: Read data into this buffer
412427
//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]``
413428
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``"""
@@ -456,6 +471,12 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_readinto_obj, 2, rp2pio_statemach
456471
//| may be different. The function will return once both are filled.
457472
//| If buffer slice lengths are both 0, nothing happens.
458473
//|
474+
//| Data transfers to and from the FIFOs will match the corresponding buffer's element size. See
475+
//| `write` and `readinto` for details.
476+
//|
477+
//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired
478+
//| size.
479+
//|
459480
//| :param ~circuitpython_typing.ReadableBuffer buffer_out: Write out the data in this buffer
460481
//| :param ~circuitpython_typing.WriteableBuffer buffer_in: Read data into this buffer
461482
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``

0 commit comments

Comments
 (0)