4 * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
8 * \brief Driver for NTC (reads a temperature through an ADC)
12 * \author Giovanni Bajo <rasky@develer.com>
13 * \author Francesco Sacchi <batt@develer.com>
18 *#* Revision 1.2 2006/07/19 12:56:26 bernie
19 *#* Convert to new Doxygen style.
21 *#* Revision 1.1 2005/11/04 17:59:47 bernie
22 *#* Import into DevLib.
24 *#* Revision 1.3 2005/06/10 08:56:47 batt
25 *#* Avoid calling DEG_T_TO_DEG().
27 *#* Revision 1.2 2005/06/10 08:54:58 batt
28 *#* Rename deg_t conversion macros to accomplish coding standard.
30 *#* Revision 1.1 2005/05/24 09:17:58 batt
31 *#* Move drivers to top-level.
38 #include <cfg/debug.h>
39 #include <cfg/compiler.h>
41 #define NTC_OPEN_CIRCUIT -32768
42 #define NTC_SHORT_CIRCUIT 32767
44 typedef int16_t deg_t; /** type for celsius degrees deg_t = °C * 10 */
46 /** Macro for converting from deg to deg_t type */
47 #define DEG_TO_DEG_T(x) ((deg_t)((x) * 10))
49 /** Macro for converting from deg_t to celsius degrees (returns only the integer part) */
50 #define DEG_T_TO_INTDEG(x) ((x) / 10)
52 /** Macro for converting from deg_t to celsius degrees (returns only the decimal part) */
53 #define DEG_T_TO_DECIMALDEG(x) ((x) % 10)
55 /** Macro for converting from deg_t to celsius degrees (returns type is float) */
56 #define DEG_T_TO_FLOATDEG(x) ((x) / 10.0)
59 typedef uint32_t res_t; /** type for resistor res_t = Ohm * 100 */
60 typedef float amp_t; /** type for defining amplifications amp_t = A, where A is a pure number */
62 DB(extern bool ntc_initialized;)
65 /** Describe a NTC chip */
66 typedef struct NtcHwInfo
68 const res_t *resistances; ///< resistances of the NTC (ohms * 100)
69 size_t num_resistances; ///< number of resistances
70 deg_t degrees_min; ///< degrees corresponding to the first entry in the table (celsius * 10)
71 deg_t degrees_step; ///< difference in degrees between two consecutive elements in the table (celsius * 10)
74 /** Initialize the NTC module */
77 /** Read a single temperature value from the NTC */
78 deg_t ntc_read(NtcDev dev);
80 #endif /* DRV_NTC_H */