-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds 9bit reception support to the TI uart drivers. #713
Changes from 3 commits
8f0dfc7
0b3174b
dbca917
0496cf4
e4c9d95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ CC32xxUart::CC32xxUart(const char *name, unsigned long base, uint32_t interrupt, | |
, uartMode_(mode | UART_CONFIG_PAR_NONE) | ||
, txPending_(false) | ||
, hwFIFO_(hw_fifo) | ||
, nineBit_(false) | ||
{ | ||
static_assert( | ||
UART_CONFIG_PAR_NONE == 0, "driverlib changed against our assumptions"); | ||
|
@@ -169,6 +170,13 @@ int CC32xxUart::ioctl(File *file, unsigned long int key, unsigned long data) | |
uartMode_ |= UART_CONFIG_PAR_ONE; | ||
MAP_UARTParityModeSet(base_, UART_CONFIG_PAR_ONE); | ||
break; | ||
case TCNINEBITRX: | ||
nineBit_ = data != 0; | ||
if (!nineBit_) | ||
{ | ||
break; | ||
} | ||
// fall through | ||
case TCPARZERO: | ||
uartMode_ &= ~UART_CONFIG_PAR_MASK; | ||
uartMode_ |= UART_CONFIG_PAR_ZERO; | ||
|
@@ -289,14 +297,34 @@ void CC32xxUart::interrupt_handler() | |
while (MAP_UARTCharsAvail(base_)) | ||
{ | ||
long data = MAP_UARTCharGetNonBlocking(base_); | ||
if (data >= 0 && data <= 0xff) | ||
if (nineBit_) | ||
{ | ||
unsigned char c = data; | ||
if (rxBuf->put(&c, 1) == 0) | ||
if (rxBuf->space() < 2) | ||
{ | ||
++overrunCount; | ||
} | ||
rxBuf->signal_condition_from_isr(); | ||
else | ||
{ | ||
// parity error bit is moved to the ninth bit, then two bytes | ||
// are written to the buffer. | ||
long bit9 = (data & 0x200) >> 1; | ||
data &= 0xff; | ||
data |= bit9; | ||
rxBuf->put((uint8_t *)&data, 2); | ||
rxBuf->signal_condition_from_isr(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if/else [overrun] logic for signal_condition_from_isr() is not the same for both 9 and 8 bit data paths. I think technically either is actually fine, but we should be consistent. Pick one and modify the other to match. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
} | ||
} | ||
else | ||
{ | ||
if (data >= 0 && data <= 0xff) | ||
{ | ||
unsigned char c = data; | ||
if (rxBuf->put(&c, 1) == 0) | ||
{ | ||
++overrunCount; | ||
} | ||
rxBuf->signal_condition_from_isr(); | ||
} | ||
} | ||
} | ||
/* transmit a character if we have pending tx data */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ TivaUart::TivaUart(const char *name, unsigned long base, uint32_t interrupt, | |
, hwFIFO_(hw_fifo) | ||
, uartMode_(mode) | ||
, txPending_(false) | ||
, nineBit_(false) | ||
{ | ||
static_assert( | ||
UART_CONFIG_PAR_NONE == 0, "driverlib changed against our assumptions"); | ||
|
@@ -218,14 +219,34 @@ void TivaUart::interrupt_handler() | |
while (MAP_UARTCharsAvail(base_)) | ||
{ | ||
long data = MAP_UARTCharGetNonBlocking(base_); | ||
if (data >= 0 && data <= 0xff) | ||
if (nineBit_) | ||
{ | ||
unsigned char c = data; | ||
if (rxBuf->put(&c, 1) == 0) | ||
if (rxBuf->space() < 2) | ||
{ | ||
overrunCount++; | ||
++overrunCount; | ||
} | ||
else | ||
{ | ||
// parity error bit is moved to the ninth bit, then two bytes | ||
// are written to the buffer. | ||
long bit9 = (data & 0x200) >> 1; | ||
data &= 0xff; | ||
data |= bit9; | ||
rxBuf->put((uint8_t *)&data, 2); | ||
rxBuf->signal_condition_from_isr(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
} | ||
} | ||
else | ||
{ | ||
if (data >= 0 && data <= 0xff) | ||
{ | ||
unsigned char c = data; | ||
if (rxBuf->put(&c, 1) == 0) | ||
{ | ||
overrunCount++; | ||
} | ||
rxBuf->signal_condition_from_isr(); | ||
} | ||
rxBuf->signal_condition_from_isr(); | ||
} | ||
} | ||
/* transmit a character if we have pending tx data */ | ||
|
@@ -302,6 +323,13 @@ int TivaUart::ioctl(File *file, unsigned long int key, unsigned long data) | |
uartMode_ |= UART_CONFIG_PAR_ONE; | ||
MAP_UARTParityModeSet(base_, UART_CONFIG_PAR_ONE); | ||
break; | ||
case TCNINEBITRX: | ||
nineBit_ = data != 0; | ||
if (!nineBit_) | ||
{ | ||
break; | ||
} | ||
// fall through | ||
case TCPARZERO: | ||
uartMode_ &= ~UART_CONFIG_PAR_MASK; | ||
uartMode_ |= UART_CONFIG_PAR_ZERO; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace or intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed