Nut/OS  5.0.5
API Reference
A/D Converter

ATmega128 On-Chip ADC. More...

Collaboration diagram for A/D Converter:

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)
uint8_t ADCSetPrescale (uint8_t prescalar)
void ADCSetChannel (adc_channel_t adc_channel)
void ADCBufferFlush (void)
void ADCStartConversion (void)
 Start conversion.
void ADCStartLowNoiseConversion (void)
void ADCStopConversion (void)
uint8_t ADCRead (uint16_t *value)
adc_mode_t ADCGetMode (void)
int ADCBufRead (uint16_t *buf, uint16_t *read)
int ADCBufWrite (uint16_t *buf, uint16_t *write)
void ADCBufInit (uint16_t *buf)

Variables

uint8_t adc_sleep_mode = SLEEP_MODE_ADC
adc_mode_t current_mode = ADC_OFF
uint16_tADC_buffer = NULL
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...

Detailed Description

ATmega128 On-Chip ADC.


Define Documentation

#define ADC_PRESCALE_DIV2   0x00

0x01,0x00 -> CPU clk/2

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV4   0x02

0x02 -> CPU clk/4

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV8   0x03

0x03 -> CPU clk/8

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV16   0x04

0x04 -> CPU clk/16

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV32   0x05

0x05 -> CPU clk/32

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV64   0x06

0x06 -> CPU clk/64

Referenced by ADCSetPrescale().

#define ADC_PRESCALE_DIV128   0x07

0x07 -> CPU clk/128

Referenced by ADCSetPrescale().

#define ADC_INITIAL_CHANNEL   ADC0

Referenced by ADCInit().

#define ADC_INITIAL_REF   AVCC

Referenced by ADCInit().

#define ADC_INITIAL_MODE   SINGLE_CONVERSION

Referenced by ADCInit().

#define ADC_INITIAL_PRESCALE   ADC_PRESCALE_DIV64

Referenced by ADCInit().

#define ADC_BUF_SIZE   16

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

#define AVR_SLEEP_CTRL_REG   MCUCR
#define _adc_buf_head   ADC_BUF_SIZE

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

#define _adc_buf_tail   (ADC_BUF_SIZE+1)

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


Typedef Documentation

typedef enum adc_ref_type adc_ref_t
typedef enum adc_mode_type adc_mode_t

Enumeration Type Documentation

Enumerator:
AVCC 
AREF 
INTERNAL_256 
Enumerator:
ADC_OFF 
FREE_RUNNING 
SINGLE_CONVERSION 
ADC_OFF 
FREE_RUNNING_T0 
FREE_RUNNING_T1 
FREE_RUNNING_T2 
FREE_RUNNING_EXT 
SINGLE_CONVERSION 

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 

Function Documentation

void ADCInit ( void  )

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

void ADCSetRef ( adc_ref_t  reference)

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

Referenced by ADCInit().

Here is the call graph for this function:

uint8_t ADCSetPrescale ( uint8_t  prescalar)

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().

Here is the call graph for this function:

void ADCSetChannel ( adc_channel_t  adc_channel)

References inb, and outb.

Referenced by ADCInit().

void ADCBufferFlush ( void  )

References ADC_buffer, and ADCBufInit().

Here is the call graph for this function:

void ADCStartConversion ( void  )

Start conversion.

void ADCStartLowNoiseConversion ( void  )

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

Here is the call graph for this function:

void ADCStopConversion ( void  )

References cbi, current_mode, FREE_RUNNING, and sbi.

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

uint8_t ADCRead ( uint16_t value)

References ADC_buffer, and ADCBufRead().

Here is the call graph for this function:

adc_mode_t ADCGetMode ( void  ) [inline]

References current_mode.

int ADCBufRead ( uint16_t buf,
uint16_t read 
) [inline]
int ADCBufWrite ( uint16_t buf,
uint16_t write 
) [inline]
void ADCBufInit ( uint16_t buf)

References _adc_buf_head, and _adc_buf_tail.

Referenced by ADCBufferFlush(), and ADCInit().


Variable Documentation

uint8_t adc_sleep_mode = SLEEP_MODE_ADC

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