Skip to content

Commit 96fd89a

Browse files
committed
ports/rp2: Provide direct memory access to PIO FIFOs via proxy arrays.
Signed-off-by: Nicko van Someren <nicko@nicko.org>
1 parent 516385c commit 96fd89a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ports/rp2/rp2_pio.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "py/runtime.h"
3131
#include "py/mperrno.h"
3232
#include "py/mphal.h"
33+
#include "py/objarray.h"
3334
#include "shared/runtime/mpirq.h"
3435
#include "modrp2.h"
3536

@@ -809,6 +810,24 @@ STATIC mp_obj_t rp2_state_machine_tx_fifo(mp_obj_t self_in) {
809810
}
810811
STATIC MP_DEFINE_CONST_FUN_OBJ_1(rp2_state_machine_tx_fifo_obj, rp2_state_machine_tx_fifo);
811812

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+
812831
// StateMachine.irq(handler=None, trigger=0|1, hard=False)
813832
STATIC mp_obj_t rp2_state_machine_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
814833
enum { ARG_handler, ARG_trigger, ARG_hard };
@@ -874,6 +893,7 @@ STATIC const mp_rom_map_elem_t rp2_state_machine_locals_dict_table[] = {
874893
{ MP_ROM_QSTR(MP_QSTR_put), MP_ROM_PTR(&rp2_state_machine_put_obj) },
875894
{ MP_ROM_QSTR(MP_QSTR_rx_fifo), MP_ROM_PTR(&rp2_state_machine_rx_fifo_obj) },
876895
{ 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) },
877897
{ MP_ROM_QSTR(MP_QSTR_irq), MP_ROM_PTR(&rp2_state_machine_irq_obj) },
878898
};
879899
STATIC MP_DEFINE_CONST_DICT(rp2_state_machine_locals_dict, rp2_state_machine_locals_dict_table);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy