From 0d04677c9804d6614902dcfecac2533dd4851069 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 3 Sep 2014 09:30:49 +0100 Subject: [PATCH] uart: add C++ Uart module and links to swig Signed-off-by: Brendan Le Foll --- api/mraa.hpp | 1 + api/mraa/uart.hpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.md | 1 + src/CMakeLists.txt | 2 +- src/mraa.i | 6 ++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 api/mraa/uart.hpp diff --git a/api/mraa.hpp b/api/mraa.hpp index 6df8970..41685a5 100644 --- a/api/mraa.hpp +++ b/api/mraa.hpp @@ -30,3 +30,4 @@ #include "mraa/gpio.hpp" #include "mraa/i2c.hpp" #include "mraa/spi.hpp" +#include "mraa/uart.hpp" diff --git a/api/mraa/uart.hpp b/api/mraa/uart.hpp new file mode 100644 index 0000000..28f61c6 --- /dev/null +++ b/api/mraa/uart.hpp @@ -0,0 +1,57 @@ +/* + * Author: Brendan Le Foll + * Copyright (c) 2014 Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include "uart.h" + +namespace mraa { + +/** + * @brief C++ API to UART (enabling only) + * + * This file defines the UART C++ interface for libmraa + */ +class Uart { + public: + /** + * Uart Constructor, takes a pin number which will map directly to the + * linux uart number, this 'enables' the uart, nothing more + * + * @param uart the index of the uart set to use + */ + Uart(int uart) { + m_uart = mraa_uart_init(uart); + } + /** + * Uart destructor + */ + ~Uart() { + return; + } + private: + mraa_uart_context m_uart; +}; + +} diff --git a/docs/index.md b/docs/index.md index 4df32c8..0889902 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,6 +23,7 @@ functionality. | @ref aio.h "aio" | @ref mraa::Aio "Aio class" | | @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" | | @ref spi.h "spi" | @ref mraa::Spi "Spi class" | +| @ref uart.h "uart" | @ref mraa::Uart "Uart class" | | @ref common.h "common" | @ref mraa "common" | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9bdf9c..3df195e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,7 +46,7 @@ install (TARGETS mraa DESTINATION lib) if (DOXYGEN_FOUND) set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND}) - set (DOCCLASSES aio gpio i2c pwm spi) + set (DOCCLASSES aio gpio i2c pwm spi uart) # CPP class headers foreach (_file ${DOCCLASSES}) add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i diff --git a/src/mraa.i b/src/mraa.i index b99dae8..5928d23 100644 --- a/src/mraa.i +++ b/src/mraa.i @@ -8,6 +8,7 @@ %include pwm_class_doc.i %include aio_class_doc.i %include spi_class_doc.i + %include uart_class_doc.i #endif %{ @@ -17,6 +18,7 @@ #include "i2c.hpp" #include "spi.hpp" #include "aio.hpp" + #include "uart.hpp" %} %init %{ @@ -51,3 +53,7 @@ #### AIO #### %include "aio.hpp" + +#### UART #### + +%include "uart.hpp" -- 2.7.4