A/D Converter
[Special Hardware]

Collaboration diagram for A/D Converter:

Detailed Description

ATmega128 On-Chip ADC.

enum  adc_channel_type {
  ADC0 = 0, ADC1 = 1, ADC2 = 2, ADC3 = 3,
  ADC4 = 4, ADC5 = 5, ADC6 = 6, ADC7 = 7,
  ADC0 = 0, ADC1 = 1, ADC2 = 2, ADC3 = 3,
  ADC4 = 4, ADC5 = 5, ADC6 = 6, ADC7 = 7,
  ADC_MAX_CHANNEL = 8
}
 enum declaring possible ADC channels More...

Defines

#define ADC_PRESCALE_DIV2   0x00
 0x01,0x00 -> CPU clk/2
#define ADC_PRESCALE_DIV4   0x02
 0x02 -> CPU clk/4
#define ADC_PRESCALE_DIV8   0x03
 0x03 -> CPU clk/8
#define ADC_PRESCALE_DIV16   0x04
 0x04 -> CPU clk/16
#define ADC_PRESCALE_DIV32   0x05
 0x05 -> CPU clk/32
#define ADC_PRESCALE_DIV64   0x06
 0x06 -> CPU clk/64
#define ADC_PRESCALE_DIV128   0x07
 0x07 -> CPU clk/128
#define ADC_INITIAL_CHANNEL   ADC0
#define ADC_INITIAL_REF   AVCC
#define ADC_INITIAL_MODE   SINGLE_CONVERSION
#define ADC_INITIAL_PRESCALE   ADC_PRESCALE_DIV64
#define ADC_BUF_SIZE   16
#define AVR_SLEEP_CTRL_REG   MCUCR
#define _adc_buf_head   ADC_BUF_SIZE
#define _adc_buf_tail   ADC_BUF_SIZE+1

Typedefs

typedef enum adc_ref_type adc_ref_t
typedef enum
adc_mode_type 
adc_mode_t
typedef enum
adc_channel_type 
adc_channel_t

Enumerations

enum  adc_ref_type { AVCC = 0, AREF, INTERNAL_256 }
enum  adc_mode_type {
  ADC_OFF, FREE_RUNNING, SINGLE_CONVERSION, ADC_OFF,
  FREE_RUNNING_T0, FREE_RUNNING_T1, FREE_RUNNING_T2, FREE_RUNNING_EXT,
  SINGLE_CONVERSION
}

Functions

void ADCInit (void)
 Initialize the adc to the configured default values and enable interrupt.
void ADCSetRef (adc_ref_t reference)
void ADCSetMode (adc_mode_t mode)
 Sets the data aquisition mode for the adc.
u_char ADCSetPrescale (u_char prescalar)
void ADCSetChannel (adc_channel_t adc_channel)
void ADCBufferFlush (void)
void ADCStartConversion (void)
 Start conversion.
void ADCStartLowNoiseConversion (void)
void ADCStopConversion (void)
u_char ADCRead (u_short *value)
adc_mode_t ADCGetMode (void)
int ADCBufRead (u_short *buf, u_short *read)
int ADCBufWrite (u_short *buf, u_short *write)
void ADCBufInit (u_short *buf)

Variables

u_char adc_sleep_mode = SLEEP_MODE_ADC
adc_mode_t current_mode = ADC_OFF
u_shortADC_buffer = NULL


Define Documentation

#define ADC_PRESCALE_DIV2   0x00

0x01,0x00 -> CPU clk/2

Definition at line 97 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV4   0x02

0x02 -> CPU clk/4

Definition at line 98 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV8   0x03

0x03 -> CPU clk/8

Definition at line 99 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV16   0x04

0x04 -> CPU clk/16

Definition at line 100 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV32   0x05

0x05 -> CPU clk/32

Definition at line 101 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV64   0x06

0x06 -> CPU clk/64

Definition at line 102 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV128   0x07

0x07 -> CPU clk/128

Definition at line 103 of file adc.h.

Referenced by ADCSetPrescale().

#define ADC_INITIAL_CHANNEL   ADC0

Definition at line 96 of file adc.c.

Referenced by ADCInit().

#define ADC_INITIAL_REF   AVCC

Definition at line 100 of file adc.c.

Referenced by ADCInit().

#define ADC_INITIAL_MODE   SINGLE_CONVERSION

Definition at line 104 of file adc.c.

Referenced by ADCInit().

#define ADC_INITIAL_PRESCALE   ADC_PRESCALE_DIV64

Definition at line 108 of file adc.c.

Referenced by ADCInit().

#define ADC_BUF_SIZE   16

Definition at line 111 of file adc.c.

Referenced by ADCBufRead(), ADCBufWrite(), and ADCInit().

#define AVR_SLEEP_CTRL_REG   MCUCR

Definition at line 120 of file adc.c.

Referenced by ADCStartLowNoiseConversion(), and NutIdle().

#define _adc_buf_head   ADC_BUF_SIZE

Definition at line 138 of file adc.c.

Referenced by ADCBufInit(), ADCBufRead(), ADCBufWrite(), and ADCInit().

#define _adc_buf_tail   ADC_BUF_SIZE+1

Definition at line 139 of file adc.c.

