https://forum.pjrc.com/threads/27093-Fix-for-9-bit-serial-receive-bugmain
| head = rx_buffer_head; | head = rx_buffer_head; | ||||
| tail = rx_buffer_tail; | tail = rx_buffer_tail; | ||||
| do { | do { | ||||
| n = UART0_D; | |||||
| if (use9Bits && (UART0_C3 & 0x80)) n |= 0x100; | |||||
| if (use9Bits && (UART0_C3 & 0x80)) { | |||||
| n = UART0_D | 0x100; | |||||
| } else { | |||||
| n = UART0_D; | |||||
| } | |||||
| newhead = head + 1; | newhead = head + 1; | ||||
| if (newhead >= RX_BUFFER_SIZE) newhead = 0; | if (newhead >= RX_BUFFER_SIZE) newhead = 0; | ||||
| if (newhead != tail) { | if (newhead != tail) { |
| head = rx_buffer_head; | head = rx_buffer_head; | ||||
| tail = rx_buffer_tail; | tail = rx_buffer_tail; | ||||
| do { | do { | ||||
| n = UART1_D; | |||||
| if (use9Bits && (UART1_C3 & 0x80)) n |= 0x100; | |||||
| if (use9Bits && (UART1_C3 & 0x80)) { | |||||
| n = UART1_D | 0x100; | |||||
| } else { | |||||
| n = UART1_D; | |||||
| } | |||||
| newhead = head + 1; | newhead = head + 1; | ||||
| if (newhead >= RX_BUFFER_SIZE) newhead = 0; | if (newhead >= RX_BUFFER_SIZE) newhead = 0; | ||||
| if (newhead != tail) { | if (newhead != tail) { |
| uint8_t c; | uint8_t c; | ||||
| if (UART2_S1 & UART_S1_RDRF) { | if (UART2_S1 & UART_S1_RDRF) { | ||||
| n = UART2_D; | |||||
| if (use9Bits && (UART2_C3 & 0x80)) n |= 0x100; | |||||
| if (use9Bits && (UART2_C3 & 0x80)) { | |||||
| n = UART2_D | 0x100; | |||||
| } else { | |||||
| n = UART2_D; | |||||
| } | |||||
| head = rx_buffer_head + 1; | head = rx_buffer_head + 1; | ||||
| if (head >= RX_BUFFER_SIZE) head = 0; | if (head >= RX_BUFFER_SIZE) head = 0; | ||||
| if (head != rx_buffer_tail) { | if (head != rx_buffer_tail) { |