Hi Vivien,
Did you write the usart_001.h by yourself? I can't find this header file. Did you get this file from the official website?
odd parity, even parity, forced'1' and forece'0' stick parity are all bit 5:4 in the LCR register, enable disable parity is bit 3..
Take your post code as an example:
You think incorrect item:
typedef enum IP_UART_PARITY {
UART_PARITY_NONE = 0, /*!< No parity */
UART_PARITY_ODD = (4 << 3), /*!< Odd parity */
UART_PARITY_EVEN = (5 << 3), /*!< Even parity */
UART_PARITY_SP_1 = (6 << 3), /*!< Forced "1" stick parity */
UART_PARITY_SP_0 = (7 << 3) /*!< Forced "0" stick parity */
} IP_UART_PARITY_T;
UART_PARITY_NONE =0; bit3 is 0x0, disable parity should be 0
UART_PARITY_ODD = 0x20; bit5,4 is 0X2, but odd parity should be 0x0; bit3 should be 1, not correct.
UART_PARITY_EVEN=0X28; bit5,4 is 0X2, but even parity should be 0x1; not correct.
UART_PARITY_SP_1=0X30; bit5,4 is 0X3, but SP_1 parity should be 0x2; bit3 should be 1, not correct.
UART_PARITY_SP_0=0X38; bit5,4 is 0X3, but SP_0 parity should be 0x3; correct.
You think correct item:
typedef enum IP_UART_PARITY {
UART_PARITY_NONE = 0, /*!< No parity */
UART_PARITY_ODD = (1 << 3), /*!< Odd parity */
UART_PARITY_EVEN = (3 << 3), /*!< Even parity */
UART_PARITY_SP_1 = (5 << 3), /*!< Forced "1" stick parity */
UART_PARITY_SP_0 = (7 << 3) /*!< Forced "0" stick parity */
} IP_UART_PARITY_T;
UART_PARITY_NONE =0; bit3 is 0x0, disable parity should be 0; correct.
UART_PARITY_ODD = 0x08; bit5,4 is 0X0, odd parity should be 0x0; correct.
UART_PARITY_EVEN=0X18; bit5,4 is 0X1, even parity should be 0x1; correct.
UART_PARITY_SP_1=0X28; bit5,4 is 0X2, SP_1 parity should be 0x2; correct.
UART_PARITY_SP_0=0X38; bit5,4 is 0X3, SP_0 parity should be 0x3; correct.
so, after the analysis, your modified enum IP_UART_PARITY is correct.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------