8000 ports/rp2: Provide direct memory access to UART FIFOs. by nickovs · Pull Request #13378 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

ports/rp2: Provide direct memory access to UART FIFOs. #13378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions extmod/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ STATIC void mp_machine_uart_writechar(machine_uart_obj_t *self, uint16_t data);
STATIC mp_irq_obj_t *mp_machine_uart_irq(machine_uart_obj_t *self, bool any_args, mp_arg_val_t *args);
#endif

#if MICROPY_PY_MACHINE_UART_FIFO_BUFFER
STATIC mp_int_t mp_machine_uart_fifo_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
#endif

STATIC mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode);
STATIC mp_uint_t mp_machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode);
STATIC mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode);
Expand Down Expand Up @@ -181,6 +185,9 @@ MP_DEFINE_CONST_OBJ_TYPE(
make_new, mp_machine_uart_make_new,
print, mp_machine_uart_print,
protocol, &uart_stream_p,
#if MICROPY_PY_MACHINE_UART_FIFO_BUFFER
buffer, mp_machine_uart_fifo_buffer,
#endif
locals_dict, &machine_uart_locals_dict
);

Expand Down
6 changes: 6 additions & 0 deletions extmod/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
#define MICROPY_PY_MACHINE_UART_IRQ (0)
#endif

// Whether to enable the direct access to the UART FIFO through the buffer interface.
// Requires a port to implement mp_machine_uart_fifo_buffer().
#ifndef MICROPY_PY_MACHINE_UART_FIFO_BUFFER
#define MICROPY_PY_MACHINE_UART_FIFO_BUFFER (0)
#endif

// Temporary support for legacy construction of SoftI2C via I2C type.
#define MP_MACHINE_I2C_CHECK_FOR_LEGACY_SOFTI2C_CONSTRUCTION(n_args, n_kw, all_args) \
do { \
Expand Down
10 changes: 10 additions & 0 deletions ports/rp2/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,15 @@ STATIC mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uint
return ret;
}

STATIC mp_int_t mp_machine_uart_fifo_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
machine_uart_obj_t *self = o_in;

bufinfo->len = 4;
bufinfo->typecode = 'I';
bufinfo->buf = (void *)&uart_get_hw(self->uart)->dr;

return 0;
}

MP_REGISTER_ROOT_POINTER(void *rp2_uart_rx_buffer[2]);
MP_REGISTER_ROOT_POINTER(void *rp2_uart_tx_buffer[2]);
1 change: 1 addition & 0 deletions ports/rp2/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
#define MICROPY_PY_MACHINE_UART (1)
#define MICROPY_PY_MACHINE_UART_INCLUDEFILE "ports/rp2/machine_uart.c"
#define MICROPY_PY_MACHINE_UART_SENDBREAK (1)
#define MICROPY_PY_MACHINE_UART_FIFO_BUFFER (1)
#define MICROPY_PY_MACHINE_WDT (1)
#define MICROPY_PY_MACHINE_WDT_INCLUDEFILE "ports/rp2/machine_wdt.c"
#define MICROPY_PY_ONEWIRE (1)
Expand Down
0