* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h. */
| 99 | * Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h. |
| 100 | */ |
| 101 | uint16_t readADCChannelWithReference(uint8_t aADCChannelNumber, uint8_t aReference) { |
| 102 | WordUnionForADCUtils tUValue; |
| 103 | ADMUX = aADCChannelNumber | (aReference << SHIFT_VALUE_FOR_REFERENCE); |
| 104 | |
| 105 | // ADCSRB = 0; // Only active if ADATE is set to 1. |
| 106 | // ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode |
| 107 | ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADIF) | ADC_PRESCALE); |
| 108 | |
| 109 | // wait for single conversion to finish |
| 110 | loop_until_bit_is_clear(ADCSRA, ADSC); |
| 111 | |
| 112 | // Get value |
| 113 | tUValue.UByte.LowByte = ADCL; |
| 114 | tUValue.UByte.HighByte = ADCH; |
| 115 | return tUValue.UWord; |
| 116 | } |
| 117 | |
| 118 | /* |
| 119 | * Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h. |
no outgoing calls
no test coverage detected