Ejemplo n.º 1
0
Archivo: adc.hpp Proyecto: 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();
			}
Ejemplo n.º 2
0
///@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);
}
Ejemplo n.º 3
0
Archivo: adc.hpp Proyecto: davidwe/xpcc
			/**
			 * \brief Check if the conversion is finished
			 * 
			 * Available on all ATmegas.
			 */
			static inline bool
			isFinished()
			{
				return isInterruptFlagSet();
			}