8000 nrf/uart: Add support for UARTE (EasyDMA). · jimmo/micropython@c561ae6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c561ae6

Browse files
committed
nrf/uart: Add support for UARTE (EasyDMA).
1 parent 02a8c31 commit c561ae6

File tree

1 file changed

+42
-0
lines changed
  • ports/nrf/modules/machine

1 file changed

+42
-0
lines changed

ports/nrf/modules/machine/uart.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444
#include "mpconfigboard.h"
4545
#include "nrf.h"
4646
#include "mphalport.h"
47+
48+
#if NRFX_UART_ENABLED
4749
#include "nrfx_uart.h"
50+
#else
51+
#include "nrfx_uarte.h"
52+
#endif
4853

4954

5055
#if MICROPY_PY_MACHINE_UART
@@ -56,6 +61,40 @@ typedef struct _machine_hard_uart_buf_t {
5661
volatile ringbuf_t rx_ringbuf;
5762
} machine_hard_uart_buf_t;
5863

64+
#if NRFX_UARTE_ENABLED
65+
66+
#define nrfx_uart_t nrfx_uarte_t
67+
#define nrfx_uart_config_t nrfx_uarte_config_t
68+
69+
#define nrfx_uart_rx nrfx_uarte_rx
70+
#define nrfx_uart_tx nrfx_uarte_tx
71+
#define nrfx_uart_tx_in_progress nrfx_uarte_tx_in_progress
72+
#define nrfx_uart_init nrfx_uarte_init
73+
#define nrfx_uart_event_t nrfx_uarte_event_t
74+
#define NRFX_UART_INSTANCE NRFX_UARTE_INSTANCE
75+
76+
#define NRF_UART_HWFC_ENABLED NRF_UARTE_HWFC_ENABLED
77+
#define NRF_UART_HWFC_DISABLED NRF_UARTE_HWFC_DISABLED
78+
#define NRF_UART_PARITY_EXCLUDED NRF_UARTE_PARITY_EXCLUDED
79+
#define NRFX_UART_EVT_RX_DONE NRFX_UARTE_EVT_RX_DONE
80+
81+
#define NRF_UART_BAUDRATE_1200 NRF_UARTE_BAUDRATE_1200
82+
#define NRF_UART_BAUDRATE_2400 NRF_UARTE_BAUDRATE_2400
83+
#define NRF_UART_BAUDRATE_4800 NRF_UARTE_BAUDRATE_4800
84+
#define NRF_UART_BAUDRATE_9600 NRF_UARTE_BAUDRATE_9600
85+
#define NRF_UART_BAUDRATE_14400 NRF_UARTE_BAUDRATE_14400
86+
#define NRF_UART_BAUDRATE_19200 NRF_UARTE_BAUDRATE_19200
87+
#define NRF_UART_BAUDRATE_28800 NRF_UARTE_BAUDRATE_28800
88+
#define NRF_UART_BAUDRATE_38400 NRF_UARTE_BAUDRATE_38400
89+
#define NRF_UART_BAUDRATE_57600 NRF_UARTE_BAUDRATE_57600
90+
#define NRF_UART_BAUDRATE_76800 NRF_UARTE_BAUDRATE_76800
91+
#define NRF_UART_BAUDRATE_115200 NRF_UARTE_BAUDRATE_115200
92+
#define NRF_UART_BAUDRATE_230400 NRF_UARTE_BAUDRATE_230400
93+
#define NRF_UART_BAUDRATE_250000 NRF_UARTE_BAUDRATE_250000
94+
#define NRF_UART_BAUDRATE_1000000 NRF_UARTE_BAUDRATE_1000000
95+
96+
#endif
97+
5998
typedef struct _machine_hard_uart_obj_t {
6099
mp_obj_base_t base;
61100
const nrfx_uart_t * p_uart; // Driver instance
@@ -210,7 +249,10 @@ STATIC mp_obj_t machine_hard_uart_make_new(const mp_obj_type_t *type, size_t n_a
210249
// Enable event callback and start asynchronous receive
211250
nrfx_uart_init(self->p_uart, &config, uart_event_handler);
212251
nrfx_uart_rx(self->p_uart, &self->buf->rx_buf[0], 1);
252+
253+
#if NRFX_UART_ENABLED
213254
nrfx_uart_rx_enable(self->p_uart);
255+
#endif
214256

215257
return MP_OBJ_FROM_PTR(self);
216258
}

0 commit comments

Comments
 (0)
0