Add support for UART hardware flow control
This allows assigning platform pins to the CTS/RTS lines. If provided, these will be muxed as UART when flow control is enabled. Signed-off-by: Nicola Lunghi <nicola.lunghi@emutex.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
6185f0ac92
commit
45127e04b9
@@ -372,6 +372,8 @@ typedef struct {
|
||||
unsigned int index; /**< ID as exposed in the system */
|
||||
int rx; /**< uart rx */
|
||||
int tx; /**< uart tx */
|
||||
int cts; /**< uart cts */
|
||||
int rts; /**< uart rts */
|
||||
char* device_path; /**< To store "/dev/ttyS1" for example */
|
||||
/*@}*/
|
||||
} mraa_uart_dev_t;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Contributions: Jon Trulson <jtrulson@ics.com>
|
||||
* Brendan le Foll <brendan.le.foll@intel.com>
|
||||
* Nicola Lunghi <nicola.lunghi@emutex.com>
|
||||
* Copyright (c) 2014 - 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -609,6 +610,29 @@ mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_bo
|
||||
return dev->advance_func->uart_set_flowcontrol_replace(dev, xonxoff, rtscts);
|
||||
}
|
||||
|
||||
if (rtscts) {
|
||||
// assign the CTS and RTS pin to UART when enabling flow control
|
||||
if (!plat->no_bus_mux) {
|
||||
int pos_cts = plat->uart_dev[dev->index].cts;
|
||||
int pos_rts = plat->uart_dev[dev->index].rts;
|
||||
|
||||
if ((pos_cts >= 0) && (pos_rts >= 0)) {
|
||||
if (plat->pins[pos_cts].uart.mux_total > 0) {
|
||||
if (mraa_setup_mux_mapped(plat->pins[pos_cts].uart) != MRAA_SUCCESS) {
|
||||
syslog(LOG_ERR, "uart%i: init: failed to setup muxes for CTS pin", dev->index);
|
||||
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
if (plat->pins[pos_rts].uart.mux_total > 0) {
|
||||
if (mraa_setup_mux_mapped(plat->pins[pos_rts].uart) != MRAA_SUCCESS) {
|
||||
syslog(LOG_ERR, "uart%i: init: failed to setup muxes for RTS pin", dev->index);
|
||||
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hardware flow control
|
||||
int action = TCIOFF;
|
||||
if (xonxoff) {
|
||||
|
||||
Reference in New Issue
Block a user