|
30 | 30 | #include "py/runtime.h"
|
31 | 31 | #include "py/mperrno.h"
|
32 | 32 | #include "py/mphal.h"
|
| 33 | +#include "py/objarray.h" |
33 | 34 | #include "shared/runtime/mpirq.h"
|
34 | 35 | #include "modrp2.h"
|
35 | 36 |
|
@@ -809,6 +810,24 @@ STATIC mp_obj_t rp2_state_machine_tx_fifo(mp_obj_t self_in) {
|
809 | 810 | }
|
810 | 811 | STATIC MP_DEFINE_CONST_FUN_OBJ_1(rp2_state_machine_tx_fifo_obj, rp2_state_machine_tx_fifo);
|
811 | 812 |
|
| 813 | +STATIC mp_obj_t rp2_state_machine_get_fifo_proxy(mp_obj_t self_in, mp_obj_t read_not_write) { |
| 814 | + rp2_state_machine_obj_t *self = MP_OBJ_TO_PTR(self_in); |
| 815 | + |
| 816 | + mp_obj_array_t *proxy = m_new_obj(mp_obj_array_t); |
| 817 | + proxy->base.type = &mp_type_array; |
| 818 | + proxy->typecode = 'I'; |
| 819 | + proxy->free = 0; |
| 820 | + proxy->len = 1; |
| 821 | + if (mp_obj_is_true(read_not_write)) { |
| 822 | + proxy->items = (void *)&self->pio->rxf[self->sm]; |
| 823 | + } else { |
| 824 | + proxy->items = (void *)&self->pio->txf[self->sm]; |
| 825 | + } |
| 826 | + |
| 827 | + return MP_OBJ_FROM_PTR(proxy); |
| 828 | +} |
| 829 | +STATIC MP_DEFINE_CONST_FUN_OBJ_2(rp2_state_machine_get_fifo_proxy_obj, rp2_state_machine_get_fifo_proxy); |
| 830 | + |
812 | 831 | // StateMachine.irq(handler=None, trigger=0|1, hard=False)
|
813 | 832 | STATIC mp_obj_t rp2_state_machine_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
814 | 833 | enum { ARG_handler, ARG_trigger, ARG_hard };
|
@@ -874,6 +893,7 @@ STATIC const mp_rom_map_elem_t rp2_state_machine_locals_dict_table[] = {
|
874 | 893 | { MP_ROM_QSTR(MP_QSTR_put), MP_ROM_PTR(&rp2_state_machine_put_obj) },
|
875 | 894 | { MP_ROM_QSTR(MP_QSTR_rx_fifo), MP_ROM_PTR(&rp2_state_machine_rx_fifo_obj) },
|
876 | 895 | { MP_ROM_QSTR(MP_QSTR_tx_fifo), MP_ROM_PTR(&rp2_state_machine_tx_fifo_obj) },
|
| 896 | + { MP_ROM_QSTR(MP_QSTR_get_fifo_proxy), MP_ROM_PTR(&rp2_state_machine_get_fifo_proxy_obj) }, |
877 | 897 | { MP_ROM_QSTR(MP_QSTR_irq), MP_ROM_PTR(&rp2_state_machine_irq_obj) },
|
878 | 898 | };
|
879 | 899 | STATIC MP_DEFINE_CONST_DICT(rp2_state_machine_locals_dict, rp2_state_machine_locals_dict_table);
|
|
0 commit comments