uart: add pre uart hook
authorThomas Ingleby <thomas.c.ingleby@intel.com>
Mon, 20 Oct 2014 17:43:58 +0000 (18:43 +0100)
committerThomas Ingleby <thomas.c.ingleby@intel.com>
Mon, 20 Oct 2014 17:43:58 +0000 (18:43 +0100)
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
include/mraa_adv_func.h
src/uart/uart.c

index f9f84b5..4a1af66 100644 (file)
@@ -61,5 +61,6 @@ typedef struct {
     mraa_result_t (*spi_init_pre) (int bus);
     mraa_result_t (*spi_init_post) (mraa_spi_context spi);
 
+    mraa_result_t (*uart_init_pre) (int index);
     mraa_result_t (*uart_init_post) (mraa_uart_context uart);
 } mraa_adv_func_t;
index 389ba2c..b282fc1 100644 (file)
 mraa_uart_context
 mraa_uart_init(int index)
 {
+    if (advance_func->uart_init_pre != NULL) {
+        if (advance_func->uart_init_pre(index) != MRAA_SUCCESS)
+            return NULL;
+    }
+
     if ( mraa_setup_uart(index) != MRAA_SUCCESS)
         return NULL;