21
21
#include "py/objproperty.h"
22
22
#include "py/runtime.h"
23
23
24
-
25
24
//| FifoType = Literal["auto", "txrx", "tx", "rx", "txput", "txget", "putget"]
26
25
//| FifoType_piov0 = Literal["auto", "txrx", "tx", "rx"]
27
26
//| 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
233
232
234
233
{ MP_QSTR_offset , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = PIO_ANY_OFFSET } },
235
234
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 ) } },
238
237
{ MP_QSTR_mov_status_n , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
239
238
};
240
239
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
300
299
};
301
300
const int fifo_values [] = { PIO_FIFO_JOIN_AUTO , PIO_FIFO_JOIN_NONE , PIO_FIFO_JOIN_TX , PIO_FIFO_JOIN_RX ,
302
301
#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
304
303
#endif
305
304
};
305
+ MP_STATIC_ASSERT (MP_ARRAY_SIZE (fifo_alternatives ) == MP_ARRAY_SIZE (fifo_values ));
306
+
306
307
int fifo_type = one_of (MP_QSTR_fifo_type , args [ARG_fifo_type ].u_obj , MP_ARRAY_SIZE (fifo_alternatives ), fifo_alternatives , fifo_values );
307
308
308
309
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
315
316
STATUS_IRQ_SET
316
317
#endif
317
318
};
319
+ MP_STATIC_ASSERT (MP_ARRAY_SIZE (mov_status_alternatives ) == MP_ARRAY_SIZE (mov_status_values ));
318
320
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 );
319
321
320
322
common_hal_rp2pio_statemachine_construct (self ,
@@ -907,6 +909,32 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_get_pc_obj, rp2pio_statemachine_ob
907
909
MP_PROPERTY_GETTER (rp2pio_statemachine_pc_obj ,
908
910
(mp_obj_t )& rp2pio_statemachine_get_pc_obj );
909
911
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
+
910
938
911
939
static const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table [] = {
912
940
{ 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[] = {
934
962
935
963
{ MP_ROM_QSTR (MP_QSTR_offset ), MP_ROM_PTR (& rp2pio_statemachine_offset_obj ) },
936
964
{ 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 ) },
937
967
};
938
968
static MP_DEFINE_CONST_DICT (rp2pio_statemachine_locals_dict , rp2pio_statemachine_locals_dict_table ) ;
939
969
0 commit comments