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 2019/05/08 08:02:44 UTC
[GitHub] [mynewt-core] sterlinghughes commented on a change in pull request
#1801: Added support to Infineon DPS368/3xx barometric pressure sensor.
sterlinghughes commented on a change in pull request #1801: Added support to Infineon DPS368/3xx barometric pressure sensor.
URL: https://github.com/apache/mynewt-core/pull/1801#discussion_r281955536
##########
File path: hw/drivers/sensors/dps368/src/dps368.c
##########
@@ -0,0 +1,1048 @@
+/*Copyright 2019 Infineon Technologies AG
+ *
+ * Licensed 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
+ *
+ * https://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.
+ */
+/*
+ * dps368_priv.h
+ *
+ * Created on: Apr 15, 2019
+ * Author: Saumitra Chafekar
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdint.h>
+#include <syscfg/syscfg.h>
+#include <math.h>
+
+#include "sensor/sensor.h"
+#include "sensor/temperature.h"
+#include "sensor/pressure.h"
+
+
+#include "dps368/dps368.h"
+#include "dps368_priv.h"
+
+
+#if !MYNEWT_VAL(BUS_DRIVER_PRESENT)
+static struct hal_spi_settings spi_dps368_settings_s = {
+ .data_order = HAL_SPI_MSB_FIRST,
+ .data_mode = HAL_SPI_MODE3,
+ .baudrate = 4000,
+ .word_size = HAL_SPI_WORD_SIZE_8BIT,
+};
+#endif
+
+/* Exports for the sensor API */
+static int dps368_sensor_read(struct sensor *, sensor_type_t,
+ sensor_data_func_t, void *, uint32_t);
+static int dps368_sensor_get_config(struct sensor *, sensor_type_t,
+ struct sensor_cfg *);
+static int dps368_sensor_set_config(struct sensor *, void *);
+
+static const struct sensor_driver dps368_sensor_driver_s = {
+ .sd_read = dps368_sensor_read,
+ .sd_get_config = dps368_sensor_get_config,
+ .sd_set_config = dps368_sensor_set_config,
+ .sd_reset = dps368_soft_reset,
+};
+
+
+
+/*Local helper functions*/
+
+/**
+ * Verify sensor on bus
+ *
+ * @param The sensor interface
+ * @param ptr to indicate if sensor hw is ready
+ * @return 0 on success, non-zero on failure
+ */
+static int
+dps368_verify_sensor(struct sensor_itf *itf, uint8_t *sensor_exist)
+{
+ int rc;
+ uint8_t hwid;
+
+ rc = dps368_get_hwid(itf,&hwid);
+
+ if (rc) {
+ *sensor_exist = 0;
+ return rc;
+ }
+
+ if (hwid == IFX_DPS368_DEV_PROD_REVID)
Review comment:
need braces around if, even for one-line conditionals per coding standards.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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