From d8c8c5f0058b7184259d537178b16910271d6d5f Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 18 Sep 2018 20:26:50 +0700 Subject: [PATCH 01/25] remove CFG_HWUART_FOR_SERIAL --- ports/nrf/boards/pca10056/mpconfigboard.h | 3 --- ports/nrf/mphalport.c | 2 +- ports/nrf/supervisor/serial.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index de4545d620..0f34516022 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -36,9 +36,6 @@ #define PORT_HEAP_SIZE (128 * 1024) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 -// Temp (could be removed) 0: usb cdc (default), 1 : hwuart (jlink) -#define CFG_HWUART_FOR_SERIAL 0 - #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) #define DEFAULT_I2C_BUS_SDA (&pin_P0_26) diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index 1e1ebf32e6..163ac8d60b 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -33,7 +33,7 @@ #if (MICROPY_PY_BLE_NUS == 0) -#if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 ) +#if !defined( NRF52840_XXAA) int mp_hal_stdin_rx_chr(void) { uint8_t data = 0; diff --git a/ports/nrf/supervisor/serial.c b/ports/nrf/supervisor/serial.c index da7fe07fd3..18a45f10b9 100644 --- a/ports/nrf/supervisor/serial.c +++ b/ports/nrf/supervisor/serial.c @@ -32,7 +32,7 @@ #include "nrf_gpio.h" #endif -#if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 ) +#if !defined( NRF52840_XXAA) #define INST_NO 0 From 1df3bcf39227f6a71dbed5c2016e4603b70a92ef Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 19 Sep 2018 14:40:37 +0700 Subject: [PATCH 02/25] add board.UART() function --- ports/nrf/Makefile | 1 + ports/nrf/boards/pca10056/mpconfigboard.h | 9 ++------- ports/nrf/boards/pca10056/pins.c | 2 ++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 0e9d224be7..d48b20fd38 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -100,6 +100,7 @@ SRC_C += \ internal_flash.c \ mphalport.c \ tick.c \ + board_busses.c \ boards/$(BOARD)/board.c \ boards/$(BOARD)/pins.c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \ diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index 0f34516022..5aa2191f71 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -28,11 +28,6 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "nRF52840-DK" -// See legend on bottom of board -#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8) -#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6) -#define MICROPY_HW_UART_HWFC (0) - #define PORT_HEAP_SIZE (128 * 1024) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 @@ -43,5 +38,5 @@ #define DEFAULT_SPI_BUS_MOSI (&pin_P1_13) #define DEFAULT_SPI_BUS_MISO (&pin_P1_14) -#define DEFAULT_UART_BUS_RX (&pin_P1_01) -#define DEFAULT_UART_BUS_TX (&pin_P1_02) +#define DEFAULT_UART_BUS_RX (&pin_P0_08) +#define DEFAULT_UART_BUS_TX (&pin_P0_06) diff --git a/ports/nrf/boards/pca10056/pins.c b/ports/nrf/boards/pca10056/pins.c index 1c208f89b5..a57c9d1c95 100644 --- a/ports/nrf/boards/pca10056/pins.c +++ b/ports/nrf/boards/pca10056/pins.c @@ -124,6 +124,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P1_15), MP_ROM_PTR(&pin_P1_15) }, { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_15) }, { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From c5593ec074236a050abb627f7b637e5409e4d3c0 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 19 Sep 2018 17:59:15 +0700 Subject: [PATCH 03/25] got uart tx work --- ports/nrf/boards/pca10056/mpconfigboard.h | 4 +- ports/nrf/common-hal/busio/UART.c | 194 +++++++++++++++++++++- ports/nrf/common-hal/busio/UART.h | 5 +- 3 files changed, 191 insertions(+), 12 deletions(-) diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index 5aa2191f71..00a73005c5 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -38,5 +38,5 @@ #define DEFAULT_SPI_BUS_MOSI (&pin_P1_13) #define DEFAULT_SPI_BUS_MISO (&pin_P1_14) -#define DEFAULT_UART_BUS_RX (&pin_P0_08) -#define DEFAULT_UART_BUS_TX (&pin_P0_06) +#define DEFAULT_UART_BUS_RX (&pin_P1_01) +#define DEFAULT_UART_BUS_TX (&pin_P1_02) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index f05949e152..bcf335d652 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -35,54 +35,234 @@ #include "supervisor/shared/translate.h" #include "tick.h" +#include "nrfx_uart.h" -void common_hal_busio_uart_construct(busio_uart_obj_t *self, - const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, - uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout, - uint8_t receiver_buffer_size) { +static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); + +// expression to examine, and return value in case of failing +#define _VERIFY_ERR(_exp, _ret) \ + do {\ + uint32_t _err = (_exp);\ + if (NRFX_SUCCESS != _err ) {\ + mp_raise_msg_varg(&mp_type_AssertionError, translate("error = 0x%08lX "), _err);\ + return _ret;\ + }\ + }while(0) + +static uint32_t get_nrf_baud (uint32_t baudrate); + + +static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) { + busio_uart_obj_t* self = (busio_uart_obj_t*) context; + + switch ( event->type ) { + case NRFX_UART_EVT_TX_DONE: + case NRFX_UART_EVT_RX_DONE: + self->xferred_bytes = event->data.rxtx.bytes; + break; + + default: + self->xferred_bytes = -(event->data.error.rxtx.bytes); + break; + } +} + + +void common_hal_busio_uart_construct (busio_uart_obj_t *self, + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, + uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout, + uint8_t receiver_buffer_size) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +#else + if ( parity == PARITY_ODD ) { + mp_raise_ValueError(translate("busio.UART odd parity is not supported")); + } + + if ( (tx == mp_const_none) || (rx == mp_const_none) ) { + mp_raise_ValueError(translate("Invalid pins")); + } + + if ( receiver_buffer_size == 0 ) { + mp_raise_ValueError(translate("Invalid buffer size")); + } + + nrfx_uart_config_t config = { + .pseltxd = tx->number, + .pseltxd = rx->number, + .pselcts = NRF_UART_PSEL_DISCONNECTED, + .pselrts = NRF_UART_PSEL_DISCONNECTED, + .p_context = self, + .hwfc = NRF_UART_HWFC_DISABLED, + .parity = (parity == PARITY_NONE) ? NRF_UART_PARITY_EXCLUDED : NRF_UART_PARITY_INCLUDED, + .baudrate = get_nrf_baud(baudrate), + .interrupt_priority = 7 + }; + + nrfx_uart_uninit(&_uart); + _VERIFY_ERR(nrfx_uart_init(&_uart, &config, uart_callback_irq),); + nrfx_uart_rx_enable(&_uart); + + self->buffer_length = receiver_buffer_size; + self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false, false); + if ( self->buffer == NULL ) { + nrfx_uart_uninit(&_uart); + mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); + } + + self->baudrate = baudrate; + self->timeout_ms = timeout; +#endif } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +#else + return (nrf_uart_rx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED) || + (nrf_uart_tx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED); +#endif } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); - if (common_hal_busio_uart_deinited(self)) { - return; +#else + if ( !common_hal_busio_uart_deinited(self) ) { + nrfx_uart_uninit(&_uart); + gc_free(self->buffer); } - // Do deinit; +#endif } // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return 0; +#else + + + + if ( (*errcode) == NRFX_SUCCESS ) { + (*errcode) = 0; + } + + return 0; +#endif } // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return 0; +#else + self->xferred_bytes = 0; + + (*errcode) = nrfx_uart_tx(&_uart, data, len); + _VERIFY_ERR(*errcode, MP_STREAM_ERROR); + (*errcode) = 0; + + uint64_t start_ticks = ticks_ms; + while ( (0 == self->xferred_bytes) && (ticks_ms - start_ticks < self->timeout_ms) ) { +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif + } + + if ( self->xferred_bytes <= 0 ) { + mp_raise_msg_varg(&mp_type_AssertionError, translate("failed")); + *errcode = MP_EAGAIN; + return MP_STREAM_ERROR; + } + + return len; +#endif } uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +#endif return self->baudrate; } void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +#else self->baudrate = baudrate; + nrf_uart_baudrate_set(_uart.p_reg, get_nrf_baud(baudrate)); +#endif } uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +#else + +#endif return 0; } bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { +#ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return false; +#else + return !nrfx_uart_tx_in_progress(&_uart); +#endif +} + +static uint32_t get_nrf_baud (uint32_t baudrate) +{ + if ( baudrate <= 1200 ) { + return NRF_UART_BAUDRATE_1200; + } + else if ( baudrate <= 2400 ) { + return NRF_UART_BAUDRATE_2400; + } + else if ( baudrate <= 4800 ) { + return NRF_UART_BAUDRATE_4800; + } + else if ( baudrate <= 9600 ) { + return NRF_UART_BAUDRATE_9600; + } + else if ( baudrate <= 14400 ) { + return NRF_UART_BAUDRATE_14400; + } + else if ( baudrate <= 19200 ) { + return NRF_UART_BAUDRATE_19200; + } + else if ( baudrate <= 28800 ) { + return NRF_UART_BAUDRATE_28800; + } + else if ( baudrate <= 38400 ) { + return NRF_UART_BAUDRATE_38400; + } + else if ( baudrate <= 57600 ) { + return NRF_UART_BAUDRATE_57600; + } + else if ( baudrate <= 76800 ) { + return NRF_UART_BAUDRATE_76800; + } + else if ( baudrate <= 115200 ) { + return NRF_UART_BAUDRATE_115200; + } + else if ( baudrate <= 230400 ) { + return NRF_UART_BAUDRATE_230400; + } + else if ( baudrate <= 250000 ) { + return NRF_UART_BAUDRATE_250000; + } + else if ( baudrate <= 460800 ) { + return NRF_UART_BAUDRATE_460800; + } + else if ( baudrate <= 921600 ) { + return NRF_UART_BAUDRATE_921600; + } + else { + return NRF_UART_BAUDRATE_1000000; + } } diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 7c0493e37e..ec37373575 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -33,9 +33,6 @@ typedef struct { mp_obj_base_t base; - uint8_t rx_pin; - uint8_t tx_pin; - uint8_t character_bits; bool rx_error; uint32_t baudrate; uint32_t timeout_ms; @@ -45,6 +42,8 @@ typedef struct { uint32_t buffer_size; uint32_t buffer_length; uint8_t* buffer; + + volatile int32_t xferred_bytes; } busio_uart_obj_t; #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H From 9c25306877b3bd381730dfbc82533fc2b683fff3 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 20 Sep 2018 01:07:45 +0700 Subject: [PATCH 04/25] uart rx got some issue with irq --- ports/nrf/common-hal/busio/UART.c | 99 +++++++++++++++++++++++++------ ports/nrf/common-hal/busio/UART.h | 13 ++-- 2 files changed, 86 insertions(+), 26 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index bcf335d652..2c6246f601 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -36,32 +36,49 @@ #include "tick.h" #include "nrfx_uart.h" +#include static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); // expression to examine, and return value in case of failing -#define _VERIFY_ERR(_exp, _ret) \ +#define _VERIFY_ERR(_exp) \ do {\ uint32_t _err = (_exp);\ if (NRFX_SUCCESS != _err ) {\ mp_raise_msg_varg(&mp_type_AssertionError, translate("error = 0x%08lX "), _err);\ - return _ret;\ }\ }while(0) static uint32_t get_nrf_baud (uint32_t baudrate); +static uint32_t rd_error = 0; static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) { busio_uart_obj_t* self = (busio_uart_obj_t*) context; switch ( event->type ) { case NRFX_UART_EVT_TX_DONE: - case NRFX_UART_EVT_RX_DONE: self->xferred_bytes = event->data.rxtx.bytes; break; + case NRFX_UART_EVT_RX_DONE: + // mp_raise_msg_varg(&mp_type_AssertionError, translate("error = 0x%08lX "), event->data.rxtx.bytes); +// for ( int i = 0; i < event->data.rxtx.bytes; i++ ) { +// if ( 0 > ringbuf_put(&self->rx_rbuf, self->rx_xact_buf[i]) ) { +// // buffer is full, overwrite old data +// ringbuf_get(&self->rx_rbuf); +// ringbuf_put(&self->rx_rbuf, self->rx_xact_buf[i]); +// } +// } +// +// nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf)); +// nrfx_uart_rx_enable(&_uart); + + self->rx_count = event->data.rxtx.bytes; + break; + default: + rd_error = event->data.error.error_mask; self->xferred_bytes = -(event->data.error.rxtx.bytes); break; } @@ -95,23 +112,26 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, .p_context = self, .hwfc = NRF_UART_HWFC_DISABLED, .parity = (parity == PARITY_NONE) ? NRF_UART_PARITY_EXCLUDED : NRF_UART_PARITY_INCLUDED, - .baudrate = get_nrf_baud(baudrate), + .baudrate = NRF_UART_BAUDRATE_9600, // get_nrf_baud(baudrate), .interrupt_priority = 7 }; nrfx_uart_uninit(&_uart); - _VERIFY_ERR(nrfx_uart_init(&_uart, &config, uart_callback_irq),); - nrfx_uart_rx_enable(&_uart); + _VERIFY_ERR(nrfx_uart_init(&_uart, &config, uart_callback_irq)); - self->buffer_length = receiver_buffer_size; - self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false, false); - if ( self->buffer == NULL ) { + // Init ring buffer for rx + self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); + if ( !self->buffer ) { nrfx_uart_uninit(&_uart); mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); } + self->bufsize = receiver_buffer_size; self->baudrate = baudrate; self->timeout_ms = timeout; + + _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); + nrfx_uart_rx_enable(&_uart); #endif } @@ -130,7 +150,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { #else if ( !common_hal_busio_uart_deinited(self) ) { nrfx_uart_uninit(&_uart); - gc_free(self->buffer); +// gc_free(self->buffer); } #endif } @@ -142,13 +162,51 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t return 0; #else - - - if ( (*errcode) == NRFX_SUCCESS ) { - (*errcode) = 0; + if ( rd_error ) { + printf("error = 0x%08lX\n", rd_error); + rd_error = 0; } - return 0; + size_t remain = len; +// uint64_t start_ticks = ticks_ms; +// while ( remain && (ticks_ms - start_ticks < self->timeout_ms) ) { +// if ( self->rx_count ) { +// size_t cnt = MIN(self->rx_count, remain); +// memcpy(data, self->buffer, cnt); +// data += cnt; +// remain -= cnt; +// +// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf))); +// nrfx_uart_rx_enable(&_uart); +// } +//#if 0 +// uint32_t received = common_hal_busio_uart_rx_characters_available(self); +// +// // enough bytes received or ringbuffer is full +// if ( (received >= remain) || (received == self->rx_rbuf.size - 1) ) { +// nrfx_uart_rx_abort(&_uart); +// +// while ( !_ringbuf_is_empty(&self->rx_rbuf) ) { +// *data++ = ringbuf_get(&self->rx_rbuf); +// remain--; +// } +// +// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf))); +// nrfx_uart_rx_enable(&_uart); +// } +//#endif +// +//#ifdef MICROPY_VM_HOOK_LOOP +// MICROPY_VM_HOOK_LOOP +//#endif +// } + + printf("rx count = 0x%08lX\n", self->rx_count); + + _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); + nrfx_uart_rx_enable(&_uart); + + return len - remain; #endif } @@ -161,7 +219,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, self->xferred_bytes = 0; (*errcode) = nrfx_uart_tx(&_uart, data, len); - _VERIFY_ERR(*errcode, MP_STREAM_ERROR); + _VERIFY_ERR(*errcode); (*errcode) = 0; uint64_t start_ticks = ticks_ms; @@ -201,9 +259,14 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - +// int count = ((volatile uint16_t) self->rx_rbuf.iput) - ((volatile uint16_t) self->rx_rbuf.iget); +// if ( count < 0 ) { +// count += self->rx_rbuf.size; +// } +// +// return count; + return self->rx_count; #endif - return 0; } bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index ec37373575..8018a93164 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -30,20 +30,17 @@ #include "common-hal/microcontroller/Pin.h" #include "py/obj.h" +#include "py/ringbuf.h" typedef struct { mp_obj_base_t base; - bool rx_error; uint32_t baudrate; uint32_t timeout_ms; - // Index of the oldest received character. - uint32_t buffer_start; - // Index of the next available spot to store a character. - uint32_t buffer_size; - uint32_t buffer_length; - uint8_t* buffer; - volatile int32_t xferred_bytes; + + uint8_t* buffer; + uint32_t bufsize; + volatile uint32_t rx_count; } busio_uart_obj_t; #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H From fe1a2978893555209b26939062cb163208697e2f Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 21 Sep 2018 01:27:52 +0700 Subject: [PATCH 05/25] still have issue with initial uart rx --- ports/nrf/common-hal/busio/UART.c | 91 ++++++++++++++----------------- 1 file changed, 42 insertions(+), 49 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 2c6246f601..79b49464d6 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -51,6 +51,12 @@ static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); static uint32_t get_nrf_baud (uint32_t baudrate); +static inline bool is_receiving (busio_uart_obj_t *self) { + (void) self; + return nrf_uart_int_enable_check(_uart.p_reg, NRF_UART_INT_MASK_RXDRDY); +} + + static uint32_t rd_error = 0; static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) { @@ -62,24 +68,17 @@ static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) break; case NRFX_UART_EVT_RX_DONE: - // mp_raise_msg_varg(&mp_type_AssertionError, translate("error = 0x%08lX "), event->data.rxtx.bytes); -// for ( int i = 0; i < event->data.rxtx.bytes; i++ ) { -// if ( 0 > ringbuf_put(&self->rx_rbuf, self->rx_xact_buf[i]) ) { -// // buffer is full, overwrite old data -// ringbuf_get(&self->rx_rbuf); -// ringbuf_put(&self->rx_rbuf, self->rx_xact_buf[i]); -// } -// } -// -// nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf)); -// nrfx_uart_rx_enable(&_uart); - - self->rx_count = event->data.rxtx.bytes; + self->rx_count += event->data.rxtx.bytes; break; default: rd_error = event->data.error.error_mask; - self->xferred_bytes = -(event->data.error.rxtx.bytes); + + // Walkaround for first 2 error after nrfx_uart_rx_enable() + // queue RX if there is no data and no on-going rx +// if ( !self->rx_count && !is_receiving(self) ) { +// nrfx_uart_rx(&_uart, self->buffer, self->bufsize); +// } break; } } @@ -92,10 +91,6 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - if ( parity == PARITY_ODD ) { - mp_raise_ValueError(translate("busio.UART odd parity is not supported")); - } - if ( (tx == mp_const_none) || (rx == mp_const_none) ) { mp_raise_ValueError(translate("Invalid pins")); } @@ -104,6 +99,10 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, mp_raise_ValueError(translate("Invalid buffer size")); } + if ( parity == PARITY_ODD ) { + mp_raise_ValueError(translate("busio.UART odd parity is not supported")); + } + nrfx_uart_config_t config = { .pseltxd = tx->number, .pseltxd = rx->number, @@ -112,14 +111,14 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, .p_context = self, .hwfc = NRF_UART_HWFC_DISABLED, .parity = (parity == PARITY_NONE) ? NRF_UART_PARITY_EXCLUDED : NRF_UART_PARITY_INCLUDED, - .baudrate = NRF_UART_BAUDRATE_9600, // get_nrf_baud(baudrate), + .baudrate = get_nrf_baud(baudrate), .interrupt_priority = 7 }; nrfx_uart_uninit(&_uart); _VERIFY_ERR(nrfx_uart_init(&_uart, &config, uart_callback_irq)); - // Init ring buffer for rx + // Init buffer for rx self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); if ( !self->buffer ) { nrfx_uart_uninit(&_uart); @@ -130,8 +129,11 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, self->baudrate = baudrate; self->timeout_ms = timeout; - _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); nrfx_uart_rx_enable(&_uart); + + // Somehow the first 2 calls of nrfx_uart_rx will (probably) cause Frame, then Break error + // effectively cancel the rx preps --> Walkaround: keep calling nrfx_uart_rx in error handler if needed + _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); #endif } @@ -167,44 +169,41 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t rd_error = 0; } + printf("rx count = 0x%08lX\n", self->rx_count); + size_t remain = len; + // uint64_t start_ticks = ticks_ms; +// // while ( remain && (ticks_ms - start_ticks < self->timeout_ms) ) { -// if ( self->rx_count ) { -// size_t cnt = MIN(self->rx_count, remain); +// // have enough or buffer is full +// if ( (self->rx_count >= remain) || (self->rx_count == self->bufsize) ) { +// if ( is_receiving(self) ) { +// nrfx_uart_rx_abort(&_uart); +// } +// +// const size_t cnt = MIN(self->rx_count, remain); +// // memcpy(data, self->buffer, cnt); // data += cnt; // remain -= cnt; // -// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf))); -// nrfx_uart_rx_enable(&_uart); -// } -//#if 0 -// uint32_t received = common_hal_busio_uart_rx_characters_available(self); +// self->rx_count -= cnt; // -// // enough bytes received or ringbuffer is full -// if ( (received >= remain) || (received == self->rx_rbuf.size - 1) ) { -// nrfx_uart_rx_abort(&_uart); -// -// while ( !_ringbuf_is_empty(&self->rx_rbuf) ) { -// *data++ = ringbuf_get(&self->rx_rbuf); -// remain--; +// // shift buffer if we didn't consume it all +// if ( self->rx_count ) { +// memmove(self->buffer, self->buffer + cnt, self->rx_count); // } -// -// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf))); -// nrfx_uart_rx_enable(&_uart); // } -//#endif +// +//// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf))); // //#ifdef MICROPY_VM_HOOK_LOOP // MICROPY_VM_HOOK_LOOP //#endif // } - printf("rx count = 0x%08lX\n", self->rx_count); - _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); - nrfx_uart_rx_enable(&_uart); return len - remain; #endif @@ -259,13 +258,7 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else -// int count = ((volatile uint16_t) self->rx_rbuf.iput) - ((volatile uint16_t) self->rx_rbuf.iget); -// if ( count < 0 ) { -// count += self->rx_rbuf.size; -// } -// -// return count; - return self->rx_count; +return self->rx_count + (nrfx_uart_rx_ready(&_uart) ? 1 : 0); #endif } From dddc437ea7fc98cb3c1e6e9e2bc5e16dfa690769 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 21 Sep 2018 03:48:13 +0700 Subject: [PATCH 06/25] got rx working finally --- ports/nrf/common-hal/busio/UART.c | 122 +++++++++++++++++------------- ports/nrf/common-hal/busio/UART.h | 1 + 2 files changed, 69 insertions(+), 54 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 79b49464d6..9cb7f8dc1a 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -36,7 +36,7 @@ #include "tick.h" #include "nrfx_uart.h" -#include +#include static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); @@ -51,14 +51,6 @@ static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); static uint32_t get_nrf_baud (uint32_t baudrate); -static inline bool is_receiving (busio_uart_obj_t *self) { - (void) self; - return nrf_uart_int_enable_check(_uart.p_reg, NRF_UART_INT_MASK_RXDRDY); -} - - -static uint32_t rd_error = 0; - static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) { busio_uart_obj_t* self = (busio_uart_obj_t*) context; @@ -69,16 +61,10 @@ static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) case NRFX_UART_EVT_RX_DONE: self->rx_count += event->data.rxtx.bytes; + self->receiving = false; break; default: - rd_error = event->data.error.error_mask; - - // Walkaround for first 2 error after nrfx_uart_rx_enable() - // queue RX if there is no data and no on-going rx -// if ( !self->rx_count && !is_receiving(self) ) { -// nrfx_uart_rx(&_uart, self->buffer, self->bufsize); -// } break; } } @@ -105,7 +91,7 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, nrfx_uart_config_t config = { .pseltxd = tx->number, - .pseltxd = rx->number, + .pselrxd = rx->number, .pselcts = NRF_UART_PSEL_DISCONNECTED, .pselrts = NRF_UART_PSEL_DISCONNECTED, .p_context = self, @@ -131,8 +117,7 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, nrfx_uart_rx_enable(&_uart); - // Somehow the first 2 calls of nrfx_uart_rx will (probably) cause Frame, then Break error - // effectively cancel the rx preps --> Walkaround: keep calling nrfx_uart_rx in error handler if needed + self->receiving = true; _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); #endif } @@ -157,6 +142,21 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { #endif } +static size_t get_rx_data (busio_uart_obj_t *self, uint8_t *data, size_t len) { + // up to max received + const size_t cnt = MIN(self->rx_count, len); + + memcpy(data, self->buffer, cnt); + self->rx_count -= cnt; + + // shift buffer if we didn't consume it all + if ( self->rx_count ) { + memmove(self->buffer, self->buffer + cnt, self->rx_count); + } + + return cnt; +} + // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { #ifndef NRF52840_XXAA @@ -164,46 +164,56 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t return 0; #else - if ( rd_error ) { - printf("error = 0x%08lX\n", rd_error); - rd_error = 0; + size_t remain = len; + uint64_t start_ticks = ticks_ms; + + // nrfx_uart doesn't provide API to check number of bytes received so far for the on going reception. + // we have to abort the current transfer to get rx_count updated !!! + if ( self->receiving ) { + nrfx_uart_rx_abort(&_uart); + while ( self->receiving ) { + } } - printf("rx count = 0x%08lX\n", self->rx_count); + size_t cnt = get_rx_data(self, data, remain); + data += cnt; + remain -= cnt; - size_t remain = len; + if ( self->timeout_ms ) { + do { + if ( remain == 0 ) { + break; + } -// uint64_t start_ticks = ticks_ms; -// -// while ( remain && (ticks_ms - start_ticks < self->timeout_ms) ) { -// // have enough or buffer is full -// if ( (self->rx_count >= remain) || (self->rx_count == self->bufsize) ) { -// if ( is_receiving(self) ) { -// nrfx_uart_rx_abort(&_uart); -// } -// -// const size_t cnt = MIN(self->rx_count, remain); -// -// memcpy(data, self->buffer, cnt); -// data += cnt; -// remain -= cnt; -// -// self->rx_count -= cnt; -// -// // shift buffer if we didn't consume it all -// if ( self->rx_count ) { -// memmove(self->buffer, self->buffer + cnt, self->rx_count); -// } -// } -// -//// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->rx_xact_buf, sizeof(self->rx_xact_buf))); -// -//#ifdef MICROPY_VM_HOOK_LOOP -// MICROPY_VM_HOOK_LOOP -//#endif -// } + // no data, no transfer, start with only 1 byte each so that we could know when data is available + if ( !self->rx_count && !self->receiving ) { + self->receiving = true; + _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, 1)); + } - _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); + if ( self->rx_count ) { + *data++ = self->buffer[0]; + remain--; + self->rx_count--; + } + +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif + + } while ( ticks_ms - start_ticks < self->timeout_ms ); + } + + // abort oon-going 1 byte transfer + if ( self->receiving ) { + nrfx_uart_rx_abort(&_uart); + while ( self->receiving ) { + } + } + + // queue full buffer transfer + self->receiving = true; + _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer + self->rx_count, self->bufsize - self->rx_count)); return len - remain; #endif @@ -226,6 +236,10 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif + // break if zero timeout + if ( self->timeout_ms == 0 ) { + break; + } } if ( self->xferred_bytes <= 0 ) { diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 8018a93164..5cd0bae418 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -41,6 +41,7 @@ typedef struct { uint8_t* buffer; uint32_t bufsize; volatile uint32_t rx_count; + volatile bool receiving; } busio_uart_obj_t; #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H From 816ff052534224967283aa657ba63b007c286cbe Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 21 Sep 2018 03:53:35 +0700 Subject: [PATCH 07/25] clean up --- ports/nrf/common-hal/busio/UART.c | 13 ++++--------- ports/nrf/common-hal/busio/UART.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 9cb7f8dc1a..ec3d55fef0 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -56,7 +56,7 @@ static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) switch ( event->type ) { case NRFX_UART_EVT_TX_DONE: - self->xferred_bytes = event->data.rxtx.bytes; + self->tx_count = event->data.rxtx.bytes; break; case NRFX_UART_EVT_RX_DONE: @@ -225,25 +225,20 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return 0; #else - self->xferred_bytes = 0; + self->tx_count = 0; (*errcode) = nrfx_uart_tx(&_uart, data, len); _VERIFY_ERR(*errcode); (*errcode) = 0; uint64_t start_ticks = ticks_ms; - while ( (0 == self->xferred_bytes) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( (0 == self->tx_count) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif - // break if zero timeout - if ( self->timeout_ms == 0 ) { - break; - } } - if ( self->xferred_bytes <= 0 ) { - mp_raise_msg_varg(&mp_type_AssertionError, translate("failed")); + if ( self->tx_count <= 0 ) { *errcode = MP_EAGAIN; return MP_STREAM_ERROR; } diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 5cd0bae418..3cb9e5fda7 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -36,7 +36,7 @@ typedef struct { mp_obj_base_t base; uint32_t baudrate; uint32_t timeout_ms; - volatile int32_t xferred_bytes; + volatile int32_t tx_count; uint8_t* buffer; uint32_t bufsize; From fdd3e91753a74dc779fbb001abaf6b2d0761ec42 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 24 Sep 2018 14:37:28 +0700 Subject: [PATCH 08/25] changing to nrf uarte, tx works fine --- ports/nrf/Makefile | 2 +- ports/nrf/common-hal/busio/UART.c | 48 +++++++++++++++---------------- ports/nrf/common-hal/busio/UART.h | 1 - ports/nrf/nrfx_config.h | 5 ++++ 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index d48b20fd38..93ca783760 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -91,7 +91,7 @@ SRC_NRFX = $(addprefix nrfx/,\ drivers/src/nrfx_power.c \ drivers/src/nrfx_spim.c \ drivers/src/nrfx_twim.c \ - drivers/src/nrfx_uart.c \ + drivers/src/nrfx_uarte.c \ ) SRC_C += \ diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 260b958ea7..b9b182247a 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -35,10 +35,10 @@ #include "supervisor/shared/translate.h" #include "tick.h" -#include "nrfx_uart.h" +#include "nrfx_uarte.h" #include -static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); +static nrfx_uarte_t _uart = NRFX_UARTE_INSTANCE(0); // expression to examine, and return value in case of failing #define _VERIFY_ERR(_exp) \ @@ -51,12 +51,11 @@ static nrfx_uart_t _uart = NRFX_UART_INSTANCE(0); static uint32_t get_nrf_baud (uint32_t baudrate); -static void uart_callback_irq (const nrfx_uart_event_t * event, void * context) { +static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) { busio_uart_obj_t* self = (busio_uart_obj_t*) context; switch ( event->type ) { case NRFX_UART_EVT_TX_DONE: - self->tx_count = event->data.rxtx.bytes; break; case NRFX_UART_EVT_RX_DONE: @@ -89,7 +88,7 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, mp_raise_ValueError(translate("busio.UART odd parity is not supported")); } - nrfx_uart_config_t config = { + nrfx_uarte_config_t config = { .pseltxd = tx->number, .pselrxd = rx->number, .pselcts = NRF_UART_PSEL_DISCONNECTED, @@ -101,13 +100,13 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, .interrupt_priority = 7 }; - nrfx_uart_uninit(&_uart); - _VERIFY_ERR(nrfx_uart_init(&_uart, &config, uart_callback_irq)); + nrfx_uarte_uninit(&_uart); + _VERIFY_ERR(nrfx_uarte_init(&_uart, &config, uart_callback_irq)); // Init buffer for rx self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); if ( !self->buffer ) { - nrfx_uart_uninit(&_uart); + nrfx_uarte_uninit(&_uart); mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); } self->bufsize = receiver_buffer_size; @@ -115,10 +114,10 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, self->baudrate = baudrate; self->timeout_ms = timeout; - nrfx_uart_rx_enable(&_uart); - - self->receiving = true; - _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); +// nrfx_uart_rx_enable(&_uart); +// +// self->receiving = true; +// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); #endif } @@ -136,8 +135,8 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else if ( !common_hal_busio_uart_deinited(self) ) { - nrfx_uart_uninit(&_uart); -// gc_free(self->buffer); + nrfx_uarte_uninit(&_uart); + gc_free(self->buffer); } #endif } @@ -165,6 +164,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t #else size_t remain = len; +#if 0 uint64_t start_ticks = ticks_ms; // nrfx_uart doesn't provide API to check number of bytes received so far for the on going reception. @@ -214,8 +214,9 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // queue full buffer transfer self->receiving = true; _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer + self->rx_count, self->bufsize - self->rx_count)); - +#endif return len - remain; + #endif } @@ -225,24 +226,19 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return 0; #else - self->tx_count = 0; + if ( len == 0 ) return 0; - (*errcode) = nrfx_uart_tx(&_uart, data, len); + (*errcode) = nrfx_uarte_tx(&_uart, data, len); _VERIFY_ERR(*errcode); (*errcode) = 0; uint64_t start_ticks = ticks_ms; - while ( (0 == self->tx_count) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( nrfx_uarte_tx_in_progress(&_uart) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif } - if ( self->tx_count <= 0 ) { - *errcode = MP_EAGAIN; - return MP_STREAM_ERROR; - } - return len; #endif } @@ -267,7 +263,8 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else -return self->rx_count + (nrfx_uart_rx_ready(&_uart) ? 1 : 0); +//return self->rx_count + (nrfx_uart_rx_ready(&_uart) ? 1 : 0); + return false; #endif } @@ -280,7 +277,8 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return false; #else - return !nrfx_uart_tx_in_progress(&_uart); +// return !nrfx_uart_tx_in_progress(&_uart); + return true; #endif } diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 3cb9e5fda7..7c693bf6c5 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -36,7 +36,6 @@ typedef struct { mp_obj_base_t base; uint32_t baudrate; uint32_t timeout_ms; - volatile int32_t tx_count; uint8_t* buffer; uint32_t bufsize; diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index cc4d193277..0ccfecb21d 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -45,8 +45,13 @@ #define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 // UART +#if 0 #define NRFX_UART_ENABLED 1 #define NRFX_UART0_ENABLED 1 +#else +#define NRFX_UARTE_ENABLED 1 +#define NRFX_UARTE0_ENABLED 1 +#endif #define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 #define NRFX_UART_DEFAULT_CONFIG_HWFC NRF_UART_HWFC_DISABLED From 7bbd449f067ea4604059d1a8c12e8a8333a528bf Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 24 Sep 2018 15:54:32 +0700 Subject: [PATCH 09/25] uarte rx work fine --- ports/nrf/common-hal/busio/UART.c | 97 +++++++++---------------------- ports/nrf/common-hal/busio/UART.h | 3 +- 2 files changed, 28 insertions(+), 72 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index b9b182247a..6f4e0af8e7 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -59,8 +59,7 @@ static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) break; case NRFX_UART_EVT_RX_DONE: - self->rx_count += event->data.rxtx.bytes; - self->receiving = false; + self->rx_count = event->data.rxtx.bytes; break; default: @@ -113,11 +112,6 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, self->baudrate = baudrate; self->timeout_ms = timeout; - -// nrfx_uart_rx_enable(&_uart); -// -// self->receiving = true; -// _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, self->bufsize)); #endif } @@ -125,8 +119,8 @@ bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - return (nrf_uart_rx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED) || - (nrf_uart_tx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED); + return (nrf_uarte_rx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED) || + (nrf_uarte_tx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED); #endif } @@ -141,21 +135,6 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { #endif } -static size_t get_rx_data (busio_uart_obj_t *self, uint8_t *data, size_t len) { - // up to max received - const size_t cnt = MIN(self->rx_count, len); - - memcpy(data, self->buffer, cnt); - self->rx_count -= cnt; - - // shift buffer if we didn't consume it all - if ( self->rx_count ) { - memmove(self->buffer, self->buffer + cnt, self->rx_count); - } - - return cnt; -} - // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { #ifndef NRF52840_XXAA @@ -164,59 +143,35 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t #else size_t remain = len; -#if 0 uint64_t start_ticks = ticks_ms; - // nrfx_uart doesn't provide API to check number of bytes received so far for the on going reception. - // we have to abort the current transfer to get rx_count updated !!! - if ( self->receiving ) { - nrfx_uart_rx_abort(&_uart); - while ( self->receiving ) { - } - } + while ( remain && (ticks_ms - start_ticks < self->timeout_ms) ) { + const size_t cnt = MIN(self->bufsize, len); - size_t cnt = get_rx_data(self, data, remain); - data += cnt; - remain -= cnt; - - if ( self->timeout_ms ) { - do { - if ( remain == 0 ) { - break; - } - - // no data, no transfer, start with only 1 byte each so that we could know when data is available - if ( !self->rx_count && !self->receiving ) { - self->receiving = true; - _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer, 1)); - } - - if ( self->rx_count ) { - *data++ = self->buffer[0]; - remain--; - self->rx_count--; - } + self->rx_count = -1; + _VERIFY_ERR(nrfx_uarte_rx(&_uart, self->buffer, cnt)); + while ( (self->rx_count == -1) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif + } - } while ( ticks_ms - start_ticks < self->timeout_ms ); - } + // Time up, abort rx use received so far + if ( self->rx_count == -1 ) { + nrfx_uarte_rx_abort(&_uart); + while ( self->rx_count == -1 ) { + } + } - // abort oon-going 1 byte transfer - if ( self->receiving ) { - nrfx_uart_rx_abort(&_uart); - while ( self->receiving ) { + if ( self->rx_count > 0 ) { + memcpy(data, self->buffer, self->rx_count); + data += self->rx_count; + remain -= self->rx_count; } } - - // queue full buffer transfer - self->receiving = true; - _VERIFY_ERR(nrfx_uart_rx(&_uart, self->buffer + self->rx_count, self->bufsize - self->rx_count)); -#endif + return len - remain; - #endif } @@ -228,6 +183,10 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, #else if ( len == 0 ) return 0; + if ( !nrfx_uarte_tx_in_progress(&_uart) ) { + nrfx_uarte_tx_abort(&_uart); + } + (*errcode) = nrfx_uarte_tx(&_uart, data, len); _VERIFY_ERR(*errcode); (*errcode) = 0; @@ -255,7 +214,7 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else self->baudrate = baudrate; - nrf_uart_baudrate_set(_uart.p_reg, get_nrf_baud(baudrate)); + nrf_uarte_baudrate_set(_uart.p_reg, get_nrf_baud(baudrate)); #endif } @@ -263,8 +222,7 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else -//return self->rx_count + (nrfx_uart_rx_ready(&_uart) ? 1 : 0); - return false; + return 1; // nrf_uart_event_check(_uart.p_reg, NRF_UART_EVENT_RXDRDY) ? 1 : 0; #endif } @@ -277,8 +235,7 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return false; #else -// return !nrfx_uart_tx_in_progress(&_uart); - return true; + return !nrfx_uarte_tx_in_progress(&_uart); #endif } diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 7c693bf6c5..9a8035c26b 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -39,8 +39,7 @@ typedef struct { uint8_t* buffer; uint32_t bufsize; - volatile uint32_t rx_count; - volatile bool receiving; + volatile int32_t rx_count; } busio_uart_obj_t; #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H From 4015023e01f233fa62f6bcd329a2cd50f8b99411 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 24 Sep 2018 16:06:44 +0700 Subject: [PATCH 10/25] clean up uart io --- ports/nrf/common-hal/busio/UART.c | 72 +++++++++++++++++++------------ ports/nrf/common-hal/busio/UART.h | 4 ++ 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 6f4e0af8e7..7e6fddf2f8 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -38,8 +38,6 @@ #include "nrfx_uarte.h" #include -static nrfx_uarte_t _uart = NRFX_UARTE_INSTANCE(0); - // expression to examine, and return value in case of failing #define _VERIFY_ERR(_exp) \ do {\ @@ -75,8 +73,8 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - if ( (tx == mp_const_none) || (rx == mp_const_none) ) { - mp_raise_ValueError(translate("Invalid pins")); + if ( (tx == mp_const_none) && (rx == mp_const_none) ) { + mp_raise_ValueError(translate("tx and rx cannot both be None")); } if ( receiver_buffer_size == 0 ) { @@ -88,8 +86,8 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, } nrfx_uarte_config_t config = { - .pseltxd = tx->number, - .pselrxd = rx->number, + .pseltxd = (tx == mp_const_none) ? NRF_UART_PSEL_DISCONNECTED : tx->number, + .pselrxd = (rx == mp_const_none) ? NRF_UART_PSEL_DISCONNECTED : rx->number, .pselcts = NRF_UART_PSEL_DISCONNECTED, .pselrts = NRF_UART_PSEL_DISCONNECTED, .p_context = self, @@ -99,16 +97,26 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, .interrupt_priority = 7 }; - nrfx_uarte_uninit(&_uart); - _VERIFY_ERR(nrfx_uarte_init(&_uart, &config, uart_callback_irq)); + // support only 1 instance for now + self->uarte = (nrfx_uarte_t ) NRFX_UARTE_INSTANCE(0); + nrfx_uarte_uninit(&self->uarte); + _VERIFY_ERR(nrfx_uarte_init(&self->uarte, &config, uart_callback_irq)); // Init buffer for rx - self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); - if ( !self->buffer ) { - nrfx_uarte_uninit(&_uart); - mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); + if ( rx != mp_const_none ) { + self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); + if ( !self->buffer ) { + nrfx_uarte_uninit(&self->uarte); + mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); + } + self->bufsize = receiver_buffer_size; + + claim_pin(rx); + } + + if ( tx != mp_const_none ) { + claim_pin(tx); } - self->bufsize = receiver_buffer_size; self->baudrate = baudrate; self->timeout_ms = timeout; @@ -119,8 +127,8 @@ bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - return (nrf_uarte_rx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED) || - (nrf_uarte_tx_pin_get(_uart.p_reg) == NRF_UART_PSEL_DISCONNECTED); + return (nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED) && + (nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED); #endif } @@ -129,7 +137,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else if ( !common_hal_busio_uart_deinited(self) ) { - nrfx_uarte_uninit(&_uart); + nrfx_uarte_uninit(&self->uarte); gc_free(self->buffer); } #endif @@ -142,6 +150,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t return 0; #else + if ( nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED ) { + mp_raise_ValueError(translate("No RX pin")); + } + size_t remain = len; uint64_t start_ticks = ticks_ms; @@ -149,7 +161,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t const size_t cnt = MIN(self->bufsize, len); self->rx_count = -1; - _VERIFY_ERR(nrfx_uarte_rx(&_uart, self->buffer, cnt)); + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, cnt)); while ( (self->rx_count == -1) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP @@ -159,7 +171,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Time up, abort rx use received so far if ( self->rx_count == -1 ) { - nrfx_uarte_rx_abort(&_uart); + nrfx_uarte_rx_abort(&self->uarte); while ( self->rx_count == -1 ) { } } @@ -181,18 +193,22 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return 0; #else - if ( len == 0 ) return 0; - - if ( !nrfx_uarte_tx_in_progress(&_uart) ) { - nrfx_uarte_tx_abort(&_uart); + if ( nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED ) { + mp_raise_ValueError(translate("No TX pin")); } - (*errcode) = nrfx_uarte_tx(&_uart, data, len); + if ( len == 0 ) return 0; + + if ( !nrfx_uarte_tx_in_progress(&self->uarte) ) { + nrfx_uarte_tx_abort(&self->uarte); + } + + (*errcode) = nrfx_uarte_tx(&self->uarte, data, len); _VERIFY_ERR(*errcode); (*errcode) = 0; uint64_t start_ticks = ticks_ms; - while ( nrfx_uarte_tx_in_progress(&_uart) && (ticks_ms - start_ticks < self->timeout_ms) ) { + while ( nrfx_uarte_tx_in_progress(&self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif @@ -214,7 +230,7 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else self->baudrate = baudrate; - nrf_uarte_baudrate_set(_uart.p_reg, get_nrf_baud(baudrate)); + nrf_uarte_baudrate_set(self->uarte.p_reg, get_nrf_baud(baudrate)); #endif } @@ -222,12 +238,12 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - return 1; // nrf_uart_event_check(_uart.p_reg, NRF_UART_EVENT_RXDRDY) ? 1 : 0; + return 1; // nrf_uart_event_check(self->uarte.p_reg, NRF_UART_EVENT_RXDRDY) ? 1 : 0; #endif } void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + } bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { @@ -235,7 +251,7 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); return false; #else - return !nrfx_uarte_tx_in_progress(&_uart); + return !nrfx_uarte_tx_in_progress(&self->uarte); #endif } diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 9a8035c26b..aef377f146 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -28,12 +28,16 @@ #define MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H #include "common-hal/microcontroller/Pin.h" +#include "nrfx_uarte.h" #include "py/obj.h" #include "py/ringbuf.h" typedef struct { mp_obj_base_t base; + + nrfx_uarte_t uarte; + uint32_t baudrate; uint32_t timeout_ms; From 1782ceab356d3c02f7d4a4319a6552654933da15 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 24 Sep 2018 16:18:49 +0700 Subject: [PATCH 11/25] uarte malloc if buffer is not in SRAM --- ports/nrf/common-hal/busio/UART.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 7e6fddf2f8..5bb51bb74c 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -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); } - (*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); (*errcode) = 0; @@ -214,6 +221,10 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, #endif } + if ( !nrfx_is_in_ram(data) ) { + gc_free(tx_buf); + } + return len; #endif } From 01c129619734103cf742a5b66865a9900cbc43ae Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 12:37:31 +0700 Subject: [PATCH 12/25] nrf52 uart io rx work reliably --- ports/nrf/common-hal/busio/UART.c | 66 +++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 5bb51bb74c..48951fe1bb 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -37,6 +37,7 @@ #include "tick.h" #include "nrfx_uarte.h" #include +#include // expression to examine, and return value in case of failing #define _VERIFY_ERR(_exp) \ @@ -47,17 +48,38 @@ }\ }while(0) +#define UARTE_DEBUG 0 + +#if UARTE_DEBUG +#define PRINT_INT(x) printf("%s: %d: " #x " = %ld\n" , __FUNCTION__, __LINE__, (uint32_t) (x) ) +#else +#define PRINT_INT(x) +#endif + static uint32_t get_nrf_baud (uint32_t baudrate); +static uint32_t _err = 0; +static uint32_t _err_count = 0; + + static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) { busio_uart_obj_t* self = (busio_uart_obj_t*) context; switch ( event->type ) { + case NRFX_UART_EVT_RX_DONE: + self->rx_count = event->data.rxtx.bytes; + break; + case NRFX_UART_EVT_TX_DONE: break; - case NRFX_UART_EVT_RX_DONE: - self->rx_count = event->data.rxtx.bytes; + case NRFX_UART_EVT_ERROR: + // Abort too fast will cause error occasionally + if ( self->rx_count == -1 ) { + self->rx_count = 0; // event->data.error.rxtx.bytes; + } + _err_count = event->data.error.rxtx.bytes; + _err = event->data.error.error_mask; break; default: @@ -120,6 +142,10 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, self->baudrate = baudrate; self->timeout_ms = timeout; + + // queue 1-byte transfer for rx_characters_available() + self->rx_count = -1; + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); #endif } @@ -157,32 +183,40 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t size_t remain = len; uint64_t start_ticks = ticks_ms; - while ( remain && (ticks_ms - start_ticks < self->timeout_ms) ) { - const size_t cnt = MIN(self->bufsize, len); - - self->rx_count = -1; - _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, cnt)); - + while ( 1 ) { + // Wait for on-going reception to complete while ( (self->rx_count == -1) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif } - // Time up, abort rx use received so far - if ( self->rx_count == -1 ) { - nrfx_uarte_rx_abort(&self->uarte); - while ( self->rx_count == -1 ) { - } - } - + // copy received data if ( self->rx_count > 0 ) { memcpy(data, self->buffer, self->rx_count); data += self->rx_count; remain -= self->rx_count; + + self->rx_count = 0; } + + // exit if complete or time up + if ( !remain || !(ticks_ms - start_ticks < self->timeout_ms) ) { + break; + } + + // prepare next receiving + const size_t cnt = MIN(self->bufsize, remain); + self->rx_count = -1; + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, cnt)); } + // queue 1-byte transfer for rx_characters_available() + if ( self->rx_count == 0 ) { + self->rx_count = -1; + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); + } + return len - remain; #endif } @@ -249,7 +283,7 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - return 1; // nrf_uart_event_check(self->uarte.p_reg, NRF_UART_EVENT_RXDRDY) ? 1 : 0; + return (self->rx_count > 0) ? 1 : 0; #endif } From d7144799249c12e66c1b00e6c0857fc8cfe11345 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 12:48:48 +0700 Subject: [PATCH 13/25] clean up --- ports/nrf/common-hal/busio/UART.c | 37 +++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 48951fe1bb..737e5007ed 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -48,20 +48,8 @@ }\ }while(0) -#define UARTE_DEBUG 0 - -#if UARTE_DEBUG -#define PRINT_INT(x) printf("%s: %d: " #x " = %ld\n" , __FUNCTION__, __LINE__, (uint32_t) (x) ) -#else -#define PRINT_INT(x) -#endif - static uint32_t get_nrf_baud (uint32_t baudrate); -static uint32_t _err = 0; -static uint32_t _err_count = 0; - - static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) { busio_uart_obj_t* self = (busio_uart_obj_t*) context; @@ -74,12 +62,9 @@ static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) break; case NRFX_UART_EVT_ERROR: - // Abort too fast will cause error occasionally if ( self->rx_count == -1 ) { - self->rx_count = 0; // event->data.error.rxtx.bytes; + self->rx_count = 0; } - _err_count = event->data.error.rxtx.bytes; - _err = event->data.error.error_mask; break; default: @@ -184,7 +169,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t uint64_t start_ticks = ticks_ms; while ( 1 ) { - // Wait for on-going reception to complete + // Wait for on-going transfer to complete while ( (self->rx_count == -1) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP @@ -233,8 +218,19 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, if ( len == 0 ) return 0; - if ( !nrfx_uarte_tx_in_progress(&self->uarte) ) { - nrfx_uarte_tx_abort(&self->uarte); + uint64_t start_ticks = ticks_ms; + + // Wait for on-going transfer to complete + while ( nrfx_uarte_tx_in_progress(&self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { +#ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP +#endif + } + + // Time up + if ( !(ticks_ms - start_ticks < self->timeout_ms) ) { + *errcode = MP_EAGAIN; + return MP_STREAM_ERROR; } // EasyDMA can only access SRAM @@ -248,7 +244,6 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, _VERIFY_ERR(*errcode); (*errcode) = 0; - uint64_t start_ticks = ticks_ms; while ( nrfx_uarte_tx_in_progress(&self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP @@ -283,7 +278,7 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { #ifndef NRF52840_XXAA mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); #else - return (self->rx_count > 0) ? 1 : 0; + return (self->rx_count > 0) ? self->rx_count : 0; #endif } From d3e5ba83eb031770e063fd5934b990767f1da692 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 13:00:57 +0700 Subject: [PATCH 14/25] update nrfx to 1.3.0 --- lib/tinyusb | 2 +- ports/nrf/common-hal/busio/UART.c | 1 - ports/nrf/nrfx | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/tinyusb b/lib/tinyusb index 583326e535..a660fb0cfc 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 583326e535454f16b06ebdb9cc06869602a5564c +Subproject commit a660fb0cfc8641d5645d1cdea76027266b278388 diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 737e5007ed..0b5bb915cd 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -37,7 +37,6 @@ #include "tick.h" #include "nrfx_uarte.h" #include -#include // expression to examine, and return value in case of failing #define _VERIFY_ERR(_exp) \ diff --git a/ports/nrf/nrfx b/ports/nrf/nrfx index 293f553ed9..67710e47c7 160000 --- a/ports/nrf/nrfx +++ b/ports/nrf/nrfx @@ -1 +1 @@ -Subproject commit 293f553ed9551c1fdfd05eac48e75bbdeb4e7290 +Subproject commit 67710e47c7313cc56a15748e485079831ee6a3af From 9017c9d29af17767e1a846339556e89de0f7c1b7 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 14:29:45 +0700 Subject: [PATCH 15/25] clean up --- ports/nrf/common-hal/busio/UART.c | 96 +++++++++++++++++++------------ 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 0b5bb915cd..3269e21839 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -38,6 +38,8 @@ #include "nrfx_uarte.h" #include +#ifdef NRF52840_XXAA + // expression to examine, and return value in case of failing #define _VERIFY_ERR(_exp) \ do {\ @@ -53,14 +55,14 @@ static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) busio_uart_obj_t* self = (busio_uart_obj_t*) context; switch ( event->type ) { - case NRFX_UART_EVT_RX_DONE: + case NRFX_UARTE_EVT_RX_DONE: self->rx_count = event->data.rxtx.bytes; break; - case NRFX_UART_EVT_TX_DONE: + case NRFX_UARTE_EVT_TX_DONE: break; - case NRFX_UART_EVT_ERROR: + case NRFX_UARTE_EVT_ERROR: if ( self->rx_count == -1 ) { self->rx_count = 0; } @@ -76,9 +78,6 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout, uint8_t receiver_buffer_size) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); -#else if ( (tx == mp_const_none) && (rx == mp_const_none) ) { mp_raise_ValueError(translate("tx and rx cannot both be None")); } @@ -130,36 +129,22 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, // queue 1-byte transfer for rx_characters_available() self->rx_count = -1; _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); -#endif } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); -#else return (nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED) && (nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED); -#endif } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); -#else if ( !common_hal_busio_uart_deinited(self) ) { nrfx_uarte_uninit(&self->uarte); gc_free(self->buffer); } -#endif } // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); - return 0; -#else - if ( nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED ) { mp_raise_ValueError(translate("No RX pin")); } @@ -202,15 +187,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t } return len - remain; -#endif } // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); - return 0; -#else if ( nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED ) { mp_raise_ValueError(translate("No TX pin")); } @@ -254,13 +234,9 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, } return len; -#endif } uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); -#endif return self->baudrate; } @@ -274,11 +250,7 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat } uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); -#else return (self->rx_count > 0) ? self->rx_count : 0; -#endif } void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { @@ -286,12 +258,7 @@ void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { } bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); - return false; -#else return !nrfx_uarte_tx_in_progress(&self->uarte); -#endif } static uint32_t get_nrf_baud (uint32_t baudrate) @@ -345,3 +312,56 @@ static uint32_t get_nrf_baud (uint32_t baudrate) return NRF_UART_BAUDRATE_1000000; } } + +#else + +void common_hal_busio_uart_construct (busio_uart_obj_t *self, + const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, + uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout, + uint8_t receiver_buffer_size) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +} + +bool common_hal_busio_uart_deinited (busio_uart_obj_t *self) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + return true; +} + +void common_hal_busio_uart_deinit (busio_uart_obj_t *self) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +} + +// Read characters. +size_t common_hal_busio_uart_read (busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + return 0; +} + +// Write characters. +size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + return 0; +} + +uint32_t common_hal_busio_uart_get_baudrate (busio_uart_obj_t *self) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + return self->baudrate; +} + +void common_hal_busio_uart_set_baudrate (busio_uart_obj_t *self, uint32_t baudrate) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +} + +uint32_t common_hal_busio_uart_rx_characters_available (busio_uart_obj_t *self) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); +} + +void common_hal_busio_uart_clear_rx_buffer (busio_uart_obj_t *self) { + +} + +bool common_hal_busio_uart_ready_to_tx (busio_uart_obj_t *self) { + mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + return false; +} +#endif From 2f0e0bdcaf18db1766c54b8ab875447f97783079 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 16:14:44 +0700 Subject: [PATCH 16/25] migrate serial from uart to uarte --- .../boards/feather_nrf52832/mpconfigboard.h | 1 - ports/nrf/common-hal/busio/UART.c | 20 ++++----- ports/nrf/mphalport.c | 34 ++++++++------- ports/nrf/mphalport.h | 15 +++---- ports/nrf/nrfx_config.h | 10 ----- ports/nrf/supervisor/serial.c | 41 +++++++++++-------- 6 files changed, 57 insertions(+), 64 deletions(-) diff --git a/ports/nrf/boards/feather_nrf52832/mpconfigboard.h b/ports/nrf/boards/feather_nrf52832/mpconfigboard.h index 0da1abfc47..e751ec182e 100644 --- a/ports/nrf/boards/feather_nrf52832/mpconfigboard.h +++ b/ports/nrf/boards/feather_nrf52832/mpconfigboard.h @@ -30,7 +30,6 @@ #define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8) #define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6) -#define MICROPY_HW_UART_HWFC (0) #define PORT_HEAP_SIZE (32 * 1024) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 3269e21839..ab71cad78e 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -91,13 +91,13 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, } nrfx_uarte_config_t config = { - .pseltxd = (tx == mp_const_none) ? NRF_UART_PSEL_DISCONNECTED : tx->number, - .pselrxd = (rx == mp_const_none) ? NRF_UART_PSEL_DISCONNECTED : rx->number, - .pselcts = NRF_UART_PSEL_DISCONNECTED, - .pselrts = NRF_UART_PSEL_DISCONNECTED, + .pseltxd = (tx == mp_const_none) ? NRF_UARTE_PSEL_DISCONNECTED : tx->number, + .pselrxd = (rx == mp_const_none) ? NRF_UARTE_PSEL_DISCONNECTED : rx->number, + .pselcts = NRF_UARTE_PSEL_DISCONNECTED, + .pselrts = NRF_UARTE_PSEL_DISCONNECTED, .p_context = self, - .hwfc = NRF_UART_HWFC_DISABLED, - .parity = (parity == PARITY_NONE) ? NRF_UART_PARITY_EXCLUDED : NRF_UART_PARITY_INCLUDED, + .hwfc = NRF_UARTE_HWFC_DISABLED, + .parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED, .baudrate = get_nrf_baud(baudrate), .interrupt_priority = 7 }; @@ -132,8 +132,8 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { - return (nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED) && - (nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED); + return (nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED) && + (nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED); } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { @@ -145,7 +145,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { - if ( nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED ) { + if ( nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED ) { mp_raise_ValueError(translate("No RX pin")); } @@ -191,7 +191,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { - if ( nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UART_PSEL_DISCONNECTED ) { + if ( nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED ) { mp_raise_ValueError(translate("No TX pin")); } diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c index 163ac8d60b..27ed57bf38 100644 --- a/ports/nrf/mphalport.c +++ b/ports/nrf/mphalport.c @@ -27,36 +27,40 @@ #include -#include "mphalport.h" +#include "py/mphal.h" #include "py/mpstate.h" - +#include "py/gc.h" #if (MICROPY_PY_BLE_NUS == 0) #if !defined( NRF52840_XXAA) int mp_hal_stdin_rx_chr(void) { - uint8_t data = 0; - - while (!nrfx_uart_rx_ready(&serial_instance)); - - const nrfx_err_t err = nrfx_uart_rx(&serial_instance, &data, sizeof(data)); - if (err == NRFX_SUCCESS) - NRFX_ASSERT(err); - + uint8_t data; + nrfx_uarte_rx(&serial_instance, &data, 1); return data; } bool mp_hal_stdin_any(void) { - return nrfx_uart_rx_ready(&serial_instance); + return nrf_uarte_event_check(serial_instance.p_reg, NRF_UARTE_EVENT_RXDRDY); } void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { - if (len == 0) + if (len == 0) { return; + } - const nrfx_err_t err = nrfx_uart_tx(&serial_instance, (uint8_t*)str, len); - if (err == NRFX_SUCCESS) - NRFX_ASSERT(err); + // EasyDMA can only access SRAM + uint8_t * tx_buf = (uint8_t*) str; + if ( !nrfx_is_in_ram(str) ) { + tx_buf = (uint8_t *) gc_alloc(len, false, false); + memcpy(tx_buf, str, len); + } + + nrfx_uarte_tx(&serial_instance, tx_buf, len); + + if ( !nrfx_is_in_ram(str) ) { + gc_free(tx_buf); + } } #else diff --git a/ports/nrf/mphalport.h b/ports/nrf/mphalport.h index f283cf38da..a1929a4ace 100644 --- a/ports/nrf/mphalport.h +++ b/ports/nrf/mphalport.h @@ -31,21 +31,16 @@ #include #include "lib/utils/interrupt_char.h" -#include "nrfx_uart.h" +#include "nrfx_uarte.h" #include "py/mpconfig.h" -extern nrfx_uart_t serial_instance; +extern nrfx_uarte_t serial_instance; extern volatile uint64_t ticks_ms; -static inline mp_uint_t mp_hal_ticks_ms(void) { - return ticks_ms; -} - -int mp_hal_stdin_rx_chr(void); -void mp_hal_stdout_tx_str(const char *str); -bool mp_hal_stdin_any(void); -void mp_hal_delay_ms(mp_uint_t ms); +#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms) #define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us)) +bool mp_hal_stdin_any(void); + #endif diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index 0ccfecb21d..f217cb0534 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -45,18 +45,8 @@ #define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 // UART -#if 0 -#define NRFX_UART_ENABLED 1 -#define NRFX_UART0_ENABLED 1 -#else #define NRFX_UARTE_ENABLED 1 #define NRFX_UARTE0_ENABLED 1 -#endif - -#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 -#define NRFX_UART_DEFAULT_CONFIG_HWFC NRF_UART_HWFC_DISABLED -#define NRFX_UART_DEFAULT_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED -#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE NRF_UART_BAUDRATE_115200 // PWM #define NRFX_PWM0_ENABLED 1 diff --git a/ports/nrf/supervisor/serial.c b/ports/nrf/supervisor/serial.c index 18a45f10b9..cfbcc4b31b 100644 --- a/ports/nrf/supervisor/serial.c +++ b/ports/nrf/supervisor/serial.c @@ -24,19 +24,19 @@ * THE SOFTWARE. */ -#include "mphalport.h" +#include "py/mphal.h" #if MICROPY_PY_BLE_NUS #include "ble_uart.h" #else #include "nrf_gpio.h" +#include "nrfx_uarte.h" #endif -#if !defined( NRF52840_XXAA) +#if !defined(NRF52840_XXAA) -#define INST_NO 0 - -nrfx_uart_t serial_instance = NRFX_UART_INSTANCE(INST_NO); +uint8_t serial_received_char; +nrfx_uarte_t serial_instance = NRFX_UARTE_INSTANCE(0); void serial_init(void) { #if MICROPY_PY_BLE_NUS @@ -45,22 +45,27 @@ void serial_init(void) { ; } #else - nrfx_uart_config_t config = NRFX_UART_DEFAULT_CONFIG; - config.pseltxd = MICROPY_HW_UART_TX; - config.pselrxd = MICROPY_HW_UART_RX; - config.hwfc = MICROPY_HW_UART_HWFC ? NRF_UART_HWFC_ENABLED : NRF_UART_HWFC_DISABLED; -#ifdef MICROPY_HW_UART_CTS - config.pselcts = MICROPY_HW_UART_CTS; -#endif -#ifdef MICROPY_HW_UART_RTS - config.pselrts = MICROPY_HW_UART_RTS; -#endif + nrfx_uarte_config_t config = { + .pseltxd = MICROPY_HW_UART_TX, + .pselrxd = MICROPY_HW_UART_RX, + .pselcts = NRF_UARTE_PSEL_DISCONNECTED, + .pselrts = NRF_UARTE_PSEL_DISCONNECTED, + .p_context = NULL, + .hwfc = NRF_UARTE_HWFC_DISABLED, + .parity = NRF_UARTE_PARITY_EXCLUDED, + .baudrate = NRF_UARTE_BAUDRATE_115200, + .interrupt_priority = 7 + }; - const nrfx_err_t err = nrfx_uart_init(&serial_instance, &config, NULL); - if (err == NRFX_SUCCESS) + nrfx_uarte_uninit(&serial_instance); + const nrfx_err_t err = nrfx_uarte_init(&serial_instance, &config, NULL); // no callback for blocking mode + + if (err != NRFX_SUCCESS) { NRFX_ASSERT(err); + } - nrfx_uart_rx_enable(&serial_instance); + // enabled receiving + nrf_uarte_task_trigger(serial_instance.p_reg, NRF_UARTE_TASK_STARTRX); #endif } From dec5c50c45ab0e8212a80e27cabb389f2792d55a Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 16:22:14 +0700 Subject: [PATCH 17/25] clean up --- ports/nrf/common-hal/busio/UART.c | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index ab71cad78e..28fcdc1508 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -264,52 +264,52 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { static uint32_t get_nrf_baud (uint32_t baudrate) { if ( baudrate <= 1200 ) { - return NRF_UART_BAUDRATE_1200; + return NRF_UARTE_BAUDRATE_1200; } else if ( baudrate <= 2400 ) { - return NRF_UART_BAUDRATE_2400; + return NRF_UARTE_BAUDRATE_2400; } else if ( baudrate <= 4800 ) { - return NRF_UART_BAUDRATE_4800; + return NRF_UARTE_BAUDRATE_4800; } else if ( baudrate <= 9600 ) { - return NRF_UART_BAUDRATE_9600; + return NRF_UARTE_BAUDRATE_9600; } else if ( baudrate <= 14400 ) { - return NRF_UART_BAUDRATE_14400; + return NRF_UARTE_BAUDRATE_14400; } else if ( baudrate <= 19200 ) { - return NRF_UART_BAUDRATE_19200; + return NRF_UARTE_BAUDRATE_19200; } else if ( baudrate <= 28800 ) { - return NRF_UART_BAUDRATE_28800; + return NRF_UARTE_BAUDRATE_28800; } else if ( baudrate <= 38400 ) { - return NRF_UART_BAUDRATE_38400; + return NRF_UARTE_BAUDRATE_38400; } else if ( baudrate <= 57600 ) { - return NRF_UART_BAUDRATE_57600; + return NRF_UARTE_BAUDRATE_57600; } else if ( baudrate <= 76800 ) { - return NRF_UART_BAUDRATE_76800; + return NRF_UARTE_BAUDRATE_76800; } else if ( baudrate <= 115200 ) { - return NRF_UART_BAUDRATE_115200; + return NRF_UARTE_BAUDRATE_115200; } else if ( baudrate <= 230400 ) { - return NRF_UART_BAUDRATE_230400; + return NRF_UARTE_BAUDRATE_230400; } else if ( baudrate <= 250000 ) { - return NRF_UART_BAUDRATE_250000; + return NRF_UARTE_BAUDRATE_250000; } else if ( baudrate <= 460800 ) { - return NRF_UART_BAUDRATE_460800; + return NRF_UARTE_BAUDRATE_460800; } else if ( baudrate <= 921600 ) { - return NRF_UART_BAUDRATE_921600; + return NRF_UARTE_BAUDRATE_921600; } else { - return NRF_UART_BAUDRATE_1000000; + return NRF_UARTE_BAUDRATE_1000000; } } From f724647a45eb8fa8cd2691a2a9a73e8e5dec409d Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 17:09:54 +0700 Subject: [PATCH 18/25] fix feather nrf52840 build error --- ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h index 81818741d1..bd6d4b2449 100644 --- a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h @@ -67,5 +67,5 @@ #define DEFAULT_SPI_BUS_MOSI (&pin_P0_23) #define DEFAULT_SPI_BUS_MISO (&pin_P0_22) -#define DEFAULT_UART_BUS_RX (&pin_P1_0) +#define DEFAULT_UART_BUS_RX (&pin_P1_00) #define DEFAULT_UART_BUS_TX (&pin_P0_24) From 74cc55b107bd41808ad2cce35493ffc51eb1c051 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 25 Sep 2018 17:31:53 +0700 Subject: [PATCH 19/25] change error type to runtime --- ports/nrf/common-hal/busio/UART.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 28fcdc1508..c209be89d0 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -45,7 +45,7 @@ do {\ uint32_t _err = (_exp);\ if (NRFX_SUCCESS != _err ) {\ - mp_raise_msg_varg(&mp_type_AssertionError, translate("error = 0x%08lX "), _err);\ + mp_raise_msg_varg(&mp_type_RuntimeError, translate("error = 0x%08lX "), _err);\ }\ }while(0) From 52328c88cd5271c9b82dd03ef9ca19b0abc34e6f Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 26 Sep 2018 02:06:32 +0700 Subject: [PATCH 20/25] remove space --- ports/nrf/common-hal/busio/UART.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index c209be89d0..86fe647265 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -45,7 +45,7 @@ do {\ uint32_t _err = (_exp);\ if (NRFX_SUCCESS != _err ) {\ - mp_raise_msg_varg(&mp_type_RuntimeError, translate("error = 0x%08lX "), _err);\ + mp_raise_msg_varg(&mp_type_RuntimeError, translate("error = 0x%08lX"), _err);\ }\ }while(0) From eba80f7a9939f6ac48fcadeb1c46082b0e8d7575 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 26 Sep 2018 02:10:44 +0700 Subject: [PATCH 21/25] update translate string --- locale/circuitpython.pot | 29 +++++++++++++++++++++++------ locale/de_DE.po | 31 +++++++++++++++++++++++++------ locale/en_US.po | 29 +++++++++++++++++++++++------ locale/es.po | 31 +++++++++++++++++++++++++------ locale/fil.po | 31 +++++++++++++++++++++++++------ locale/fr.po | 31 +++++++++++++++++++++++++------ ports/nrf/common-hal/busio/UART.c | 2 +- 7 files changed, 147 insertions(+), 37 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 513ec8efda..05cb73287c 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 12:23-0400\n" +"POT-Creation-Date: 2018-09-26 02:09+0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -378,10 +378,12 @@ msgid "bytes > 8 bits not supported" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "" @@ -390,10 +392,12 @@ msgid "Could not initialize UART" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "" @@ -702,11 +706,24 @@ msgstr "" msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +msgid "Invalid buffer size" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:90 +msgid "Odd parity is not supported" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 +#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 +#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not yet implemented" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 72f7b254d5..098e065d0a 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 12:23-0400\n" +"POT-Creation-Date: 2018-09-26 02:09+0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -387,10 +387,12 @@ msgid "bytes > 8 bits not supported" msgstr "bytes mit merh als 8 bits werden nicht unterstützt" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "tx und rx können nicht beide None sein" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "Konnte keinen RX Buffer allozieren" @@ -399,10 +401,12 @@ msgid "Could not initialize UART" msgstr "Konnte UART nicht initialisieren" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "Kein RX Pin" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "Kein TX Pin" @@ -713,11 +717,26 @@ msgstr "Alle timer werden benutzt" msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +#, fuzzy +msgid "Invalid buffer size" +msgstr "ungültiger dupterm index" + +#: ports/nrf/common-hal/busio/UART.c:90 +#, fuzzy +msgid "Odd parity is not supported" +msgstr "bytes mit merh als 8 bits werden nicht unterstützt" + +#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 +#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 +#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not yet implemented" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index 63ae50ba57..c57949b67f 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 12:23-0400\n" +"POT-Creation-Date: 2018-09-26 02:09+0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -378,10 +378,12 @@ msgid "bytes > 8 bits not supported" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "" @@ -390,10 +392,12 @@ msgid "Could not initialize UART" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "" @@ -702,11 +706,24 @@ msgstr "" msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +msgid "Invalid buffer size" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:90 +msgid "Odd parity is not supported" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 +#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 +#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not yet implemented" msgstr "" diff --git a/locale/es.po b/locale/es.po index 48cfdcda8a..9d8f057bed 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 12:23-0400\n" +"POT-Creation-Date: 2018-09-26 02:09+0700\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -393,10 +393,12 @@ msgid "bytes > 8 bits not supported" msgstr "bytes > 8 bits no son soportados" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "tx y rx no pueden ser ambos None" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "Fallo la asignación del buffer RX" @@ -405,10 +407,12 @@ msgid "Could not initialize UART" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "" @@ -718,11 +722,26 @@ msgstr "Todos los timers están siendo utilizados" msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +#, fuzzy +msgid "Invalid buffer size" +msgstr "index dupterm inválido" + +#: ports/nrf/common-hal/busio/UART.c:90 +#, fuzzy +msgid "Odd parity is not supported" +msgstr "bytes > 8 bits no son soportados" + +#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 +#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 +#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not yet implemented" msgstr "" diff --git a/locale/fil.po b/locale/fil.po index ad6252a213..6223463da1 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 12:23-0400\n" +"POT-Creation-Date: 2018-09-26 02:09+0700\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -390,10 +390,12 @@ msgid "bytes > 8 bits not supported" msgstr "hindi sinusuportahan ang bytes > 8 bits" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "tx at rx hindi pwedeng parehas na None" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "Nabigong ilaan ang RX buffer" @@ -402,10 +404,12 @@ msgid "Could not initialize UART" msgstr "Hindi ma-initialize ang UART" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "Walang RX pin" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "Walang TX pin" @@ -719,11 +723,26 @@ msgstr "Lahat ng timer ginagamit" msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +#, fuzzy +msgid "Invalid buffer size" +msgstr "mali ang buffer length" + +#: ports/nrf/common-hal/busio/UART.c:90 +#, fuzzy +msgid "Odd parity is not supported" +msgstr "hindi sinusuportahan ang bytes > 8 bits" + +#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 +#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 +#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not yet implemented" msgstr "hindi pa implemented ang busio.UART" diff --git a/locale/fr.po b/locale/fr.po index d6d7b6087a..3b3baca840 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-21 12:23-0400\n" +"POT-Creation-Date: 2018-09-26 02:09+0700\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -385,10 +385,12 @@ msgid "bytes > 8 bits not supported" msgstr "octets > 8 bits non supporté" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "TX et RX ne peuvent être None tous les deux" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "Echec de l'allocation du tampon RX" @@ -397,10 +399,12 @@ msgid "Could not initialize UART" msgstr "L'UART n'a pu être initialisé" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "Pas de broche RX" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "Pas de broche TX" @@ -715,11 +719,26 @@ msgstr "Tous les timers sont utilisés" msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +#, fuzzy +msgid "Invalid buffer size" +msgstr "longueur de tampon invalide" + +#: ports/nrf/common-hal/busio/UART.c:90 +#, fuzzy +msgid "Odd parity is not supported" +msgstr "octets > 8 bits non supporté" + +#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 +#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 +#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not yet implemented" msgstr "busio.UART pas encore implémenté" diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 86fe647265..40be66b65a 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -87,7 +87,7 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, } if ( parity == PARITY_ODD ) { - mp_raise_ValueError(translate("busio.UART odd parity is not supported")); + mp_raise_ValueError(translate("Odd parity is not supported")); } nrfx_uarte_config_t config = { From 76d6fb03f0ffabe3886ed5a493faa02041f91179 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 26 Sep 2018 02:12:06 +0700 Subject: [PATCH 22/25] more clean up --- ports/nrf/common-hal/busio/UART.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 40be66b65a..d3bd2a8544 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -241,12 +241,8 @@ uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) { } void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) { -#ifndef NRF52840_XXAA - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); -#else self->baudrate = baudrate; nrf_uarte_baudrate_set(self->uarte.p_reg, get_nrf_baud(baudrate)); -#endif } uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { From f543c8415d96aff96b252a0256795e1eb874f2ed Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 3 Oct 2018 11:30:31 +0700 Subject: [PATCH 23/25] "busio.UART not yet implemented -> not available --- locale/circuitpython.pot | 14 +++++++------- locale/de_DE.po | 14 +++++++------- locale/en_US.po | 14 +++++++------- locale/es.po | 14 +++++++------- locale/fil.po | 15 ++++++++------- locale/fr.po | 23 ++++++++++++----------- ports/nrf/common-hal/busio/UART.c | 20 ++++++++++---------- 7 files changed, 58 insertions(+), 56 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 05cb73287c..c224b9d6ab 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-26 02:09+0700\n" +"POT-Creation-Date: 2018-10-03 11:28+0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -719,12 +719,12 @@ msgstr "" msgid "Odd parity is not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 -#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 -#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 +#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 +#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:360 +msgid "busio.UART not available" msgstr "" #: ports/nrf/common-hal/microcontroller/Processor.c:49 diff --git a/locale/de_DE.po b/locale/de_DE.po index 098e065d0a..b60d644f9e 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-26 02:09+0700\n" +"POT-Creation-Date: 2018-10-03 11:28+0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -732,12 +732,12 @@ msgstr "ungültiger dupterm index" msgid "Odd parity is not supported" msgstr "bytes mit merh als 8 bits werden nicht unterstützt" -#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 -#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 -#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 +#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 +#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:360 +msgid "busio.UART not available" msgstr "" #: ports/nrf/common-hal/microcontroller/Processor.c:49 diff --git a/locale/en_US.po b/locale/en_US.po index c57949b67f..255de333dc 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-26 02:09+0700\n" +"POT-Creation-Date: 2018-10-03 11:28+0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -719,12 +719,12 @@ msgstr "" msgid "Odd parity is not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 -#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 -#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 +#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 +#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:360 +msgid "busio.UART not available" msgstr "" #: ports/nrf/common-hal/microcontroller/Processor.c:49 diff --git a/locale/es.po b/locale/es.po index 9d8f057bed..c3c87bf461 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-26 02:09+0700\n" +"POT-Creation-Date: 2018-10-03 11:28+0700\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -737,12 +737,12 @@ msgstr "index dupterm inválido" msgid "Odd parity is not supported" msgstr "bytes > 8 bits no son soportados" -#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 -#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 -#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 +#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 +#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:360 +msgid "busio.UART not available" msgstr "" #: ports/nrf/common-hal/microcontroller/Processor.c:49 diff --git a/locale/fil.po b/locale/fil.po index 6223463da1..e131a5c62a 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-26 02:09+0700\n" +"POT-Creation-Date: 2018-10-03 11:28+0700\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -738,12 +738,13 @@ msgstr "mali ang buffer length" msgid "Odd parity is not supported" msgstr "hindi sinusuportahan ang bytes > 8 bits" -#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 -#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 -#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 +#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 +#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:360 +#, fuzzy +msgid "busio.UART not available" msgstr "hindi pa implemented ang busio.UART" #: ports/nrf/common-hal/microcontroller/Processor.c:49 diff --git a/locale/fr.po b/locale/fr.po index 3b3baca840..9bd874e5ca 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-26 02:09+0700\n" +"POT-Creation-Date: 2018-10-03 11:28+0700\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -734,12 +734,13 @@ msgstr "longueur de tampon invalide" msgid "Odd parity is not supported" msgstr "octets > 8 bits non supporté" -#: ports/nrf/common-hal/busio/UART.c:245 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:326 ports/nrf/common-hal/busio/UART.c:331 -#: ports/nrf/common-hal/busio/UART.c:336 ports/nrf/common-hal/busio/UART.c:342 -#: ports/nrf/common-hal/busio/UART.c:347 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:356 ports/nrf/common-hal/busio/UART.c:364 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 +#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 +#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 +#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 +#: ports/nrf/common-hal/busio/UART.c:360 +#, fuzzy +msgid "busio.UART not available" msgstr "busio.UART pas encore implémenté" #: ports/nrf/common-hal/microcontroller/Processor.c:49 @@ -2424,10 +2425,10 @@ msgstr "'S' et 'O' ne sont pas des types de format supportés" msgid "too many arguments provided with the given format" msgstr "trop d'arguments fournis avec ce format" -#, fuzzy -#~ msgid "value_size must be power of two" -#~ msgstr "'len' doit être un multiple de 4" - #, fuzzy #~ msgid "palette must be displayio.Palette" #~ msgstr "la palette doit être longue de 32 octets" + +#, fuzzy +#~ msgid "value_size must be power of two" +#~ msgstr "'len' doit être un multiple de 4" diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index d3bd2a8544..8d0db34be8 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -190,7 +190,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t } // Write characters. -size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { +size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if ( nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED ) { mp_raise_ValueError(translate("No TX pin")); } @@ -315,41 +315,41 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout, uint8_t receiver_buffer_size) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); } bool common_hal_busio_uart_deinited (busio_uart_obj_t *self) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); return true; } void common_hal_busio_uart_deinit (busio_uart_obj_t *self) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); } // Read characters. size_t common_hal_busio_uart_read (busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); return 0; } // Write characters. size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); return 0; } uint32_t common_hal_busio_uart_get_baudrate (busio_uart_obj_t *self) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); return self->baudrate; } void common_hal_busio_uart_set_baudrate (busio_uart_obj_t *self, uint32_t baudrate) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); } uint32_t common_hal_busio_uart_rx_characters_available (busio_uart_obj_t *self) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); } void common_hal_busio_uart_clear_rx_buffer (busio_uart_obj_t *self) { @@ -357,7 +357,7 @@ void common_hal_busio_uart_clear_rx_buffer (busio_uart_obj_t *self) { } bool common_hal_busio_uart_ready_to_tx (busio_uart_obj_t *self) { - mp_raise_NotImplementedError(translate("busio.UART not yet implemented")); + mp_raise_NotImplementedError(translate("busio.UART not available")); return false; } #endif From 08cbb03bddfa1a18ac8048e979fb2e9682beb1c2 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 3 Oct 2018 11:39:01 +0700 Subject: [PATCH 24/25] implement common_hal_busio_uart_clear_rx_buffer --- ports/nrf/common-hal/busio/UART.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 8d0db34be8..b2dbb56a1f 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -250,7 +250,11 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { } void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { - + // Discard received byte, and queue 1-byte transfer for rx_characters_available() + if ( self->rx_count > 0 ) { + self->rx_count = -1; + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); + } } bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { From a47eaa521b39f90667da17a4ec7a1c256dec2ab5 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 3 Oct 2018 23:16:02 +0700 Subject: [PATCH 25/25] update translate --- locale/circuitpython.pot | 20 +++++++++--------- locale/de_DE.po | 20 +++++++++--------- locale/en_US.po | 20 +++++++++--------- locale/es.po | 23 +++++++++++---------- locale/fil.po | 20 +++++++++--------- locale/fr.po | 28 ++++++++++++------------- locale/pt_BR.po | 44 +++++++++++++++++++++++++++++----------- 7 files changed, 98 insertions(+), 77 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 0d6a612b82..ca8d55dcbc 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-03 11:28+0700\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -361,7 +361,7 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "" @@ -694,15 +694,15 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 msgid "All I2C peripherals are in use" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 msgid "All SPI peripherals are in use" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" @@ -719,11 +719,11 @@ msgstr "" msgid "Odd parity is not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 -#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 -#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:360 +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not available" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index defe320cab..4579f8c679 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-03 11:28+0700\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -370,7 +370,7 @@ msgstr "Nicht genug Pins vorhanden" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "Ungültige Pins" @@ -703,17 +703,17 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 #, fuzzy msgid "All I2C peripherals are in use" msgstr "Alle timer werden benutzt" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 #, fuzzy msgid "All SPI peripherals are in use" msgstr "Alle timer werden benutzt" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" @@ -732,11 +732,11 @@ msgstr "ungültiger dupterm index" msgid "Odd parity is not supported" msgstr "bytes mit merh als 8 bits werden nicht unterstützt" -#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 -#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 -#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:360 +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not available" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index a05a3c028e..1a120e6682 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-03 11:28+0700\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -361,7 +361,7 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "" @@ -694,15 +694,15 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 msgid "All I2C peripherals are in use" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 msgid "All SPI peripherals are in use" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" @@ -719,11 +719,11 @@ msgstr "" msgid "Odd parity is not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 -#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 -#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:360 +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not available" msgstr "" diff --git a/locale/es.po b/locale/es.po index 5d3aee77f0..664fd9be78 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-03 11:28+0700\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -376,7 +376,7 @@ msgstr "No hay suficientes pines disponibles" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "pines inválidos" @@ -624,7 +624,8 @@ msgstr "len debe de ser múltiple de 4" #: ports/esp8266/modesp.c:274 #, c-format msgid "memory allocation failed, allocating %u bytes for native code" -msgstr "la asignación de memoria ha fallado, asignando %u bytes para código nativo" +msgstr "" +"la asignación de memoria ha fallado, asignando %u bytes para código nativo" #: ports/esp8266/modesp.c:317 msgid "flash location must be below 1MByte" @@ -710,15 +711,15 @@ msgstr "parámetro config desconocido" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 msgid "All I2C peripherals are in use" msgstr "Todos los timers están siendo utilizados" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 msgid "All SPI peripherals are in use" msgstr "Todos los timers están siendo utilizados" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" @@ -737,11 +738,11 @@ msgstr "index dupterm inválido" msgid "Odd parity is not supported" msgstr "bytes > 8 bits no son soportados" -#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 -#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 -#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:360 +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 msgid "busio.UART not available" msgstr "" diff --git a/locale/fil.po b/locale/fil.po index e77e31068a..783fb67711 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-03 11:28+0700\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -373,7 +373,7 @@ msgstr "Hindi sapat ang magagamit na pins" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "Mali ang pins" @@ -709,17 +709,17 @@ msgstr "hindi alam na config param" msgid "AnalogOut functionality not supported" msgstr "Hindi supportado ang AnalogOut" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 #, fuzzy msgid "All I2C peripherals are in use" msgstr "Lahat ng timer ginagamit" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 #, fuzzy msgid "All SPI peripherals are in use" msgstr "Lahat ng timer ginagamit" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" @@ -738,11 +738,11 @@ msgstr "mali ang buffer length" msgid "Odd parity is not supported" msgstr "hindi sinusuportahan ang bytes > 8 bits" -#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 -#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 -#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:360 +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 #, fuzzy msgid "busio.UART not available" msgstr "hindi pa implemented ang busio.UART" diff --git a/locale/fr.po b/locale/fr.po index bbabd85378..3af5066e6a 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-03 11:28+0700\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -368,7 +368,7 @@ msgstr "Pas assez de broches disponibles" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "Broche invalide" @@ -705,17 +705,17 @@ msgstr "paramètre de config. inconnu" msgid "AnalogOut functionality not supported" msgstr "AnalogOut non supporté" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 #, fuzzy msgid "All I2C peripherals are in use" msgstr "Tous les timers sont utilisés" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 #, fuzzy msgid "All SPI peripherals are in use" msgstr "Tous les timers sont utilisés" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" @@ -734,11 +734,11 @@ msgstr "longueur de tampon invalide" msgid "Odd parity is not supported" msgstr "octets > 8 bits non supporté" -#: ports/nrf/common-hal/busio/UART.c:318 ports/nrf/common-hal/busio/UART.c:322 -#: ports/nrf/common-hal/busio/UART.c:327 ports/nrf/common-hal/busio/UART.c:332 -#: ports/nrf/common-hal/busio/UART.c:338 ports/nrf/common-hal/busio/UART.c:343 -#: ports/nrf/common-hal/busio/UART.c:348 ports/nrf/common-hal/busio/UART.c:352 -#: ports/nrf/common-hal/busio/UART.c:360 +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 #, fuzzy msgid "busio.UART not available" msgstr "busio.UART pas encore implémenté" @@ -2425,10 +2425,10 @@ msgstr "'S' et 'O' ne sont pas des types de format supportés" msgid "too many arguments provided with the given format" msgstr "trop d'arguments fournis avec ce format" -#, fuzzy -#~ msgid "palette must be displayio.Palette" -#~ msgstr "la palette doit être longue de 32 octets" - #, fuzzy #~ msgid "value_size must be power of two" #~ msgstr "'len' doit être un multiple de 4" + +#, fuzzy +#~ msgid "palette must be displayio.Palette" +#~ msgstr "la palette doit être longue de 32 octets" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 723c9bc8ec..d6b283c9fe 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-02 01:19-0300\n" +"POT-Creation-Date: 2018-10-03 23:15+0700\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -361,7 +361,7 @@ msgstr "Não há pinos suficientes disponíveis" #: ports/atmel-samd/common-hal/busio/SPI.c:132 #: ports/atmel-samd/common-hal/busio/UART.c:119 #: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45 -#: ports/nrf/common-hal/busio/I2C.c:77 +#: ports/nrf/common-hal/busio/I2C.c:81 msgid "Invalid pins" msgstr "Pinos inválidos" @@ -378,10 +378,12 @@ msgid "bytes > 8 bits not supported" msgstr "bytes > 8 bits não suportado" #: ports/atmel-samd/common-hal/busio/UART.c:72 +#: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" msgstr "TX e RX não podem ser ambos" #: ports/atmel-samd/common-hal/busio/UART.c:145 +#: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" msgstr "Falha ao alocar buffer RX" @@ -390,10 +392,12 @@ msgid "Could not initialize UART" msgstr "Não foi possível inicializar o UART" #: ports/atmel-samd/common-hal/busio/UART.c:240 +#: ports/nrf/common-hal/busio/UART.c:149 msgid "No RX pin" msgstr "Nenhum pino RX" #: ports/atmel-samd/common-hal/busio/UART.c:294 +#: ports/nrf/common-hal/busio/UART.c:195 msgid "No TX pin" msgstr "Nenhum pino TX" @@ -690,24 +694,39 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/I2C.c:91 +#: ports/nrf/common-hal/busio/I2C.c:95 msgid "All I2C peripherals are in use" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:109 +#: ports/nrf/common-hal/busio/SPI.c:115 msgid "All SPI peripherals are in use" msgstr "" -#: ports/nrf/common-hal/busio/SPI.c:170 +#: ports/nrf/common-hal/busio/SPI.c:176 msgid "Baud rate too high for this SPI peripheral" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 -#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 -#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 -#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 -#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90 -msgid "busio.UART not yet implemented" +#: ports/nrf/common-hal/busio/UART.c:48 +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c:86 +#, fuzzy +msgid "Invalid buffer size" +msgstr "Arquivo inválido" + +#: ports/nrf/common-hal/busio/UART.c:90 +#, fuzzy +msgid "Odd parity is not supported" +msgstr "I2C operação não suportada" + +#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326 +#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336 +#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347 +#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356 +#: ports/nrf/common-hal/busio/UART.c:364 +msgid "busio.UART not available" msgstr "" #: ports/nrf/common-hal/microcontroller/Processor.c:49 @@ -2254,7 +2273,8 @@ msgstr "Limite deve estar no alcance de 0-65536" #: shared-bindings/util.c:38 msgid "" "Object has been deinitialized and can no longer be used. Create a new object." -msgstr "Objeto foi desinicializado e não pode ser mais usaado. Crie um novo objeto." +msgstr "" +"Objeto foi desinicializado e não pode ser mais usaado. Crie um novo objeto." #: shared-module/audioio/WaveFile.c:61 msgid "Invalid wave file"