コード例 #1
0
ファイル: adc.hpp プロジェクト: davidwe/xpcc
			/**
			 * \brief	Read the value an analog channel
			 * 
			 * A normal conversion takes 13 ADC clock cycles. With a clock frequency
			 * of for example 200 kHz a conversion therefore needs 65 microseconds.
			 * This time increases with a lower frequency.
			 *
			 * Available on all ATmegas.
			 */
			static inline uint16_t
			readChannel(uint8_t channel)
			{
				if (!startConversion(channel)) return 0;
				
				while (!isInterruptFlagSet()) {
					// wait until the conversion is finished
				}
				
				return getDataRegister();
			}
コード例 #2
0
ファイル: myqADC.cpp プロジェクト: myqthorn/myq-atmel-studio
///@description	Perform a complete conversion. Should only be used when waiting isn't a problem.
uint16_t ANALOG::read(){
		
	//start conversion
	start();
	
	//wait for conversion to finish (interrupt flag is set)
	while( isReading() && !isInterruptFlagSet());
	
	clearFlag();
	return (ADC);
}
コード例 #3
0
ファイル: adc.hpp プロジェクト: davidwe/xpcc
			/**
			 * \brief Check if the conversion is finished
			 * 
			 * Available on all ATmegas.
			 */
			static inline bool
			isFinished()
			{
				return isInterruptFlagSet();
			}