aversive_10-03-12/modules/hardware/adc/adc.c File Reference

#include <stdlib.h>
#include <aversive.h>
#include <adc.h>

Go to the source code of this file.

Functions

void adc_init (void)
void adc_shutdown (void)
void adc_register_event (void(*f)(int16_t))
 SIGNAL (SIG_ADC)
void adc_launch (uint16_t conversion_config)
int16_t adc_get_value (uint16_t conversion_config)
int32_t adc_get_value32 (void *conversion_config)


Function Documentation

int16_t adc_get_value ( uint16_t  conversion_config  ) 

This function gets an ADC value. If a conversion has been previously started, with EXACTLY the same config (or specifying ADC_NO_CONFIG) then it waits for it to finish. Else it launches a new one with the given config, and polls the result.

This function should not be used if you use interrupts, but only can be used with triggered (or free run mode)

Definition at line 176 of file adc.c.

References adc_launch(), ADC_MODE_16_BITS, ADC_NO_CONFIG, ADC_RESULT_SIGNED, ADFR, cbi, and sbi.

Referenced by adc_get_value32().

int32_t adc_get_value32 ( void *  conversion_config  ) 

Just a int32_t version for compatibility with control_system function prototypes.

Definition at line 229 of file adc.c.

References adc_get_value().

void adc_init ( void   ) 

Initialisation of ADC internal registers Can be called for a wake up after a shutdown command

Definition at line 38 of file adc.c.

References ADC_PRESCALE, and cbi.

void adc_launch ( uint16_t  conversion_config  ) 

Launch a conversion : this function launches a conversion with the specified configuration. The conversion_config is casted to an int.

This disables and reenables the ADC when a different channel is selected AND the new channel is a differential one. Using this trick, the ADC recalibrates, and the time for this allows the amplifier to settle.

Datasheet says : When switching to a differential gain channel, the first conversion result may have a poor accuracy due to the required settling time for the automatic offset cancellation circuitry. The user should preferably disregard the first conversion result.

Definition at line 111 of file adc.c.

References ADC_MODE_INT, ADC_MODE_TRIGGERED, ADC_RESULT_SIGNED, ADFR, cbi, MUX5_MASK_IN_CONFIG, and sbi.

Referenced by adc_get_value().

void adc_register_event ( void(*)(int16_t)  f  ) 

Register callback event. The parameter function is called when the conversion is finished.

Definition at line 72 of file adc.c.

References parse_symbols::f, IRQ_LOCK, and IRQ_UNLOCK.

void adc_shutdown ( void   ) 

Shut down the ADC, for power consumption

Definition at line 56 of file adc.c.

References sbi.

SIGNAL ( SIG_ADC   ) 

Interrupt function, other interrupts are disabled during its execution.

Definition at line 85 of file adc.c.

References ADC_MODE_16_BITS, and ADC_RESULT_SIGNED.


Generated on Fri Mar 12 06:32:06 2010 for AVR by  doxygen 1.5.6