Atmel Software Framework

adc_sensors.h File Reference

ADC Sensor interface.

Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.

#include "adc.h"

Functions

void adc_handler (ADC_t *adc, uint8_t channel, adc_result_t result)
 Callback for the ADC conversion complete. More...
 
void adc_sensors_init (void)
 Initialize ADC channels for NTC and lightsensor. More...
 
bool lightsensor_data_is_ready (void)
 
int16_t lightsensor_get_raw_value (void)
 Read the lightsensor value from the ADC. More...
 
static void lightsensor_measure (void)
 
bool ntc_data_is_ready (void)
 Check of there is NTC data ready to be read. More...
 
int16_t ntc_get_raw_value (void)
 Read the NTC value from the ADC. More...
 
int8_t ntc_get_temperature (void)
 Read the actual temperature from the NTC. More...
 
static void ntc_measure (void)
 Call this to schedule a ADC reading of the temperature sensor. More...
 

void adc_handler ( ADC_t *  adc,
uint8_t  ch_mask,
adc_result_t  result 
)

Callback for the ADC conversion complete.

The ADC module will call this function on a conversion complete.

Parameters
adcthe ADC from which the interrupt came
ch_maskthe ch_mask that produced the interrupt
resultthe result from the ADC

References ADC_CH0, ADC_CH1, light_sensor_data_ready, LIGHT_SENSOR_MAX_SAMPLES, light_sensor_sample, lightsensor_measure(), ntc_measure(), ntc_sensor_data_ready, NTC_SENSOR_MAX_SAMPLES, ntc_sensor_sample, and result.

bool lightsensor_data_is_ready ( void  )
int16_t lightsensor_get_raw_value ( void  )

Read the lightsensor value from the ADC.

This will read the ADC value of the channel and pin connected to the lightsensor on the A3BU-Xplained.

Return values
theraw ADC value from the current ntc_sensor_sample

References light_sensor_sample.

Referenced by lightsensor_application().

static void lightsensor_measure ( void  )
inlinestatic
bool ntc_data_is_ready ( void  )

Check of there is NTC data ready to be read.

When data is ready to be read this function will return true, and assume that the data is going to be read so it sets the ready flag to false.

Return values
trueif the NTC value is ready to be read
falseif data is not ready yet

References cpu_irq_restore(), cpu_irq_save(), and ntc_sensor_data_ready.

Referenced by ntc_sensor_application().

int16_t ntc_get_raw_value ( void  )

Read the NTC value from the ADC.

This will read the ADC value of the channel and pin connected to the NTC on the A3BU-Xplained.

Return values
theraw ADC value from the current ntc_sensor_sample

References ntc_sensor_sample.

int8_t ntc_get_temperature ( void  )

Read the actual temperature from the NTC.

This function returns the temperature in Celsius by piecewise linearisation of the complex transfer function between NTC resistance and ADC codes. The accuracy of the temperature is somewhat limited.

Note
The result is inaccurate for temperatures outside 5-45 degrees.
Return values
thetemperature in Celsius

References ntc_sensor_sample.

Referenced by ntc_sensor_application().

static void ntc_measure ( void  )
inlinestatic

Call this to schedule a ADC reading of the temperature sensor.

Calling this will trigger the ADC to perform a reading of the on board NTC, the ADC will automatically recall this function the number of times specified for averaging.

References ADC_CH1, and adc_start_conversion().

Referenced by adc_handler(), and ntc_sensor_application().