Commit aa4ada94 authored by daniel-k's avatar daniel-k Committed by Paul Sokolovsky

esp8266/modpybuart: Fix UART parity setting.

The configuration bits for the UART register were wrong and the parity
couldn't be enabled, because the exist_parity member hasn't been updated. I
took this ESP8266 register description (http://esp8266.ru/esp8266-uart-reg/)
as reference.

Verification has been done with a logic analyzer.
parent 01816068
...@@ -112,9 +112,11 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o ...@@ -112,9 +112,11 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o
if (args[ARG_parity].u_obj != MP_OBJ_NULL) { if (args[ARG_parity].u_obj != MP_OBJ_NULL) {
if (args[ARG_parity].u_obj == mp_const_none) { if (args[ARG_parity].u_obj == mp_const_none) {
UartDev.parity = UART_NONE_BITS; UartDev.parity = UART_NONE_BITS;
UartDev.exist_parity = UART_STICK_PARITY_DIS;
self->parity = 0; self->parity = 0;
} else { } else {
mp_int_t parity = mp_obj_get_int(args[ARG_parity].u_obj); mp_int_t parity = mp_obj_get_int(args[ARG_parity].u_obj);
UartDev.exist_parity = UART_STICK_PARITY_EN;
if (parity & 1) { if (parity & 1) {
UartDev.parity = UART_ODD_BITS; UartDev.parity = UART_ODD_BITS;
self->parity = 1; self->parity = 1;
......
#ifndef _INCLUDED_UART_H_ #ifndef _INCLUDED_UART_H_
#define _INCLUDED_UART_H_ #define _INCLUDED_UART_H_
#include <eagle_soc.h>
#define UART0 (0) #define UART0 (0)
#define UART1 (1) #define UART1 (1)
...@@ -18,14 +20,14 @@ typedef enum { ...@@ -18,14 +20,14 @@ typedef enum {
} UartStopBitsNum; } UartStopBitsNum;
typedef enum { typedef enum {
UART_NONE_BITS = 0, UART_NONE_BITS = 0,
UART_ODD_BITS = 0, UART_ODD_BITS = BIT0,
UART_EVEN_BITS = BIT4 UART_EVEN_BITS = 0
} UartParityMode; } UartParityMode;
typedef enum { typedef enum {
UART_STICK_PARITY_DIS = 0, UART_STICK_PARITY_DIS = 0,
UART_STICK_PARITY_EN = BIT3 | BIT5 UART_STICK_PARITY_EN = BIT1
} UartExistParity; } UartExistParity;
typedef enum { typedef enum {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment