MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / readADCChannel

Function readADCChannel

examples/AllProtocolsOnLCD/ADCUtils.hpp:91–106  ·  view source on GitHub ↗

* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h. * Use previous settings */

Source from the content-addressed store, hash-verified

89 * Use previous settings
90 */
91uint16_t readADCChannel() {
92 WordUnionForADCUtils tUValue;
93
94 // ADCSRB = 0; // Only active if ADATE is set to 1.
95 // ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode
96 ADCSRA = (_BV(ADEN) | _BV(ADSC) | _BV(ADIF) | ADC_PRESCALE);
97
98 // wait for single conversion to finish
99 loop_until_bit_is_clear(ADCSRA, ADSC);
100
101 // Get value
102 tUValue.UByte.LowByte = ADCL;
103 tUValue.UByte.HighByte = ADCH;
104 return tUValue.UWord;
105 // return ADCL | (ADCH <<8); // needs 4 bytes more
106}
107
108/*
109 * Use new channel aADCChannelNumber, but do not wait for channel switching

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected