AVRCpp::AnalogToDigital Namespace Reference

Analog to digital converter. More...


Classes

struct  ConversionCompleteInterrupt

Typedefs

typedef _ADC Result

Enumerations

enum  Reference {
  AREF = 0x00,
  AVCC = 0x40,
  Internal1V = 0x80,
  InternalRef = 0x80 | 0x40
}
enum  Adjustment {
  AlignRight = 0x00,
  AlignLeft = 0x20
}
enum  InterruptEnableFlag {
  InterruptEnable = 0x8,
  InterruptDisable = 0x00
}
enum  EnableFlag {
  ADCEnable = 0x80,
  ADCDisable = 0x00
}
enum  ConversionStart {
  StartNow = 0x40,
  StartLater = 0x00
}
enum  FreeRunning {
  FreeRunMode = 0x20,
  FreeRunStopped = 0x00
}
enum  Prescaler {
  Div2 = 0x01,
  Div4 = 0x02,
  Div8 = 0x03,
  Div16 = 0x04,
  Div32 = 0x05,
  Div64 = 0x06,
  Div128 = 0x07
}
enum  AnalogChannel {
  ADC0 = 0x00,
  ADC1 = 0x01,
  ADC2 = 0x02,
  ADC3 = 0x03,
  ADC4 = 0x04,
  ADC5 = 0x05,
  ADC6 = 0x06,
  ADC7 = 0x07,
  Vbandgap = 0x1E,
  GND = 0x1F
}
enum  Gain {
  Gain1x = 0x10,
  Gain10x = 0x08,
  Gain200x = 0x0a
}
enum  AutoTriggerSource {
  FreeRunningMode = 0x00,
  AnalogComparator = 0x01,
  ExternalInterruptRequest0 = 0x02,
  Counter0CompareMatch = 0x03,
  Counter0Overflow = 0x04,
  Counter1CompareMatchB = 0x05,
  Counter1Overflow = 0x06,
  Counter1CaptureEvent = 0x07
}

Functions

bool IsConverting ()
void WaitWhileConverting ()
void EnsureChangeSafety ()
void SelectionSetUp (Reference reference, Adjustment adjustment, AnalogChannel channel)
void ControlSetUp (EnableFlag enableFlag, ConversionStart conversionStart, FreeRunning freeRunning, InterruptEnableFlag interruptEnableFlag, Prescaler prescaler)
void SetChannel (AnalogChannel channel)
void SelectPrescaler (Prescaler prescaler)
void Enable ()
void Disable ()
bool IsEnabled ()
void StartConversion ()
void SetDifferentialChannels (AnalogChannel positive, AnalogChannel negative, Gain gain)
void EnableAutoTrigger ()
void DisableAutoTrigger ()
bool IsAutoTriggerEnabled ()
void SetAutoTriggerSource (AutoTriggerSource source)
void EnableFreeRun ()
void DisableFreeRun ()
bool IsFreeRunEnabled ()
void StartFreeRun ()
void StopFreeRun ()
void DigitalInputDisable (uint8_t pins)
 Disables the digital input buffers of the pins specified.
void DigitalInputEnable (uint8_t pins)
 Enables the digital input buffers for the specified pins.
void SetDigitalInput (uint8_t pins)
 Enables the digital input buffers for the specified pins, disables for others.


Detailed Description

Analog to digital converter.

Typedef Documentation

typedef _ADC AVRCpp::AnalogToDigital::Result

Definition at line 88 of file ADC.h.


Enumeration Type Documentation

enum AVRCpp::AnalogToDigital::Adjustment

Enumerator:
AlignRight 
AlignLeft 

Definition at line 114 of file ADC.h.

00115                 {
00116                         AlignRight      = 0x00,
00117                         AlignLeft       = _ADLAR
00118                         
00119                 }; // enum Adjustment

enum AVRCpp::AnalogToDigital::AnalogChannel

Enumerator:
ADC0 
ADC1 
ADC2 
ADC3 
ADC4 
ADC5 
ADC6 
ADC7 
Vbandgap 
GND 

Definition at line 164 of file ADC.h.

00165                 {
00166                         ADC0            = 0x00,
00167                         ADC1            = 0x01,
00168                         ADC2            = 0x02,
00169                         ADC3            = 0x03,
00170                         ADC4            = 0x04,
00171                         ADC5            = 0x05,
00172                         ADC6            = 0x06,
00173                         ADC7            = 0x07,
00174                         Vbandgap        = 0x1E,
00175                         GND                     = 0x1F
00176                         
00177                 }; // enum AnalogChannel

enum AVRCpp::AnalogToDigital::AutoTriggerSource

Enumerator:
FreeRunningMode 
AnalogComparator 
ExternalInterruptRequest0 
Counter0CompareMatch 
Counter0Overflow 
Counter1CompareMatchB 
Counter1Overflow 
Counter1CaptureEvent 

Definition at line 209 of file ADC.h.

00210                 {
00211                         FreeRunningMode                         = 0x00,
00212                         AnalogComparator                        = 0x01,
00213                         ExternalInterruptRequest0       = 0x02,
00214                         Counter0CompareMatch            = 0x03,
00215                         Counter0Overflow                        = 0x04,
00216                         Counter1CompareMatchB           = 0x05,
00217                         Counter1Overflow                        = 0x06,
00218                         Counter1CaptureEvent            = 0x07
00219                         
00220                 }; // enum AutoTriggerSource

enum AVRCpp::AnalogToDigital::ConversionStart

Enumerator:
StartNow 
StartLater 

Definition at line 135 of file ADC.h.

00136                 {
00137                         StartNow        = _ADSC,
00138                         StartLater      = 0x00
00139                         
00140                 }; // enum ConversionStart

enum AVRCpp::AnalogToDigital::EnableFlag

Enumerator:
ADCEnable 
ADCDisable 

Definition at line 128 of file ADC.h.

00129                 {
00130                         ADCEnable       = _ADEN,
00131                         ADCDisable      = 0x00
00132                         
00133                 }; // enum EnableFlag

enum AVRCpp::AnalogToDigital::FreeRunning

Enumerator:
FreeRunMode 
FreeRunStopped 

Definition at line 142 of file ADC.h.

00143                 {
00144                         FreeRunMode             = 0x20,
00145                         FreeRunStopped  = 0x00
00146                         
00147                 }; // enum FreeRunning

enum AVRCpp::AnalogToDigital::Gain

Enumerator:
Gain1x 
Gain10x 
Gain200x 

Definition at line 179 of file ADC.h.

00180                 {
00181                         Gain1x          = 0x10,
00182                         Gain10x         = 0x08,
00183                         Gain200x        = 0x0a
00184 
00185                 }; // enum Gain

enum AVRCpp::AnalogToDigital::InterruptEnableFlag

Enumerator:
InterruptEnable 
InterruptDisable 

Definition at line 121 of file ADC.h.

00122                 {
00123                         InterruptEnable = _ADIE,
00124                         InterruptDisable = 0x00
00125                         
00126                 }; // enum InterruptEnableFlag

enum AVRCpp::AnalogToDigital::Prescaler

Enumerator:
Div2 
Div4 
Div8 
Div16 
Div32 
Div64 
Div128 

Definition at line 149 of file ADC.h.

00150                 {
00151                         Div2    = 0x01,
00152                         Div4    = 0x02,
00153                         Div8    = 0x03,
00154                         Div16   = 0x04,
00155                         Div32   = 0x05,
00156                         Div64   = 0x06,
00157                         Div128  = 0x07
00158                         
00159                 }; // enum Prescaler

enum AVRCpp::AnalogToDigital::Reference

Enumerator:
AREF 
AVCC 
Internal1V 
InternalRef 

Definition at line 92 of file ADC.h.

00093                 {
00094                         AREF            = 0x00,
00095                         AVCC            = _REFS0,
00096                         Internal1V      = _REFS1,
00097                         InternalRef     = _REFS1 | _REFS0
00098                         
00099                 }; // enum Reference


Function Documentation

void AVRCpp::AnalogToDigital::ControlSetUp ( EnableFlag  enableFlag,
ConversionStart  conversionStart,
FreeRunning  freeRunning,
InterruptEnableFlag  interruptEnableFlag,
Prescaler  prescaler 
) [inline]

Definition at line 248 of file ADC.h.

00254                 {
00255                         ADCSRA = enableFlag
00256                                         | conversionStart
00257                                         | freeRunning
00258                                         | interruptEnableFlag
00259                                         | prescaler;
00260                         
00261                 } // ControlSetUp

void AVRCpp::AnalogToDigital::DigitalInputDisable ( uint8_t  pins  )  [inline]

Disables the digital input buffers of the pins specified.

It is used to reduce power consumption in the digital input buffer because you do not need digital input buffers when you use these pins as an analog input port. Note that ADC7 and ADC6 do not have digital inputs, so for example the instruction DigitalInputDisable(ADC7 | ADC6 | ADC5) only switches off the fifth pin's buffer.

Definition at line 347 of file ADC.h.

00347 { SetBits<_DIDR0>(pins); }

void AVRCpp::AnalogToDigital::DigitalInputEnable ( uint8_t  pins  )  [inline]

Enables the digital input buffers for the specified pins.

Definition at line 349 of file ADC.h.

00349 { ClearBits<_DIDR0>(pins); }

void AVRCpp::AnalogToDigital::Disable (  )  [inline]

Definition at line 280 of file ADC.h.

00280 { ClearBits<_ADCSRA>(_ADEN); }

void AVRCpp::AnalogToDigital::DisableAutoTrigger (  )  [inline]

Definition at line 315 of file ADC.h.

00315 { ClearBits<_ADCSRA>(_ADATE); }

void AVRCpp::AnalogToDigital::DisableFreeRun (  )  [inline]

Definition at line 321 of file ADC.h.