Referenced by ADCBufInit(), ADCBufRead(), ADCBufWrite(), and ADCInit().


Typedef Documentation

typedef enum adc_ref_type adc_ref_t

Definition at line 61 of file adc.h.

typedef enum adc_mode_type adc_mode_t

Definition at line 79 of file adc.h.

typedef enum adc_channel_type adc_channel_t

Definition at line 95 of file adc.h.


Enumeration Type Documentation

enum adc_ref_type

Enumerator:
AVCC 
AREF 
INTERNAL_256 

Definition at line 54 of file adc.h.

enum adc_mode_type

Enumerator:
ADC_OFF 
FREE_RUNNING 
SINGLE_CONVERSION 
ADC_OFF 
FREE_RUNNING_T0 
FREE_RUNNING_T1 
FREE_RUNNING_T2 
FREE_RUNNING_EXT 
SINGLE_CONVERSION 

Definition at line 72 of file adc.h.

enum adc_channel_type

enum declaring possible ADC channels

dev/at91_adc.h

Enumerator:
ADC0 
ADC1 
ADC2 
ADC3 
ADC4 
ADC5 
ADC6 
ADC7 
ADC0 
ADC1 
ADC2 
ADC3 
ADC4 
ADC5 
ADC6 
ADC7 
ADC_MAX_CHANNEL 

Definition at line 83 of file adc.h.


Function Documentation

void ADCInit ( void   ) 

Initialize the adc to the configured default values and enable interrupt.

Definition at line 187 of file adc.c.

References ADC_BUF_SIZE, ADC_buffer, ADC_INITIAL_CHANNEL, ADC_INITIAL_MODE, ADC_INITIAL_PRESCALE, ADC_INITIAL_REF, ADCBufInit(), ADCSetChannel(), ADCSetMode(), ADCSetPrescale(), ADCSetRef(), NutHeapAlloc(), NutRegisterIrqHandler(), sbi, and sig_ADC.

void ADCSetRef ( adc_ref_t  reference  ) 

Definition at line 210 of file adc.c.

References ADCStopConversion(), AREF, AVCC, cbi, INTERNAL_256, and sbi.

Referenced by ADCInit().

void ADCSetMode ( TADCMode  mode  ) 

Sets the data aquisition mode for the adc.

Parameters:
mode Mode to set

Definition at line 233 of file adc.c.

References ADC_OFF, ADCStopConversion(), cbi, current_mode, FREE_RUNNING, sbi, and SINGLE_CONVERSION.

Referenced by ADCInit(), and ADCStartLowNoiseConversion().

u_char ADCSetPrescale ( u_char  prescalar  ) 

Definition at line 250 of file adc.c.

References ADC_PRESCALE_DIV128, ADC_PRESCALE_DIV16, ADC_PRESCALE_DIV2, ADC_PRESCALE_DIV32, ADC_PRESCALE_DIV4, ADC_PRESCALE_DIV64, ADC_PRESCALE_DIV8, ADCStopConversion(), cbi, and sbi.

Referenced by ADCInit().

void ADCSetChannel ( adc_channel_t  adc_channel  ) 

Definition at line 304 of file adc.c.

References inb, and outb.

Referenced by ADCInit().

void ADCBufferFlush ( void   ) 

Definition at line 313 of file adc.c.

References ADC_buffer, and ADCBufInit().

void ADCStartConversion ( void   ) 

Start conversion.

Definition at line 318 of file adc.c.

References sbi.

void ADCStartLowNoiseConversion ( void   ) 

Definition at line 323 of file adc.c.

References _BV, adc_sleep_mode, ADCSetMode(), AVR_SLEEP_CTRL_REG, sbi, and SINGLE_CONVERSION.

void ADCStopConversion ( void   ) 

Definition at line 343 of file adc.c.

References cbi, current_mode, FREE_RUNNING, and sbi.

Referenced by ADCSetMode(), ADCSetPrescale(), and ADCSetRef().

u_char ADCRead ( u_short value  ) 

Definition at line 357 of file adc.c.

References ADC_buffer, and ADCBufRead().

adc_mode_t ADCGetMode ( void   )  [inline]

Definition at line 362 of file adc.c.

References current_mode.

int ADCBufRead ( u_short buf,
u_short read 
) [inline]

Definition at line 143 of file adc.c.

References _adc_buf_head, _adc_buf_tail, and ADC_BUF_SIZE.

int ADCBufWrite ( u_short buf,
u_short write 
) [inline]

Definition at line 156 of file adc.c.

References _adc_buf_head, _adc_buf_tail, and ADC_BUF_SIZE.

void ADCBufInit ( u_short buf  ) 

Definition at line 169 of file adc.c.

References _adc_buf_head, and _adc_buf_tail.

Referenced by ADCBufferFlush(), and ADCInit().


Variable Documentation

u_char adc_sleep_mode = SLEEP_MODE_ADC

Definition at line 114 of file adc.c.

Referenced by ADCStartLowNoiseConversion().

adc_mode_t current_mode = ADC_OFF

Definition at line 127 of file adc.c.

Referenced by ADCGetMode(), ADCSetMode(), and ADCStopConversion().

u_short* ADC_buffer = NULL

Definition at line 141 of file adc.c.

Referenced by ADCBufferFlush(), ADCInit(), and ADCRead().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/