forked from Imagelibrary/rtems
dev/sc16is752: Add RS485 mode variants
This commit is contained in:
@@ -68,6 +68,8 @@ extern "C" {
|
||||
#define SC16IS752_EFCR_RS485_ENABLE (1u << 0)
|
||||
#define SC16IS752_EFCR_RX_DISABLE (1u << 1)
|
||||
#define SC16IS752_EFCR_TX_DISABLE (1u << 2)
|
||||
#define SC16IS752_EFCR_RTSCON (1u << 4)
|
||||
#define SC16IS752_EFCR_RTSINVER (1u << 5)
|
||||
|
||||
/* IER */
|
||||
#define SC16IS752_IER_RHR (1u << 0)
|
||||
@@ -91,6 +93,7 @@ extern "C" {
|
||||
#define SC16IS752_LCR_2_STOP_BIT (1u << 2)
|
||||
#define SC16IS752_LCR_SET_PARITY (1u << 3)
|
||||
#define SC16IS752_LCR_EVEN_PARITY (1u << 4)
|
||||
#define SC16IS752_LCR_BREAK (1u << 5)
|
||||
#define SC16IS752_LCR_ENABLE_DIVISOR (1u << 7)
|
||||
|
||||
/* LSR */
|
||||
|
||||
@@ -212,6 +212,7 @@ static bool sc16is752_first_open(
|
||||
{
|
||||
bool ok;
|
||||
uint8_t fcr;
|
||||
uint8_t efcr;
|
||||
|
||||
(void)args;
|
||||
sc16is752_context *ctx = (sc16is752_context *)base;
|
||||
@@ -223,12 +224,23 @@ static bool sc16is752_first_open(
|
||||
return ok;
|
||||
}
|
||||
|
||||
if (ctx->mode == SC16IS752_MODE_RS485) {
|
||||
ctx->efcr = SC16IS752_EFCR_RS485_ENABLE;
|
||||
} else {
|
||||
ctx->efcr = 0;
|
||||
efcr = 0;
|
||||
|
||||
switch (ctx->mode) {
|
||||
case SC16IS752_MODE_RS485_RTS_INV:
|
||||
efcr |= SC16IS752_EFCR_RTSINVER;
|
||||
/* Fall through */
|
||||
case SC16IS752_MODE_RS485_RTS:
|
||||
efcr |= SC16IS752_EFCR_RTSCON;
|
||||
/* Fall through */
|
||||
case SC16IS752_MODE_RS485:
|
||||
efcr |= SC16IS752_EFCR_RS485_ENABLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->efcr = efcr;
|
||||
write_reg(ctx, SC16IS752_FCR, &ctx->efcr, 1);
|
||||
|
||||
fcr = SC16IS752_FCR_FIFO_EN
|
||||
|
||||
@@ -31,7 +31,18 @@ extern "C" {
|
||||
|
||||
typedef enum {
|
||||
SC16IS752_MODE_RS232,
|
||||
SC16IS752_MODE_RS485
|
||||
|
||||
/* Enable RS485 mode */
|
||||
SC16IS752_MODE_RS485,
|
||||
|
||||
/* Enable RS485 mode, enable the transmitter to control the #RTS pin */
|
||||
SC16IS752_MODE_RS485_RTS,
|
||||
|
||||
/*
|
||||
* Enable RS485 mode, enable the transmitter to control the #RTS pin, invert
|
||||
* RTS signal (#RTS = 1 during transmission and #RTS = 0 during reception)
|
||||
*/
|
||||
SC16IS752_MODE_RS485_RTS_INV
|
||||
} sc16is752_mode;
|
||||
|
||||
typedef struct sc16is752_context sc16is752_context;
|
||||
|
||||
Reference in New Issue
Block a user