/* ADC Calibration mode. 
Serial console prints the ADC input voltage after calibration done.  */
void adc_calibration(void)
/* ADC Calibration mode. 
Serial console prints the ADC input voltage after calibration done.  */
void adc_calibration(void)
{
	uint8_t key;
	printf("\x0C\n-- Start of ADC Calibration Example --\n");
	configure_adc();
	printf("Commands:\n");
	printf("- key 'c' to enable correction\n");
	printf("- key 'd' to disable correction\n");
	key = getchar();
	delay_ms(500);
	if (key == 'c') {
		adc_correction_start();	}
	if (key == 'd') {
		adc_correction_stop();	}
	raw_result = adc_start_read_result();
	result = ((float)raw_result * (float)ADC_REFERENCE_INTVCC1_VALUE)/(float)ADC_12BIT_FULL_SCALE_VALUE;
	printf("\nADC Input voltage is %fV", result);	printf("\n-- End of ADC Calibration Example --\n");
}