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

Interface of the ADC Module. More...

#include <aversive.h>
#include <adc_archs.h>
#include <adc_config.h>

Go to the source code of this file.

Defines

#define ADC_MODE_INT   0x0200
#define ADC_MODE_TRIGGERED   0x0400
#define ADC_MODE_10_BITS   0
#define ADC_MODE_16_BITS   ADLAR_MASK_IN_CONFIG
#define ADC_RESULT_SIGNED   0x1000
#define ADC_NO_CONFIG   0xFFFF

Functions

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


Detailed Description

Interface of the ADC Module.

Todo:
some ATtiny support to add
Test:
nothing done
This module provides access to the built-in ADC unit of the AVR uCs.

Definition in file adc.h.


Define Documentation

#define ADC_MODE_10_BITS   0

Definition at line 102 of file adc.h.

#define ADC_MODE_16_BITS   ADLAR_MASK_IN_CONFIG

Definition at line 103 of file adc.h.

Referenced by adc_get_value(), and SIGNAL().

#define ADC_MODE_INT   0x0200

Set this flag for using interruptions instead of polling. If you use this, do not call the adc_get_value() function !

Definition at line 79 of file adc.h.

Referenced by adc_launch().

#define ADC_MODE_TRIGGERED   0x0400

Flag for triggered mode.

Definition at line 84 of file adc.h.

Referenced by adc_launch().

#define ADC_NO_CONFIG   0xFFFF

This specifies a conversion with no config (uses the previous parameters) always use this flag alone !!

Definition at line 116 of file adc.h.

Referenced by adc_get_value().

#define ADC_RESULT_SIGNED   0x1000

this flag is used internally of the module, use it only if you set manually a differential channel.

Definition at line 109 of file adc.h.

Referenced by adc_get_value(), adc_launch(), and SIGNAL().


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.


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