mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
uart.h
Go to the documentation of this file.
1 /*
2  * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3  * Contributions: Jon Trulson <jtrulson@ics.com>
4  * Brendan Le Foll <brendan.le.foll@intel.com>
5  * Copyright (c) 2014 - 2015 Intel Corporation
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 
27 #pragma once
28 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <stdio.h>
45 
46 #include "common.h"
47 
49 typedef struct _uart* mraa_uart_context;
50 
57 mraa_uart_context mraa_uart_init(int uart);
58 
65 mraa_uart_context mraa_uart_init_raw(const char* path);
66 
74 mraa_result_t mraa_uart_flush(mraa_uart_context dev);
75 
86 mraa_result_t mraa_uart_sendbreak(mraa_uart_context dev, int duration);
87 
97 mraa_result_t mraa_uart_set_baudrate(mraa_uart_context dev, unsigned int baud);
98 
110 mraa_result_t mraa_uart_set_mode(mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits);
111 
120 mraa_result_t mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts);
121 
132 mraa_result_t mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar);
133 
141 mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t nonblock);
142 
150 const char* mraa_uart_get_dev_path(mraa_uart_context dev);
151 
177 mraa_uart_settings(int index,
178  const char **devpath,
179  const char **name,
180  int* baudrate,
181  int* databits,
182  int* stopbits,
183  mraa_uart_parity_t* parity,
184  unsigned int* rtscts,
185  unsigned int* xonxoff);
186 
193 mraa_result_t mraa_uart_stop(mraa_uart_context dev);
194 
203 int mraa_uart_read(mraa_uart_context dev, char* buf, size_t length);
204 
213 int mraa_uart_write(mraa_uart_context dev, const char* buf, size_t length);
214 
222 mraa_boolean_t mraa_uart_data_available(mraa_uart_context dev, unsigned int millis);
223 
224 #ifdef __cplusplus
225 }
226 #endif
mraa_uart_parity_t
Definition: types.h:255
unsigned int mraa_boolean_t
Definition: common.h:78
int mraa_uart_write(mraa_uart_context dev, const char *buf, size_t length)
struct _uart * mraa_uart_context
Definition: uart.h:49
mraa_result_t mraa_uart_stop(mraa_uart_context dev)
mraa_result_t mraa_uart_sendbreak(mraa_uart_context dev, int duration)
mraa_result_t mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts)
mraa_result_t mraa_uart_flush(mraa_uart_context dev)
mraa_result_t mraa_uart_settings(int index, const char **devpath, const char **name, int *baudrate, int *databits, int *stopbits, mraa_uart_parity_t *parity, unsigned int *rtscts, unsigned int *xonxoff)
mraa_uart_context mraa_uart_init_raw(const char *path)
mraa_boolean_t mraa_uart_data_available(mraa_uart_context dev, unsigned int millis)
const char * mraa_uart_get_dev_path(mraa_uart_context dev)
mraa_result_t mraa_uart_set_mode(mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits)
int mraa_uart_read(mraa_uart_context dev, char *buf, size_t length)
mraa_uart_context mraa_uart_init(int uart)
mraa_result_t
Definition: types.h:209
mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t nonblock)
mraa_result_t mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar)
mraa_result_t mraa_uart_set_baudrate(mraa_uart_context dev, unsigned int baud)