diff options
-rw-r--r-- | cc3200/mods/pybuart.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cc3200/mods/pybuart.c b/cc3200/mods/pybuart.c index 7fb51d83d1..92bb3e46e6 100644 --- a/cc3200/mods/pybuart.c +++ b/cc3200/mods/pybuart.c @@ -375,10 +375,13 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, const mp_arg_val_t *a config |= UART_CONFIG_PAR_NONE; } else { uint parity = mp_obj_get_int(args[2].u_obj); - if (parity != UART_CONFIG_PAR_ODD && parity != UART_CONFIG_PAR_EVEN) { + if (parity == 0) { + config |= UART_CONFIG_PAR_EVEN; + } else if (parity == 1) { + config |= UART_CONFIG_PAR_ODD; + } else { goto error; } - config |= parity; } // stop bits config |= (args[3].u_int == 1 ? UART_CONFIG_STOP_ONE : UART_CONFIG_STOP_TWO); @@ -577,8 +580,6 @@ STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&mp_stream_write_obj }, // class constants - { MP_OBJ_NEW_QSTR(MP_QSTR_EVEN), MP_OBJ_NEW_SMALL_INT(UART_CONFIG_PAR_EVEN) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_ODD), MP_OBJ_NEW_SMALL_INT(UART_CONFIG_PAR_ODD) }, { MP_OBJ_NEW_QSTR(MP_QSTR_RX_ANY), MP_OBJ_NEW_SMALL_INT(UART_TRIGGER_RX_ANY) }, }; |