未验证 提交 8fcc9148 编写于 作者: B brian-r-calder 提交者: GitHub

Added facility to invert the polarity of input UART bits. (#4200)

上级 d03f8f12
......@@ -184,3 +184,8 @@ HardwareSerial::operator bool() const
{
return true;
}
void HardwareSerial::setRxInvert(bool invert)
{
uartSetRxInvert(_uart, invert);
}
......@@ -100,6 +100,8 @@ public:
size_t setRxBufferSize(size_t);
void setDebugOutput(bool);
void setRxInvert(bool);
protected:
int _uart_nr;
......
......@@ -266,6 +266,17 @@ size_t uartResizeRxBuffer(uart_t * uart, size_t new_size) {
return new_size;
}
void uartSetRxInvert(uart_t* uart, bool invert)
{
if (uart == NULL)
return;
if (invert)
uart->dev->conf0.rxd_inv = 1;
else
uart->dev->conf0.rxd_inv = 0;
}
uint32_t uartAvailable(uart_t* uart)
{
if(uart == NULL || uart->queue == NULL) {
......
......@@ -70,6 +70,8 @@ uint32_t uartGetBaudRate(uart_t* uart);
size_t uartResizeRxBuffer(uart_t* uart, size_t new_size);
void uartSetRxInvert(uart_t* uart, bool invert);
void uartSetDebug(uart_t* uart);
int uartGetDebug();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册