mirror of
https://github.com/apache/nuttx.git
synced 2026-09-21 05:14:27 +08:00
drivers/sensors/adt7320.c: Add support for the ADT7320 temperature sensor.
This commit is contained in:
committed by
Gregory Nutt
parent
53d5e44d89
commit
d6ad7ebd47
@@ -807,3 +807,10 @@ config XEN1210_REGDEBUG
|
||||
config SENSORS_ZEROCROSS
|
||||
bool "Zero Cross Sensor"
|
||||
default n
|
||||
|
||||
config SENSORS_ADT7320
|
||||
bool "Analog Devices ADT7320 Driver"
|
||||
default n
|
||||
select SPI
|
||||
---help---
|
||||
Enables support for the ADT7320 Driver
|
||||
|
||||
@@ -248,6 +248,10 @@ ifeq ($(CONFIG_SENSORS_L3GD20),y)
|
||||
CSRCS += l3gd20.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_ADT7320),y)
|
||||
CSRCS += adt7320.c
|
||||
endif
|
||||
|
||||
endif # CONFIG_SPI
|
||||
|
||||
# Quadrature encoder upper half
|
||||
|
||||
@@ -462,3 +462,9 @@ shared worker task that collects the data.
|
||||
|
||||
The cluster driver close() function calls the close functions of the leaf
|
||||
drivers.
|
||||
|
||||
ADT7320 (Augusto Fraga Giachero)
|
||||
=======
|
||||
|
||||
The ADT7320 is a SPI temperature sensor with a temperature range of
|
||||
−40°C to +150°C.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
* drivers/sensors/adt7320.h
|
||||
*
|
||||
* Copyright (C) 2019, Augusto Fraga Giachero. All rights reserved.
|
||||
* Author: Augusto Fraga Giachero <afg@augustofg.net>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __DRIVERS_SENSORS_ADT7320_H
|
||||
#define __DRIVERS_SENSORS_ADT7320_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ADT7320_STAT_REG 0x00
|
||||
#define ADT7320_CONF_REG 0x01
|
||||
#define ADT7320_TEMP_REG 0x02
|
||||
#define ADT7320_ID_REG 0x03
|
||||
#define ADT7320_TCRIT_REG 0x04
|
||||
#define ADT7320_THYST_REG 0x05
|
||||
#define ADT7320_THIGH_REG 0x06
|
||||
#define ADT7320_TLOW_REG 0x07
|
||||
|
||||
#define ADT7320_ID 0xc3
|
||||
|
||||
#endif /* __DRIVERS_SENSORS_ADT7320_H */
|
||||
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/adt7320.h
|
||||
*
|
||||
* Copyright (C) 2019 Augusto Fraga Giachero
|
||||
* Author: Augusto Fraga Giachero <afg@augustofg.net>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SENSORS_ADT7320_H
|
||||
#define __INCLUDE_NUTTX_SENSORS_ADT7320_H
|
||||
|
||||
/****************************************************************************
|
||||
* Driver usage notes:
|
||||
*
|
||||
* This driver supports the Common Sensor Register Interface.
|
||||
* See drivers/sensors/README.txt for details.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/sensors/ioctl.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_ADT7320)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adt7320_register
|
||||
*
|
||||
* Description:
|
||||
* Register the ADT7320 character device as 'devpath'
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/temp0"
|
||||
* spi - An instance of the SPI interface to use to communicate with
|
||||
* spidev - Number of the spi device (used to determine what chip
|
||||
* should be selected).
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int adt7320_register(FAR const char *devpath,
|
||||
FAR struct spi_dev_s *spi,
|
||||
int spidev);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SPI && CONFIG_SENSORS_ADT7320 && CONFIG_SPI_EXCHANGE */
|
||||
#endif /* __INCLUDE_NUTTX_SENSORS_ADT7320_H */
|
||||
@@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* include/nuttx/sensors/ioctl.h
|
||||
*
|
||||
* Copyright (C) 2016-2018 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -210,6 +210,10 @@
|
||||
#define SNIOC_SET_CLEAN_INTERVAL _SNIOC(0x005d) /* Arg: uint32_t value (seconds) */
|
||||
#define SNIOC_START_FAN_CLEANING _SNIOC(0x005e) /* Arg: None */
|
||||
|
||||
/* IOCTL commands unique to the ADT7320 */
|
||||
|
||||
#define SNIOC_READSTAT _SNIOC(0x005f) /* Arg: uint8_t* pointer */
|
||||
|
||||
/* IOCTL commands unique to the VL53L1X */
|
||||
|
||||
#define SNIOC_DISTANCESHORT _SNIOC(0x0100) /* Arg: None */
|
||||
|
||||
Reference in New Issue
Block a user