The Analog to Digital Converter (ADC) synchronous driver will block (i.e. not return) there until the requested data has been read. Functionality is therefore synchronous to the calling thread, i.e. the thread will wait for the result to be ready. The adc_sync_read_channel function will perform a conversion of the voltage on the specified channel and return the result when it is ready.
Initialize and deinitialize the driver and associated hardware
Select single shot or free running conversion modes
Configure major ADC properties such as resolution and reference source
Read back conversion results
Selecting which ADC input channels to enable for positive and negative input
Which clock source and prescaler the ADC uses
Various aspects of Event control
Single shot or free running conversion modes
Sampling properties such as resolution, window mode, and reference source
Run in Standby or Debug mode
The functions in the ADC synchronous driver will block (i.e. not return) until the operation is done.
The following shows a simple example of using the ADC. The ADC must have been initialized by adc_sync_init. This initialization will configure the operation of the ADC, such as single-shot or continuous mode, etc.
The example enables channel 0 of ADC0, and finally starts a conversion on this channel.
/**
* Example of using ADC_0 to generate waveform.
*/
void ADC_0_example(void)
{
uint8_t buffer[2];
adc_sync_enable_channel(&ADC_0, 0);
while (1) {
adc_sync_read_channel(&ADC_0, 0, buffer, 2);
}
}
ADC peripheral and its related I/O lines and clocks