LUFA Library  120219
Temperature Sensor Driver - LUFA/Drivers/Board/Temperature.h

NTC Temperature Sensor board hardware driver. More...


#define TEMP_ADC_CHANNEL   0
#define TEMP_TABLE_SIZE   120


static void Temperature_Init (void) ATTR_ALWAYS_INLINE
int8_t Temperature_GetTemperature (void) ATTR_WARN_UNUSED_RESULT

Detailed Description

Module Source Dependencies

The following files must be built with any user project that uses this module:

Module Description

Temperature sensor driver. This provides an easy to use interface for the hardware temperature sensor located on many boards. It provides an interface to configure the sensor and appropriate ADC channel, plus read out the current temperature in degrees C. It is designed for and will only work with the temperature sensor located on the official Atmel USB AVR boards, as each sensor has different characteristics.

Example Usage

The following snippet is an example of how this module may be used within a typical application.

      // Initialize the ADC and board temperature sensor drivers before first use

      // Display converted temperature in degrees Celsius
      printf("Current Temperature: %d Degrees\r\n", Temperature_GetTemperature());

Define Documentation

#define TEMP_ADC_CHANNEL   0

ADC channel number for the temperature sensor.

ADC channel MUX mask for the temperature sensor.


Maximum returnable temperature from the Temperature_GetTemperature() function.


Minimum returnable temperature from the Temperature_GetTemperature() function.

#define TEMP_TABLE_SIZE   120

Size of the temperature sensor lookup table, in lookup values

Function Documentation

int8_t Temperature_GetTemperature ( void  )

Performs a complete ADC on the temperature sensor channel, and converts the result into a valid temperature between TEMP_MIN_TEMP and TEMP_MAX_TEMP in degrees Celsius.

Signed temperature value in degrees Celsius.
static void Temperature_Init ( void  ) [inline, static]

Initializes the temperature sensor driver, including setting up the appropriate ADC channel. This must be called before any other temperature sensor routines.

The ADC itself (not the ADC channel) must be configured separately before calling the temperature sensor functions.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines