uart: add C++ Uart module and links to swig
authorBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 3 Sep 2014 08:30:49 +0000 (09:30 +0100)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 3 Sep 2014 08:30:49 +0000 (09:30 +0100)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
api/mraa.hpp
api/mraa/uart.hpp [new file with mode: 0644]
docs/index.md
src/CMakeLists.txt
src/mraa.i

index 6df8970..41685a5 100644 (file)
@@ -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 (file)
index 0000000..28f61c6
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Author: Brendan Le Foll <brendan.le.foll@intel.com>
+ * 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;
+};
+
+}
index 4df32c8..0889902 100644 (file)
@@ -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"           |
 </center>
 
index d9bdf9c..3df195e 100644 (file)
@@ -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
index b99dae8..5928d23 100644 (file)
@@ -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"