You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2020/12/14 10:59:36 UTC

[mynewt-core] branch master updated: hw/drivers/uart: Add uart_open function

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new e6bc2c3  hw/drivers/uart: Add uart_open function
e6bc2c3 is described below

commit e6bc2c39b2069815dba9d5fbfd6ea44d955f9fff
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Dec 11 14:28:44 2020 +0100

    hw/drivers/uart: Add uart_open function
    
    This adds thin wrapper to open UART device.
    Generic os_dev_open has opaque pointer that in case of UART has
    configuration but it's not clear what should be passed as argument
    without looking to UART code.
    
    With this change parameter check is enhanced as well as readability.
---
 hw/drivers/uart/include/uart/uart.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/hw/drivers/uart/include/uart/uart.h b/hw/drivers/uart/include/uart/uart.h
index ec79937..acc7daa 100644
--- a/hw/drivers/uart/include/uart/uart.h
+++ b/hw/drivers/uart/include/uart/uart.h
@@ -149,6 +149,23 @@ uart_blocking_tx(struct uart_dev *dev, uint8_t byte)
     dev->ud_funcs.uf_blocking_tx(dev, byte);
 }
 
+/**
+ * Open UART device
+ *
+ * This is thin wrapper to open uart device.  It calls os_dev_open
+ * with types clearly visible.
+ *
+ * @param name - device name, typically "uart0"
+ * @param conf - configuration of UART
+ *
+ * @return 0 - on success, error code otherwise
+ */
+static inline struct uart_dev *
+uart_open(const char *name, struct uart_conf *conf)
+{
+    return (struct uart_dev *)os_dev_open(name, OS_TIMEOUT_NEVER, conf);
+}
+
 #ifdef __cplusplus
 }
 #endif