firmware/Temperature/src/ADC.c
///////////////////////////////////////////////////////////////////////////////
/// \brief Read a value from the ADC for the internal temperature sensor
///
/// \param ADC channel 0-17
/// \param destination pointer to return the value read
///
/// \return True on success else adc is not open
///////////////////////////////////////////////////////////////////////////////
\brief Read a value from the ADC for the internal temperature sensor
\param ADC channel 0-17
\param destination pointer to return the value read

\return True on success else adc is not open
\ brief Read a value from the ADC for the internal temperature sensor \ param ADC channel 0 - 17 \ param destination pointer to return the value read \ return True on success else adc is not open
uint_fast8_t ADC_Read(uint_fast32_t channel, uint_fast16_t *destination) {
	if ((!ADC1->CR & ADC_CR_ADEN) || channel > 17 || !destination) {
		return FALSE; 
	}
	if (ADC1->CR & ADC_CR_ADSTART) {
		return FALSE;  
	}
	ADC1->CHSELR = ((uint32_t)(1 << channel)); 
	ADC1->CR |= ADC_CR_ADSTART; 
	while (!(ADC1->ISR & ADC_ISR_EOC)); 
	*destination = (uint32_t)(0x0000FFFF & ADC1->DR); 
	return TRUE;
}
uint_fast8_t ADC_Read ( uint_fast32_t channel , uint_fast16_t * destination ) { if ( ( ! ADC1 -> CR & ADC_CR_ADEN ) || channel > 17 || ! destination ) { return FALSE ; } if ( ADC1 -> CR & ADC_CR_ADSTART ) { return FALSE ; } ADC1 -> CHSELR = ( ( uint32_t ) ( 1 << channel ) ) ; ADC1 -> CR |= ADC_CR_ADSTART ; while ( ! ( ADC1 -> ISR & ADC_ISR_EOC ) ) ; * destination = ( uint32_t ) ( 0x0000FFFF & ADC1 -> DR ) ; return TRUE ; }
\brief Read a value from the ADC for the internal temperature sensor
\param ADC channel 0-17
\param destination pointer to return the value read
\ brief Read a value from the ADC for the internal temperature sensor \ param ADC channel 0 - 17 \ param destination pointer to return the value read
// adc is not turned on, bad channel, or null destination // a conversion has already been started // select the channel // start the conversion //wait until ADC is done with conversion // only want to keep the 1/2 of the bits