diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-01-14 17:26:36 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-01-14 17:29:19 -0800 |
| commit | 747f2cfe267628fda8487c533ce7a5ab10a9388f (patch) | |
| tree | f8d8d56e7682e0627801897780556dc340b5411e /shared-bindings/busio/UART.c | |
| parent | 72d993d60c5e5238942491df00776ca31f9758a1 (diff) | |
Add subclass support to displayio.
Also, swap make_news to accept a kwarg map and refine param checking.
Fixes #1237
Diffstat (limited to 'shared-bindings/busio/UART.c')
| -rw-r--r-- | shared-bindings/busio/UART.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 1cba386d2..cd0ca3f36 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -69,16 +69,13 @@ typedef struct { extern const busio_uart_parity_obj_t busio_uart_parity_even_obj; extern const busio_uart_parity_obj_t busio_uart_parity_odd_obj; -STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { - mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, true); +STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { // Always initially allocate the UART object within the long-lived heap. // This is needed to avoid crashes with certain UART implementations which // cannot accomodate being moved after creation. (See // https://github.com/adafruit/circuitpython/issues/1056) busio_uart_obj_t *self = m_new_ll_obj(busio_uart_obj_t); self->base.type = &busio_uart_type; - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size}; static const mp_arg_t allowed_args[] = { { MP_QSTR_tx, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -91,7 +88,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si { MP_QSTR_receiver_buffer_size, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); assert_pin(args[ARG_rx].u_obj, true); const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(args[ARG_rx].u_obj); |
