xiaoxiang781216 commented on code in PR #10864:
URL: https://github.com/apache/nuttx/pull/10864#discussion_r1348456190


##########
drivers/sensors/max31865.c:
##########
@@ -0,0 +1,334 @@
+/****************************************************************************
+ * drivers/sensors/max31865.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Character driver for the Maxim MAX31865 Thermocouple-to-Digital Converter
+ *
+ * NOTE: Some Maxim MAX31865 chips have an issue it report value 25% lower
+ * of real temperature, for more info read this thread:
+ * http://www.eevblog.com/forum/projects/max31865-temperature-error/
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <fixedmath.h>
+#include <assert.h>
+#include <errno.h>
+#include <debug.h>
+#include <math.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/fs/fs.h>
+#include <nuttx/spi/spi.h>
+#include <nuttx/sensors/max31865.h>
+#include <nuttx/random.h>
+#include <sys/endian.h>
+
+#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MAX31865)
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private
+ ****************************************************************************/
+
+#define MAX31865_CONFIG_REG             0x00
+# define MAX31865_BIAS_ON               (1 << 7)
+# define MAX31865_AUTO_CONVERSION       (1 << 6)
+# define MAX31865_ONE_SHOT              (1 << 5)
+# define MAX31865_3WIRE                 (1 << 4)
+# define MAX31865_FAULT_DET_OFFSET      (2)
+#  define MAX31865_FAULT_DET_MASK       (3 << MAX31865_FAULT_DET_OFFSET)
+#  define MAX31865_FAULT_DET_OFF        (0 << MAX31865_FAULT_DET_OFFSET)
+#  define MAX31865_FAULT_DET_AUTO       (1 << MAX31865_FAULT_DET_OFFSET)
+#  define MAX31865_FAULT_DET_1CYCLE     (2 << MAX31865_FAULT_DET_OFFSET)
+#  define MAX31865_FAULT_DET_2CYCLE     (3 << MAX31865_FAULT_DET_OFFSET)
+# define MAX31865_FAULT_STATUS_CLR      (1 << 1)
+# define MAX31865_50HZ_FILTER           (1 << 0)
+
+#define MAX31865_RTDMSB_REG             0x01
+#define MAX31865_RTDLSB_REG             0x02
+#define MAX31865_HFAULTMSB_REG          0x03
+#define MAX31865_HFAULTLSB_REG          0x04
+#define MAX31865_LFAULTMSB_REG          0x05
+#define MAX31865_LFAULTLSB_REG          0x06
+#define MAX31865_FAULTSTAT_REG          0x07
+
+#define MAX31865_REF_RESISTOR           430
+
+#define MAX31865_WRITE                  0x80
+
+#define RTD_A                           (3.9083e-3)
+#define RTD_B                           (-5.775e-7)
+
+struct max31865_dev_s
+{
+  FAR struct spi_dev_s *spi; /* Saved SPI driver instance */
+  int16_t temp;
+  uint16_t devid; /* Select minor device number */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static void max31865_lock(FAR struct spi_dev_s *spi);
+static void max31865_unlock(FAR struct spi_dev_s *spi);
+
+/* Character driver methods */
+
+static int max31865_open(FAR struct file *filep);
+
+static ssize_t max31865_read(FAR struct file *filep, FAR char *buffer,
+                             size_t buflen);
+static ssize_t max31865_write(FAR struct file *filep, FAR const char *buffer,
+                              size_t buflen);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct file_operations g_max31865fops =
+    {
+        max31865_open,  /* open */

Review Comment:
   fix the alignment



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to