Private
Public Access
2
0

uart: add function mraa_uart_get_dev_path

Used for getting the path to the character device under linux for uart
device. i.e. "/dev/ttyS0"

Adds paths to existing platforms.
Closes #84

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
Thomas Ingleby
2015-01-20 15:10:47 +00:00
parent ed4c68eba1
commit 9cfbc87924
11 changed files with 83 additions and 0 deletions

View File

@@ -140,6 +140,8 @@ mraa_intel_de3815()
b->spi_bus[0].miso = 12;
b->spi_bus[0].sclk = 13;
b->uart_dev_count = 0;
return b;
error:
syslog(LOG_CRIT, "de3815: Platform failed to initialise");

View File

@@ -40,6 +40,7 @@
// Might not always be correct. First thing to check if mmap stops
// working. Check the device for 0x1199 and Intel Vendor (0x8086)
#define MMAP_PATH "/sys/devices/pci0000:00/0000:00:0c.0/resource0"
#define UART_DEV_PATH "/dev/ttyMFD1"
typedef struct {
int sysfs;
@@ -1365,6 +1366,13 @@ mraa_intel_edison_fab_c()
b->uart_dev[0].rx = 0;
b->uart_dev[0].tx = 1;
int uart_path_length = strlen(UART_DEV_PATH) + 1;
b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
if (b->uart_dev[0].device_path == NULL) {
goto error;
}
strncpy(b->uart_dev[0].device_path, UART_DEV_PATH, uart_path_length);
int il;
for (il =0; il < MRAA_INTEL_EDISON_PINCOUNT; il++) {
pinmodes[il].gpio.sysfs = -1;

View File

@@ -405,11 +405,25 @@ mraa_intel_galileo_rev_d()
b->spi_bus[0].miso = 12;
b->spi_bus[0].sclk = 13;
int uart_path_length = strlen("/dev/ttyS0") + 1;
b->uart_dev_count = 2;
b->def_uart_dev = 0;
b->uart_dev[0].rx = 0;
b->uart_dev[0].tx = 1;
b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
if (b->uart_dev[0].device_path == NULL) {
goto error;
}
strncpy(b->uart_dev[0].device_path, "/dev/ttyS0", uart_path_length);
b->uart_dev[1].rx = -1;
b->uart_dev[1].tx = -1;
b->uart_dev[1].device_path = (char*) malloc(sizeof(char) * uart_path_length);
if (b->uart_dev[1].device_path == NULL) {
goto error;
}
strncpy(b->uart_dev[1].device_path, "/dev/ttyS1", uart_path_length);
return b;
error:

View File

@@ -746,10 +746,17 @@ mraa_intel_galileo_gen2()
b->spi_bus[0].miso = 12;
b->spi_bus[0].sclk = 13;
int uart_path_length = strlen("/dev/ttyS0") + 1;
b->uart_dev_count = 1;
b->def_uart_dev = 0;
b->uart_dev[0].rx = 0;
b->uart_dev[0].tx = 1;
b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
if (b->uart_dev[0].device_path == NULL) {
goto error;
}
strncpy(b->uart_dev[0].device_path, "/dev/ttyS0", uart_path_length);
return b;
error:

View File

@@ -181,6 +181,8 @@ mraa_intel_minnow_max()
b->spi_bus[0].miso = 7;
b->spi_bus[0].sclk = 11;
b->uart_dev_count = 0;
return b;
error:
syslog(LOG_CRIT, "minnowmax: Platform failed to initialise");