00321 { DisableAutoTrigger(); }

void AVRCpp::AnalogToDigital::Enable (  )  [inline]

Definition at line 279 of file ADC.h.

00279 { SetBits<_ADCSRA>(_ADEN); }

void AVRCpp::AnalogToDigital::EnableAutoTrigger (  )  [inline]

Definition at line 314 of file ADC.h.

00314 { SetBits<_ADCSRA>(_ADATE); }

void AVRCpp::AnalogToDigital::EnableFreeRun (  )  [inline]

Definition at line 320 of file ADC.h.

void AVRCpp::AnalogToDigital::EnsureChangeSafety (  )  [inline]

Definition at line 229 of file ADC.h.

00230                 {
00231                         if (IsConverting() )
00232                                 Assembler::NOP();
00233                         
00234                 } // EnsureChangeSafety

bool AVRCpp::AnalogToDigital::IsAutoTriggerEnabled (  )  [inline]

Definition at line 316 of file ADC.h.

00316 { return IsBitsSet<_ADCSRA>(_ADATE); }

bool AVRCpp::AnalogToDigital::IsConverting (  )  [inline]

Definition at line 226 of file ADC.h.

00226 { return IsBitsSet<_ADCSRA>(_ADSC); }

bool AVRCpp::AnalogToDigital::IsEnabled (  )  [inline]

Definition at line 281 of file ADC.h.

00281 { return IsBitsSet<_ADCSRA>(_ADEN); }

bool AVRCpp::AnalogToDigital::IsFreeRunEnabled (  )  [inline]

Definition at line 322 of file ADC.h.

00322 { return !IsBitsSet<_ADCSRB>(_ADTS2 | _ADTS1 | _ADTS0); }

void AVRCpp::AnalogToDigital::SelectionSetUp ( Reference  reference,
Adjustment  adjustment,
AnalogChannel  channel 
) [inline]

Definition at line 237 of file ADC.h.

00241                 {
00242                         EnsureChangeSafety();
00243                         ADMUX = reference | adjustment | channel;
00244                         
00245                 } // SelectionSetUp

void AVRCpp::AnalogToDigital::SelectPrescaler ( Prescaler  prescaler  )  [inline]

Definition at line 272 of file ADC.h.

00273                 {
00274                         ChangeBits<_ADCSRA>(_ADPS0 | _ADPS1 | _ADPS2, prescaler);
00275                         
00276                 } // SelectPrescaler

void AVRCpp::AnalogToDigital::SetAutoTriggerSource ( AutoTriggerSource  source  )  [inline]

Definition at line 318 of file ADC.h.

00318 { ChangeBits<_ADCSRB>(_ADTS2 | _ADTS1 | _ADTS0, source); }

void AVRCpp::AnalogToDigital::SetChannel ( AnalogChannel  channel  )  [inline]

Definition at line 264 of file ADC.h.

00265                 {
00266                         EnsureChangeSafety();
00267                         ChangeBits<_ADMUX>(_MUX0 | _MUX1 | _MUX2 | _MUX3, channel);
00268                         
00269                 } // SetChannel

void AVRCpp::AnalogToDigital::SetDifferentialChannels ( AnalogChannel  positive,
AnalogChannel  negative,
Gain  gain 
) [inline]

Definition at line 296 of file ADC.h.

00297                 {
00298                         if(gain == Gain1x)
00299                         {
00300                                 ChangeBits<_ADMUX>(_MUX0 | _MUX1 | _MUX2 | _MUX3 | _MUX4, gain | positive | ((negative << 2) & 0x08));
00301                         }
00302                         else
00303                         {
00304                                 ChangeBits<_ADMUX>(_MUX0 | _MUX1 | _MUX2 | _MUX3, gain | (negative << 1) | (positive & 0x01));
00305                         }
00306                         
00307                 } // SetDifferentialChannels

void AVRCpp::AnalogToDigital::SetDigitalInput ( uint8_t  pins  )  [inline]

Enables the digital input buffers for the specified pins, disables for others.

Definition at line 351 of file ADC.h.

00351 { DIDR0 = ~pins; }

void AVRCpp::AnalogToDigital::StartConversion (  )  [inline]

Definition at line 283 of file ADC.h.

00283 { SetBits<_ADCSRA>(_ADSC); }            

void AVRCpp::AnalogToDigital::StartFreeRun (  )  [inline]

Definition at line 324 of file ADC.h.

void AVRCpp::AnalogToDigital::StopFreeRun (  )  [inline]

Definition at line 325 of file ADC.h.

00325 { DisableFreeRun(); }

void AVRCpp::AnalogToDigital::WaitWhileConverting (  )  [inline]

Definition at line 227 of file ADC.h.

00227 { while (IsConverting() ); }


Generated on Sat Sep 15 23:40:52 2007 for AVR C++ Lib for ATmega324P by  doxygen 1.5.2
SourceForge.net Logo MTÜ TTÜ Robotiklubi