SimAVR
AVR Simulator
ADC

simavr ADC allows external code to feed real voltages to the simulator, and the simulator uses it's 'real' reference voltage to do the right thing and return the 'proper' 10 bits ADC value to the AVR firmware. More...

Data Structures

struct  avr_adc_mux_t
 
struct  avr_adc_t
 

Macros

#define AVR_IOCTL_ADC_GETIRQ   AVR_IOCTL_DEF('a','d','c',' ')
 Get the internal IRQ corresponding to the INT. More...
 
#define AVR_ADC_SINGLE(_chan)
 
#define AVR_ADC_DIFF(_a, _b, _g)
 
#define AVR_ADC_REF(_t)
 
#define AVR_ADC_TEMP()
 
#define AVR_ADC_VCC4()
 

Typedefs

typedef struct avr_adc_mux_t avr_adc_mux_t
 
typedef struct avr_adc_t avr_adc_t
 

Enumerations

enum  {
  ADC_IRQ_ADC0 = 0, ADC_IRQ_ADC1, ADC_IRQ_ADC2, ADC_IRQ_ADC3,
  ADC_IRQ_ADC4, ADC_IRQ_ADC5, ADC_IRQ_ADC6, ADC_IRQ_ADC7,
  ADC_IRQ_ADC8, ADC_IRQ_ADC9, ADC_IRQ_ADC10, ADC_IRQ_ADC11,
  ADC_IRQ_ADC12, ADC_IRQ_ADC13, ADC_IRQ_ADC14, ADC_IRQ_ADC15,
  ADC_IRQ_TEMP, ADC_IRQ_IN_TRIGGER, ADC_IRQ_OUT_TRIGGER, ADC_IRQ_COUNT
}
 
enum  {
  ADC_MUX_NONE = 0, ADC_MUX_NOISE, ADC_MUX_SINGLE, ADC_MUX_DIFF,
  ADC_MUX_TEMP, ADC_MUX_REF, ADC_MUX_VCC4
}
 Definition of a ADC mux mode. More...
 
enum  {
  ADC_VREF_AREF = 0, ADC_VREF_VCC, ADC_VREF_AVCC, ADC_VREF_V110 = 1100,
  ADC_VREF_V256 = 2560
}
 
enum  avr_adts_type {
  avr_adts_none = 0, avr_adts_free_running, avr_adts_analog_comparator_0, avr_adts_analog_comparator_1,
  avr_adts_analog_comparator_2, avr_adts_analog_comparator_3, avr_adts_external_interrupt_0, avr_adts_timer_0_compare_match_a,
  avr_adts_timer_0_compare_match_b, avr_adts_timer_0_overflow, avr_adts_timer_1_compare_match_b, avr_adts_timer_1_overflow,
  avr_adts_timer_1_capture_event, avr_adts_pin_change_interrupt, avr_adts_psc_module_0_sync_signal, avr_adts_psc_module_1_sync_signal,
  avr_adts_psc_module_2_sync_signal
}
 ADC trigger sources. More...
 

Functions

void avr_adc_init (avr_t *avr, avr_adc_t *port)
 

Detailed Description

simavr ADC allows external code to feed real voltages to the simulator, and the simulator uses it's 'real' reference voltage to do the right thing and return the 'proper' 10 bits ADC value to the AVR firmware.

To send values to the ADC, register your code to wait for the ADC_IRQ_OUT_TRIGGER irq, and at that point send any of the ADC_IRQ_ADC* with Millivolts as value.

External trigger is not done yet.

Macro Definition Documentation

#define AVR_ADC_DIFF (   _a,
  _b,
  _g 
)
Value:
{ \
.kind = ADC_MUX_DIFF, \
.src = (_a), \
.diff = (_b), \
.gain = (_g), \
}
Normal ADC pin reading
Definition: avr_adc.h:66
#define AVR_ADC_REF (   _t)
Value:
{ \
.kind = ADC_MUX_REF, \
.src = (_t), \
}
internal temp sensor
Definition: avr_adc.h:68
#define AVR_ADC_SINGLE (   _chan)
Value:
{ \
.kind = ADC_MUX_SINGLE, \
.src = (_chan), \
}
Nothing. return something random
Definition: avr_adc.h:65
#define AVR_ADC_TEMP ( )
Value:
{ \
.kind = ADC_MUX_TEMP, \
}
differential channels (src-diff)
Definition: avr_adc.h:67
#define AVR_ADC_VCC4 ( )
Value:
{ \
.kind = ADC_MUX_VCC4, \
}
reference voltage (in src * 100)
Definition: avr_adc.h:69
#define AVR_IOCTL_ADC_GETIRQ   AVR_IOCTL_DEF('a','d','c',' ')

Get the internal IRQ corresponding to the INT.

Typedef Documentation

typedef struct avr_adc_mux_t avr_adc_mux_t
typedef struct avr_adc_t avr_adc_t

Enumeration Type Documentation

anonymous enum
Enumerator
ADC_IRQ_ADC0 

input IRQ values. Values are /always/ volts * 1000 (millivolts)

ADC_IRQ_ADC1 
ADC_IRQ_ADC2 
ADC_IRQ_ADC3 
ADC_IRQ_ADC4 
ADC_IRQ_ADC5 
ADC_IRQ_ADC6 
ADC_IRQ_ADC7 
ADC_IRQ_ADC8 
ADC_IRQ_ADC9 
ADC_IRQ_ADC10 
ADC_IRQ_ADC11 
ADC_IRQ_ADC12 
ADC_IRQ_ADC13 
ADC_IRQ_ADC14 
ADC_IRQ_ADC15 
ADC_IRQ_TEMP 
ADC_IRQ_IN_TRIGGER 
ADC_IRQ_OUT_TRIGGER 
ADC_IRQ_COUNT 

sends a avr_adc_mux_t

anonymous enum

Definition of a ADC mux mode.

Enumerator
ADC_MUX_NONE 
ADC_MUX_NOISE 

Nothing. return 0

ADC_MUX_SINGLE 

Nothing. return something random

ADC_MUX_DIFF 

Normal ADC pin reading

ADC_MUX_TEMP 

differential channels (src-diff)

ADC_MUX_REF 

internal temp sensor

ADC_MUX_VCC4 

reference voltage (in src * 100)

anonymous enum
Enumerator
ADC_VREF_AREF 
ADC_VREF_VCC 

default mode

ADC_VREF_AVCC 
ADC_VREF_V110 
ADC_VREF_V256 

ADC trigger sources.

Enumerator
avr_adts_none 
avr_adts_free_running 
avr_adts_analog_comparator_0 
avr_adts_analog_comparator_1 
avr_adts_analog_comparator_2 
avr_adts_analog_comparator_3 
avr_adts_external_interrupt_0 
avr_adts_timer_0_compare_match_a 
avr_adts_timer_0_compare_match_b 
avr_adts_timer_0_overflow 
avr_adts_timer_1_compare_match_b 
avr_adts_timer_1_overflow 
avr_adts_timer_1_capture_event 
avr_adts_pin_change_interrupt 
avr_adts_psc_module_0_sync_signal 
avr_adts_psc_module_1_sync_signal 
avr_adts_psc_module_2_sync_signal 

Function Documentation

void avr_adc_init ( avr_t avr,
avr_adc_t port 
)

Here is the call graph for this function:

Here is the caller graph for this function: