Fixed minor issue with the RNDISEthernet demo DHCP protocol decoder routine using...
[pub/USBasp.git] / LUFA / Drivers / Board / Temperature.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Temperature sensor board driver for the USB boards which contain a temperature sensor.
34 */
35
36 #ifndef __TEMPERATURE_H__
37 #define __TEMPERATURE_H__
38
39 /* Macros: */
40 #if !defined(__DOXYGEN__)
41 #define INCLUDE_FROM_BOARD_DRIVER
42 #endif
43
44 /* Includes: */
45 #include <avr/pgmspace.h>
46
47 #include "../AT90USBXXX/ADC.h"
48 #include "../../Common/Common.h"
49
50 #if !defined(BOARD)
51 #error #error BOARD must be set in makefile to a value specified in BoardTypes.h.
52 #elif (BOARD != BOARD_USBKEY) && (BOARD != BOARD_STK525) && (BOARD != BOARD_STK526)
53 #error The selected board does not contain a temperature sensor.
54 #endif
55
56 /* Enable C linkage for C++ Compilers: */
57 #if defined(__cplusplus)
58 extern "C" {
59 #endif
60
61 /* Public Interface - May be used in end-application: */
62 /* Macros: */
63 /** ADC channel number for the temperature sensor. */
64 #define TEMP_ADC_CHANNEL 0
65
66 /** Minimum returnable temperature from the Temperature_GetTemperature() function. */
67 #define TEMP_MIN_TEMP TEMP_TABLE_OFFSET
68
69 /** Maximum returnable temperature from the Temperature_GetTemperature() function. */
70 #define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET)
71
72 /** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.
73 * This must be called before any other temperature sensor routines.
74 *
75 * The ADC itself (not the ADC channel) must be configured separately before calling the temperature
76 * sensor functions.
77 */
78 #define Temperature_Init() ADC_SetupChannel(TEMP_ADC_CHANNEL);
79
80 /* Function Prototypes: */
81 /** Performs a complete ADC on the temperature sensor channel, and converts the result into a
82 * valid temperature between TEMP_MIN_TEMP and TEMP_MAX_TEMP in degrees Celsius.
83 *
84 * \return Signed temperature in degrees Celsius
85 */
86 int8_t Temperature_GetTemperature(void) ATTR_WARN_UNUSED_RESULT;
87
88 /* Private Interface - For use in library only: */
89 #if !defined(__DOXYGEN__)
90 /* Macros: */
91 #define TEMP_TABLE_SIZE (sizeof(Temperature_Lookup) / sizeof(Temperature_Lookup[0]))
92 #define TEMP_TABLE_OFFSET -21
93 #endif
94
95 /* Disable C linkage for C++ Compilers: */
96 #if defined(__cplusplus)
97 }
98 #endif
99
100 #endif