drivers/sensors/adt7320.c: Add support for the ADT7320 temperature sensor.

This commit is contained in:
Augusto Fraga Giachero
2019-08-28 15:35:43 -06:00
committed by Gregory Nutt
parent 53d5e44d89
commit d6ad7ebd47
7 changed files with 823 additions and 1 deletions
+97
View File
@@ -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 */
+5 -1
View File
@@ -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 */