Skip to content

Commit bc97045

Browse files
committed
nrf/uart: Handle sending (string) data stored in flash.
Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent 43c19b1 commit bc97045

File tree

1 file changed

+11
-1
lines changed
  • ports/nrf/modules/machine

1 file changed

+11
-1
lines changed

ports/nrf/modules/machine/uart.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
// This file is never compiled standalone, it's included directly from
3030
// extmod/machine_uart.c via MICROPY_PY_MACHINE_UART_INCLUDEFILE.
3131

32+
#include <string.h>
3233
#include "py/mperrno.h"
3334
#include "py/mphal.h"
3435
#include "py/ringbuf.h"
@@ -319,8 +320,17 @@ static mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
319320

320321
static mp_uint_t mp_machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
321322
machine_uart_obj_t *self = self_in;
323+
uint8_t *buf = (uint8_t *)buf_in;
324+
#if !NRFX_UART_ENABLED
325+
if (!nrfx_is_in_ram(buf_in)) {
326+
// EasyDMA requires that transfer buffers are placed in DataRAM,
327+
// NRFX_ERROR_INVALID_ADDR if the are not.
328+
buf = alloca(size);
329+
memcpy((void *)buf, buf_in, size);
330+
}
331+
#endif
322332

323-
nrfx_err_t err = nrfx_uart_tx(self->p_uart, buf_in, size);
333+
nrfx_err_t err = nrfx_uart_tx(self->p_uart, buf, size);
324334
if (err == NRFX_SUCCESS) {
325335
while (nrfx_uart_tx_in_progress(self->p_uart)) {
326336
MICROPY_EVENT_POLL_HOOK;

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