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.1 2005/11/04 17:59:47 bernie
19 *#* Import into DevLib.
21 *#* Revision 1.3 2005/06/10 08:56:47 batt
22 *#* Avoid calling DEG_T_TO_DEG().
24 *#* Revision 1.2 2005/06/10 08:54:58 batt
25 *#* Rename deg_t conversion macros to accomplish coding standard.
27 *#* Revision 1.1 2005/05/24 09:17:58 batt
28 *#* Move drivers to top-level.
35 #include <cfg/debug.h>
36 #include <cfg/compiler.h>
38 #define NTC_OPEN_CIRCUIT -32768
39 #define NTC_SHORT_CIRCUIT 32767
41 typedef int16_t deg_t; /*! type for celsius degrees deg_t = °C * 10 */
43 /*! Macro for converting from deg to deg_t type */
44 #define DEG_TO_DEG_T(x) ((deg_t)((x) * 10))
46 /*! Macro for converting from deg_t to celsius degrees (returns only the integer part) */
47 #define DEG_T_TO_INTDEG(x) ((x) / 10)
49 /*! Macro for converting from deg_t to celsius degrees (returns only the decimal part) */
50 #define DEG_T_TO_DECIMALDEG(x) ((x) % 10)
52 /*! Macro for converting from deg_t to celsius degrees (returns type is float) */
53 #define DEG_T_TO_FLOATDEG(x) ((x) / 10.0)
56 typedef uint32_t res_t; /*! type for resistor res_t = Ohm * 100 */
57 typedef float amp_t; /*! type for defining amplifications amp_t = A, where A is a pure number */
59 DB(extern bool ntc_initialized;)
62 /*! Describe a NTC chip */
63 typedef struct NtcHwInfo
65 const res_t *resistances; //!< resistances of the NTC (ohms * 100)
66 size_t num_resistances; //!< number of resistances
67 deg_t degrees_min; //!< degrees corresponding to the first entry in the table (celsius * 10)
68 deg_t degrees_step; //!< difference in degrees between two consecutive elements in the table (celsius * 10)
71 /*! Initialize the NTC module */
74 /*! Read a single temperature value from the NTC */
75 deg_t ntc_read(NtcDev dev);
77 #endif /* DRV_NTC_H */