X-Git-Url: http://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/9d18e10afb2439a6a9ba6978a799259746a837b7..16d75a18e3cbbfc8b414f47fda67a32dc650918d:/core/adc/adc.c?ds=sidebyside diff --git a/core/adc/adc.c b/core/adc/adc.c index fdf2d30..5728545 100644 --- a/core/adc/adc.c +++ b/core/adc/adc.c @@ -87,7 +87,7 @@ static uint8_t _adcLastChannel = 0; be added to the adcInit function. */ /**************************************************************************/ -uint32_t adcRead (uint8_t channelNum) +uint32_t adcReadSingle (uint8_t channelNum) { if (!_adcInitialised) adcInit(); @@ -162,6 +162,45 @@ uint32_t adcRead (uint8_t channelNum) return (adcData); } +/**************************************************************************/ +/*! + @brief Returns the conversion results on the specified ADC channel. + + This function will manually start an A/D conversion on a single + channel and return the results. If ADC Averaging is enabled + (via ADC_AVERAGING_ENABLE) the specified number of values will be + samples from the ADC and the average value will be returned. + + @param[in] channelNum + The A/D channel [0..7] that will be used during the A/D + conversion. (Note that only A/D channel's 0..3 are + configured by default in adcInit.) + + @return 0 if an overrun error occured, otherwise a 10-bit value + containing the A/D conversion results. + + @warning Only AD channels 0..3 are configured for A/D in adcInit. + If you wish to use A/D pins 4..7 they will also need to + be added to the adcInit function. +*/ +/**************************************************************************/ +uint32_t adcRead (uint8_t channelNum) +{ + if (!_adcInitialised) adcInit(); + + #if ADC_AVERAGING_ENABLE + uint32_t adcTotal, i; + adcTotal = 0; + for (i=0; i