uarte malloc if buffer is not in SRAM

This commit is contained in:
hathach 2018-09-24 16:18:49 +07:00
parent 4015023e01
commit 1782ceab35

View File

@ -203,7 +203,14 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
nrfx_uarte_tx_abort(&self->uarte); nrfx_uarte_tx_abort(&self->uarte);
} }
(*errcode) = nrfx_uarte_tx(&self->uarte, data, len); // EasyDMA can only access SRAM
uint8_t * tx_buf = (uint8_t*) data;
if ( !nrfx_is_in_ram(data) ) {
tx_buf = (uint8_t *) gc_alloc(len, false, false);
memcpy(tx_buf, data, len);
}
(*errcode) = nrfx_uarte_tx(&self->uarte, tx_buf, len);
_VERIFY_ERR(*errcode); _VERIFY_ERR(*errcode);
(*errcode) = 0; (*errcode) = 0;
@ -214,6 +221,10 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
#endif #endif
} }
if ( !nrfx_is_in_ram(data) ) {
gc_free(tx_buf);
}
return len; return len;
#endif #endif
} }