2.8.1.1.2 Code

Add to the main application source file, outside of any functions:
struct adc_module adc_instance;
Copy-paste the following setup code to your user application:
void configure_adc(void)
{
    struct adc_config config_adc;
    adc_get_config_defaults(&config_adc);

#if (SAMC21)
    adc_init(&adc_instance, ADC1, &config_adc);
#else
    adc_init(&adc_instance, ADC, &config_adc);
#endif

    adc_enable(&adc_instance);
}
Add to user application initialization (typically the start of main()):
configure_adc();