2121#include "py/objproperty.h"
2222#include "py/runtime.h"
2323
24-
2524//| FifoType = Literal["auto", "txrx", "tx", "rx", "txput", "txget", "putget"]
2625//| FifoType_piov0 = Literal["auto", "txrx", "tx", "rx"]
2726//| MovStatusType = Literal["txfifo", "rxfifo", "irq"]
@@ -233,8 +232,8 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
233232
234233 { MP_QSTR_offset , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = PIO_ANY_OFFSET } },
235234
236- { MP_QSTR_fifo_type , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_obj = MP_ROM_QSTR (MP_QSTR_rxtx ) } },
237- { MP_QSTR_mov_status_type , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_obj = MP_ROM_QSTR (MP_QSTR_txfifo ) } },
235+ { MP_QSTR_fifo_type , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = MP_ROM_QSTR (MP_QSTR_rxtx ) } },
236+ { MP_QSTR_mov_status_type , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = MP_ROM_QSTR (MP_QSTR_txfifo ) } },
238237 { MP_QSTR_mov_status_n , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
239238 };
240239 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
@@ -300,9 +299,11 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
300299 };
301300 const int fifo_values [] = { PIO_FIFO_JOIN_AUTO , PIO_FIFO_JOIN_NONE , PIO_FIFO_JOIN_TX , PIO_FIFO_JOIN_RX ,
302301 #if PICO_PIO_VERSION > 0
303- PIO_FIFO_JOIN_TXPUT , PIO_FIFO_JOIN_PUTGET
302+ PIO_FIFO_JOIN_TXPUT , PIO_FIFO_JOIN_TXGET , PIO_FIFO_JOIN_PUTGET
304303 #endif
305304 };
305+ MP_STATIC_ASSERT (MP_ARRAY_SIZE (fifo_alternatives ) == MP_ARRAY_SIZE (fifo_values ));
306+
306307 int fifo_type = one_of (MP_QSTR_fifo_type , args [ARG_fifo_type ].u_obj , MP_ARRAY_SIZE (fifo_alternatives ), fifo_alternatives , fifo_values );
307308
308309 const qstr_short_t mov_status_alternatives [] = { MP_QSTR_txfifo , MP_QSTR_rxfifo ,
@@ -315,6 +316,7 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n
315316 STATUS_IRQ_SET
316317 #endif
317318 };
319+ MP_STATIC_ASSERT (MP_ARRAY_SIZE (mov_status_alternatives ) == MP_ARRAY_SIZE (mov_status_values ));
318320 int mov_status_type = one_of (MP_QSTR_mov_status_type , args [ARG_mov_status_type ].u_obj , MP_ARRAY_SIZE (mov_status_alternatives ), mov_status_alternatives , mov_status_values );
319321
320322 common_hal_rp2pio_statemachine_construct (self ,
@@ -907,6 +909,32 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_pc_obj, rp2pio_statemachine_ob
907909MP_PROPERTY_GETTER (rp2pio_statemachine_pc_obj ,
908910 (mp_obj_t )& rp2pio_statemachine_get_pc_obj );
909911
912+ //| rxfifo: AddressRange
913+ //| """Accecss the state machine's rxfifo directly
914+ //|
915+ //| If the state machine's fifo mode is ``txput`` then accessing this object
916+ //| reads values stored by the ``mov rxfifo[], isr`` PIO instruction, and the
917+ //| result of modifying it is undefined.
918+ //|
919+ //| If the state machine's fifo mode is ``txget`` then modifying this object
920+ //| writes values accessed by the ``mov osr, rxfifo[]`` PIO instruction, and
921+ //| the result of accessing it is undefined..
922+ //|
923+ //| If this state machine's mode is something else, then the property's value is `None`.
924+ //|
925+ //| Note: Since the ``txput`` and ``txget`` fifo mode does not exist on RP2040, this property will always be `None`."""
926+ //|
927+
928+ static mp_obj_t rp2pio_statemachine_obj_get_rxfifo (mp_obj_t self_in ) {
929+ rp2pio_statemachine_obj_t * self = MP_OBJ_TO_PTR (self_in );
930+ check_for_deinit (self );
931+ return common_hal_rp2pio_statemachine_get_rxfifo (self );
932+ }
933+ MP_DEFINE_CONST_FUN_OBJ_1 (rp2pio_statemachine_get_rxfifo_obj , rp2pio_statemachine_obj_get_rxfifo );
934+
935+ MP_PROPERTY_GETTER (rp2pio_statemachine_rxfifo_obj ,
936+ (mp_obj_t )& rp2pio_statemachine_get_rxfifo_obj );
937+
910938
911939static const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table [] = {
912940 { MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& rp2pio_statemachine_deinit_obj ) },
@@ -934,6 +962,8 @@ static const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = {
934962
935963 { MP_ROM_QSTR (MP_QSTR_offset ), MP_ROM_PTR (& rp2pio_statemachine_offset_obj ) },
936964 { MP_ROM_QSTR (MP_QSTR_pc ), MP_ROM_PTR (& rp2pio_statemachine_pc_obj ) },
965+
966+ { MP_ROM_QSTR (MP_QSTR_rxfifo ), MP_ROM_PTR (& rp2pio_statemachine_rxfifo_obj ) },
937967};
938968static MP_DEFINE_CONST_DICT (rp2pio_statemachine_locals_dict , rp2pio_statemachine_locals_dict_table ) ;
939969
0 commit comments