Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/drivers/ADT7420/ADT7420.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file ADT7420.h
3 * @brief Header file of ADT7420 Driver.
4 * @author DBogdan ([email protected])
5 ********************************************************************************
6 * Copyright 2012(c) Analog Devices, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * - Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * - Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 * - The use of this software may or may not infringe the patent rights
22 * of one or more patent holders. This license does not release you
23 * from the requirement that you obtain separate licenses from these
24 * patent holders to use this software.
25 * - Use of the software either in source or binary form, must be run
26 * on or directly connected to an Analog Devices Inc. component.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 ********************************************************************************
40 * SVN Revision: $WCREV$
41 *******************************************************************************/
42 #ifndef __ADT7420_H__
43 #define __ADT7420_H__
44
45 /******************************************************************************/
46 /***************************** Include Files **********************************/
47 /******************************************************************************/
48 #include "Communication.h"
49
50 /******************************************************************************/
51 /************************** ADT7420 Definitions *******************************/
52 /******************************************************************************/
53
54 /* ADT7420 address */
55 #define ADT7420_A0_PIN 1 // I2C Serial Bus Address Selection Pin
56 #define ADT7420_A1_PIN 1 // I2C Serial Bus Address Selection Pin
57 #define ADT7420_ADDRESS (0x48 + (ADT7420_A1_PIN << 1) + ADT7420_A0_PIN)
58
59 /* ADT7420 registers */
60 #define ADT7420_REG_TEMP_MSB 0x00 // Temperature value MSB
61 #define ADT7420_REG_TEMP_LSB 0x01 // Temperature value LSB
62 #define ADT7420_REG_STATUS 0x02 // Status
63 #define ADT7420_REG_CONFIG 0x03 // Configuration
64 #define ADT7420_REG_T_HIGH_MSB 0x04 // Temperature HIGH setpoint MSB
65 #define ADT7420_REG_T_HIGH_LSB 0x05 // Temperature HIGH setpoint LSB
66 #define ADT7420_REG_T_LOW_MSB 0x06 // Temperature LOW setpoint MSB
67 #define ADT7420_REG_T_LOW_LSB 0x07 // Temperature LOW setpoint LSB
68 #define ADT7420_REG_T_CRIT_MSB 0x08 // Temperature CRIT setpoint MSB
69 #define ADT7420_REG_T_CRIT_LSB 0x09 // Temperature CRIT setpoint LSB
70 #define ADT7420_REG_HIST 0x0A // Temperature HYST setpoint
71 #define ADT7420_REG_ID 0x0B // ID
72 #define ADT7420_REG_RESET 0x2F // Software reset
73
74 /* ADT7420_REG_STATUS definition */
75 #define ADT7420_STATUS_T_LOW (1 << 4)
76 #define ADT7420_STATUS_T_HIGH (1 << 5)
77 #define ADT7420_STATUS_T_CRIT (1 << 6)
78 #define ADT7420_STATUS_RDY (1 << 7)
79
80 /* ADT7420_REG_CONFIG definition */
81 #define ADT7420_CONFIG_FAULT_QUEUE(x) (x & 0x3)
82 #define ADT7420_CONFIG_CT_POL (1 << 2)
83 #define ADT7420_CONFIG_INT_POL (1 << 3)
84 #define ADT7420_CONFIG_INT_CT_MODE (1 << 4)
85 #define ADT7420_CONFIG_OP_MODE(x) ((x & 0x3) << 5)
86 #define ADT7420_CONFIG_RESOLUTION (1 << 7)
87
88 /* ADT7420_CONFIG_FAULT_QUEUE(x) options */
89 #define ADT7420_FAULT_QUEUE_1_FAULT 0
90 #define ADT7420_FAULT_QUEUE_2_FAULTS 1
91 #define ADT7420_FAULT_QUEUE_3_FAULTS 2
92 #define ADT7420_FAULT_QUEUE_4_FAULTS 3
93
94 /* ADT7420_CONFIG_OP_MODE(x) options */
95 #define ADT7420_OP_MODE_CONT_CONV 0
96 #define ADT7420_OP_MODE_ONE_SHOT 1
97 #define ADT7420_OP_MODE_1_SPS 2
98 #define ADT7420_OP_MODE_SHUTDOWN 3
99
100 /* ADT7420 default ID */
101 #define ADT7420_DEFAULT_ID 0xCB
102
103 /******************************************************************************/
104 /************************ Functions Declarations ******************************/
105 /******************************************************************************/
106
107 /*! Reads the value of a register. */
108 unsigned char ADT7420_GetRegisterValue(unsigned char registerAddress);
109
110 /*! Sets the value of a register. */
111 void ADT7420_SetRegisterValue(unsigned char registerAddress,
112 unsigned char registerValue);
113
114 /*! Initializes the comm. peripheral and checks if the device is present. */
115 char ADT7420_Init(void);
116
117 /*! Resets the ADT7420. */
118 void ADT7420_Reset(void);
119
120 /*! Sets the operational mode for ADT7420. */
121 void ADT7420_SetOperationMode(unsigned char mode);
122
123 /*! Sets the resolution for ADT7420. */
124 void ADT7420_SetResolution(unsigned char resolution);
125
126 /*! Reads the temperature data and converts it to Celsius degrees. */
127 float ADT7420_GetTemperature(void);
128
129 #endif /* __ADT7420_H__ */