Functions | |
void | adc_interrupt_enable (uint8_t cmd) |
uint16_t | adc_read (void) |
void | adc_set_adlar (uint8_t adlar) |
void | adc_set_auto_trigger (uint8_t cmd) |
void | adc_set_channel (uint8_t chan) |
void | adc_set_enable (uint8_t cmd) |
void | adc_set_prescalar (uint8_t pre) |
void | adc_set_reference (uint8_t ref) |
void | adc_start_conversion (void) |
uint8_t | adc_interrupt_flag (void) |
void adc_interrupt_enable | ( | uint8_t | cmd | ) |
Enable/disable the ADC ISR.
cmd | ADC_INTERRUPT_DISABLE: disables the ISR (default) ADC_INTERRUPT_ENABLE: enable the ISR |
uint8_t adc_interrupt_flag | ( | void | ) | [inline] |
Returns the state of the ADC interrupt flag (indicates whether a conversion has been completed). Should only be used when the ISR is not being used.
Referenced by adc_read().
uint16_t adc_read | ( | void | ) |
Read the analog-to-digital converter. This function blocks (waits) until a value is available to be read from the ADC.
Assumptions: a conversion is ongoing or has completed, and adlar = ADC_ADLAR_RIGHT
References adc_interrupt_flag().
void adc_set_adlar | ( | uint8_t | adlar | ) |
Configure the position of the 10-bit ADC value in the 16-bit output register
adlar | ADC_ADLAR_RIGHT: Right-adjust the 10-bit value (default configuration) ADC_ADLAR_LEFT: Left-adjust the 10-bit value |
void adc_set_auto_trigger | ( | uint8_t | cmd | ) |
Set the ADC auto trigger state. If enabled, the ADC will automatically initiate the collection of the next sample after the current one is complete.
cmd | ADC_AUTO_TRIGGER_DISABLE: disabled (default) ADC_AUTO_TRIGGER_ENABLE: enabled |
void adc_set_channel | ( | uint8_t | chan | ) |
Select the ADC channel for the next conversion. If a conversion is already ongoing, this change will not affect it.
chan | A channel number. Acceptable values are 0 .. 15, however useful values will vary between specific chips. For the mega8, viable values are: ADC_CHANNEL_0 (default), ... ADC_CHANNEL_7, ADC_CHANNEL_1p23V (1.23V reference), and ADC_CHANNEL_0V (0V reference) |
void adc_set_enable | ( | uint8_t | cmd | ) |
Set the global state of the ADC hardware.
cmd | ADC_ENABLE: enable the ADC ADC_DISABLE: disable the ADC |
void adc_set_prescalar | ( | uint8_t | pre | ) |
Set the clock prescalar for the ADC device.
pre | is one of: ADC_PRESCALAR_2 (default), ADC_PRESCALAR_4, ADC_PRESCALAR_8, ADC_PRESCALAR_16, ADC_PRESCALAR_32, ADC_PRESCALAR_64, ADC_PRESCALAR_128 |
void adc_set_reference | ( | uint8_t | ref | ) |
Set the analog reference for the ADC. This reference determines the voltage at which the maximum analog value is read.
ref | ADC_REF_AREF: use the voltage presented at the AREF pin (default) ADC_REF_AREF_CAP: use the voltage presented at the AREF pin, but connect a capacitor to the pin ADC_REF_2p56V: use an internal reference of 2.56V |
void adc_start_conversion | ( | void | ) | [inline] |
Initiate an analog-to-digital conversion.
Assumptions: the ADC has been configured.