This library is for using the ADC and SDADC on the SAMC21 mpu using the Arduino or PlatformIO build environments.
SAMC support is still not in the mainline samd (Arduino or platformio). SAMC support is available for Arduino here:
https://github.com/prices/ArduinoCore-samd
For platformio it is available here:
https://github.com/prices/platform-atmelsam
platformio platform install https://github.com/prices/platform-atmelsam
[platformio]
env_default = samc21
[env:samc21]
platform = atmelsam
framework = arduino
board = samc21_xpro
lib_deps = https://github.com/hugllc/samc21_adc.git
This will print out new readings very fast:
#include <samc21_adc.h>
SAMC21_ADC adc(ADC0);
void setup()
{
adc.begin();
adc.freerun(SAMC21_ADC_MUXPOS_3);
}
void loop()
{
int32_t adc_read;
if (adc.newReading()) {
adc_read = adc.value();
Serial.print("ADC: ");
Serial.print(adc_read);
Serial.println();
}
}
Little bits of code (generally single lines) here and there were copied from the Arduino core.