You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/13 15:23:29 UTC

[GitHub] mkiiskila commented on a change in pull request #1507: [RFC] Add generic serial bus driver

mkiiskila commented on a change in pull request #1507: [RFC] Add generic serial bus driver
URL: https://github.com/apache/mynewt-core/pull/1507#discussion_r233082654
 
 

 ##########
 File path: hw/bus/include/bus/bus.h
 ##########
 @@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef HW_BUS_H_
+#define HW_BUS_H_
+
+#include <stdint.h>
+#include "os/os_dev.h"
+#include "os/os_mutex.h"
+#include "os/os_time.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Flags used for bus operations
+ */
+#define BUS_F_NONE          0
+#define BUS_F_NOSTOP        0x0001
+
+/**
+ * Read data from node
+ *
+ * Reads data from node. Bus is locked automatically for the duration of
+ * operation.
+ *
+ * The timeout parameter applies to complete transaction time, including
+ * locking the bus.
+ *
+ * @param node     Node device object
+ * @param buf      Buffer to read data into
+ * @param length   Length of data to be read
+ * @param timeout  Operation timeout
+ * @param flags    Flags
+ *
+ * @return 0 on success, SYS_xxx on error
+ */
+int
+bus_node_read(struct os_dev *node, uint8_t *buf, uint16_t length,
+              os_time_t timeout, uint16_t flags);
+
+/**
+ * Write data to node
+ *
+ * Writes data to node. Bus is locked automatically for the duration of
+ * operation.
+ *
+ * The timeout parameter applies to complete transaction time, including
+ * locking the bus.
+ *
+ * @param node     Node device object
+ * @param buf      Buffer with data be written
+ * @param length   Length of data to be written
+ * @param timeout  Operation timeout
+ * @param flags    Flags
+ *
+ * @return 0 on success, SYS_xxx on error
+ */
+int
+bus_node_write(struct os_dev *node, uint8_t *buf, uint16_t length,
 
 Review comment:
   And void *buf as the argument. Makes the API easier to use.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services