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

 ##########
 File path: hw/bus/spi/include/bus/spi.h
 ##########
 @@ -0,0 +1,116 @@
+/*
+ * 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_SPI_H_
+#define HW_BUS_SPI_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include "bus/bus.h"
+#include "bus/bus_driver.h"
+#include "bus/bus_debug.h"
+#include "hal/hal_spi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bus_spi_dev_cfg {
+    int spi_num;
+    int pin_sck;
+    int pin_mosi;
+    int pin_miso;
+};
+
+struct bus_spi_dev {
+    struct bus_dev bdev;
+    struct bus_spi_dev_cfg cfg;
+
+#if MYNEWT_VAL(BUS_DEBUG)
+    uint32_t devmagic;
+#endif
+};
+
+#define BUS_SPI_MODE_0              (HAL_SPI_MODE0)
+#define BUS_SPI_MODE_1              (HAL_SPI_MODE1)
+#define BUS_SPI_MODE_2              (HAL_SPI_MODE2)
+#define BUS_SPI_MODE_3              (HAL_SPI_MODE3)
+
+#define BUS_SPI_DATA_ORDER_LSB      (HAL_SPI_LSB_FIRST)
+#define BUS_SPI_DATA_ORDER_MSB      (HAL_SPI_MSB_FIRST)
+
+struct bus_spi_node_cfg {
+    /** General node configuration */
+    struct bus_node_cfg node_cfg;
+    /** */
+    uint8_t pin_cs;
+    /** Data mode */
+    uint8_t mode;
+    /** Data order */
+    uint8_t data_order;
+    /** SCK frequency to be used for node */
+    uint16_t freq;
+    /** Quirks to be applied for device */
+    uint16_t quirks;
+};
+
+struct bus_spi_node {
+    struct bus_node bnode;
+    uint8_t pin_cs;
 
 Review comment:
   maybe int would be better

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to