Added some comments.

This commit is contained in:
David Lenfesty 2019-11-04 16:44:49 -07:00
parent 985484179b
commit 189313a53c

View File

@ -46,6 +46,10 @@ void adc_init() {
*
* @note Blocks until conversion finishes, so speed of this function is dependant
* on ADC prescaler.
*
* @param adc_selection Value from 0-5, selects from ADC[0-5]
*
* @return Raw value of ADC conversion
*/
uint16_t adc_run_conversion(uint8_t adc_selection) {
// Select ADC input, using
@ -58,21 +62,27 @@ uint16_t adc_run_conversion(uint8_t adc_selection) {
while (!(ADCSRA & (1 << ADIF)));
// Read out conversion value
// may not be correct
return ADC;
}
/** @brief Converts an ADC value from a measurement on an LM35 into a temperature.
*
* @param adc_reading Raw ADC measurement from LM35.
*
* @return Measured temperature, configure parameters in main.h
*/
int8_t lm35_convert(uint16_t adc_reading) {
return (adc_reading * ADC_VREF / ADC_RESOLUTION) / LM35_SENSITIVITY;
}
/** @brief Converts and ADC value from a measurement on a diode into a temperature.
*
* @param adc_reading Raw ADC measurement from diode.
*
* @return Measured temperature, configure parameters in main.h
*/
int8_t diode_convert(uint16_t adc_reading) {
// This could be collapsed but it doesn't really matter
int16_t value_diff = adc_reading - DIODE_VALUE_25C;
int16_t temp_diff = value_diff / DIODE_SENSITIVITY;
return temp_diff + 25;
@ -113,6 +123,7 @@ int main() {
// Display diode info on LCD
lcd_puts((const char*) diode_string);
// Refreshing too fast can make the data appear weird
_delay_ms(500);
}