4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
30 * All Rights Reserved.
33 * \brief Driver for NTC (reads a temperature through an ADC)
37 * \author Giovanni Bajo <rasky@develer.com>
38 * \author Francesco Sacchi <batt@develer.com>
43 *#* Revision 1.2 2006/07/19 12:56:26 bernie
44 *#* Convert to new Doxygen style.
46 *#* Revision 1.1 2005/11/04 17:59:47 bernie
47 *#* Import into DevLib.
49 *#* Revision 1.3 2005/06/10 08:56:47 batt
50 *#* Avoid calling DEG_T_TO_DEG().
52 *#* Revision 1.2 2005/06/10 08:54:58 batt
53 *#* Rename deg_t conversion macros to accomplish coding standard.
55 *#* Revision 1.1 2005/05/24 09:17:58 batt
56 *#* Move drivers to top-level.
63 #include <cfg/debug.h>
64 #include <cfg/compiler.h>
66 #define NTC_OPEN_CIRCUIT -32768
67 #define NTC_SHORT_CIRCUIT 32767
69 typedef int16_t deg_t; /** type for celsius degrees deg_t = °C * 10 */
71 /** Macro for converting from deg to deg_t type */
72 #define DEG_TO_DEG_T(x) ((deg_t)((x) * 10))
74 /** Macro for converting from deg_t to celsius degrees (returns only the integer part) */
75 #define DEG_T_TO_INTDEG(x) ((x) / 10)
77 /** Macro for converting from deg_t to celsius degrees (returns only the decimal part) */
78 #define DEG_T_TO_DECIMALDEG(x) ((x) % 10)
80 /** Macro for converting from deg_t to celsius degrees (returns type is float) */
81 #define DEG_T_TO_FLOATDEG(x) ((x) / 10.0)
84 typedef uint32_t res_t; /** type for resistor res_t = Ohm * 100 */
85 typedef float amp_t; /** type for defining amplifications amp_t = A, where A is a pure number */
87 DB(extern bool ntc_initialized;)
90 /** Describe a NTC chip */
91 typedef struct NtcHwInfo
93 const res_t *resistances; ///< resistances of the NTC (ohms * 100)
94 size_t num_resistances; ///< number of resistances
95 deg_t degrees_min; ///< degrees corresponding to the first entry in the table (celsius * 10)
96 deg_t degrees_step; ///< difference in degrees between two consecutive elements in the table (celsius * 10)
99 /** Initialize the NTC module */
102 /** Read a single temperature value from the NTC */
103 deg_t ntc_read(NtcDev dev);
105 #endif /* DRV_NTC_H */