hugllc / samc21_adc

ADC class for dealing with the SAMC21.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Main Page

Introduction

This library is for using the ADC and SDADC on the SAMC21 mpu using the Arduino or PlatformIO build environments.

Requirements

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

Using the Library

Platformio

Installing

platformio platform install https://github.com/prices/platform-atmelsam

platformio.ini Example

[platformio]
env_default = samc21

[env:samc21]
platform = atmelsam
framework = arduino
board = samc21_xpro

lib_deps = https://github.com/hugllc/samc21_adc.git

Code

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();
    }
    
}

Acknowledgements

Little bits of code (generally single lines) here and there were copied from the Arduino core.

About

ADC class for dealing with the SAMC21.

License:GNU Lesser General Public License v3.0


Languages

Language:C++ 100.0%