ADC_task.h

Go to the documentation of this file.
00001 /*
00002 **
00003 ****************************************************************************
00004 **
00005 **
00006 **             Copyright (c) 2007 - Atmel Corporation
00007 **             Proprietaty Information
00008 **
00009 ** Project     : ATMEGA88 + ATA6824 High Temperature H-bridge System
00010 ** Module      : ADC_task.h
00011 ** Description : Header file
00012 **                Manage ADC to acquire Current (VSHUNT) Supply voltage (Vbat)
00013 **                and Speed set
00014 **
00015 ** Version :     Date:         Author:      Comment:
00016 **    1.0        24.01.2007    F.G.          Creation 
00017 **
00018 ** LICENSE -
00019 **
00020 ** ATMEL - 2007
00021 ** All software programs are provided 'as is' without warranty of any kind:
00022 ** Atmel does not state the suitability of the provided materials for any
00023 ** purpose. Atmel hereby disclaim all warranties and conditions with regard
00024 ** to the provided software, including all implied warranties, fitness for
00025 ** a particular purpose, title and non-infringement.In no event will Atmel
00026 ** be liable for any indirect or consequential damages or any damages
00027 ** whatsoever resulting from the usage of the software program.
00028 ****************************************************************************
00029 **
00030 */
00031 
00032 #ifndef ADC_TASK_H
00033 #define ADC_TASK_H
00034 
00035 /*_____ I N C L U D E S ____________________________________________________*/
00036 
00037 /*_____ M A C R O S ________________________________________________________*/
00038 
00040 #define Set_ADC_Channel(Channel) (ADMUX &= ( (1<<REFS1) | (1<<REFS0) | (1<<ADLAR)), \
00041                                  ADMUX |=  Channel & ((1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (1<<MUX0)))
00043 #define ADC_start_conv()         (ADCSRA |= (1<<ADSC))
00044 
00046 #define ADC_end_conv()           ((ADCSRA & (1<<ADIF)) == (1<<ADIF)) 
00047 
00049 #define ADC_clear_end_conv_flag() (ADCSRA |= (1<<ADIF))  
00050 
00052 #define ADC_data_reg()            (ADC)
00053 
00054 
00055 /*_____ D E F I N I T I O N S ______________________________________________*/
00058 typedef enum                    
00059 {
00060   ADC_INIT_TASK,                
00061   ADC_WAIT_CURRENT_MEAS,        
00062   ADC_WAIT_SPEED_SET_MEAS,      
00063   ADC_WAIT_VBAT_MEAS,           
00064 }ADC_state_t;           // ADC conversions state machine type definition
00065 
00066 
00067 // @defgroup ADC_channels ADC channels definitions
00068 // @{
00069 #define   ADC0                    0x00
00070 #define   ADC1                    (                         (1<<MUX0) )
00071 #define   ADC2                    (             (1<<MUX1)             )
00072 #define   ADC3                    (             (1<<MUX1) | (1<<MUX0) )
00073 #define   ADC4                    ((1<<MUX2)                          )
00074 #define   ADC5                    ((1<<MUX2)              | (1<<MUX0) )
00075 #define   ADC6                    ((1<<MUX2) |  (1<<MUX1)             )
00076 #define   ADC7                    ((1<<MUX2) |  (1<<MUX1) | (1<<MUX0) )
00077 // @}
00078 
00079 
00080 /*_____ G L O B A L S ______________________________________________________*/
00081 
00082 /*_____ P R O T O T Y P E S - D E C L A R A T I O N ________________________*/
00083 
00084 void ADC_Init(void);                          // ADC initialization
00085 void ADC_task(void);                          // Manages ADC acquisitions
00086 unsigned int adc_get_speed(void);             // Returns speed set value
00087 unsigned int adc_get_current(void);           // Returns measured current
00088 unsigned int adc_get_V_bat(void);             // Returns measured V_bat
00089 #endif //ADC_TASK_H

Generated on Wed Mar 14 10:53:31 2007 for Mega88_&_ATA6824_High_temperature_H-Bridge_system by  doxygen 1.4.7