Skip to content

ADC v0.2 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: samr21
Choose a base branch
from
Open

ADC v0.2 #3

wants to merge 9 commits into from

Conversation

wiredsource
Copy link

I have implemented the ADC with the interface defined resolution except 6BIT & 14BIT because it's not a valid resolution.

I have tested all the valid resolutions with success!

I have made a example project to test if needed?

There are still a few TODOs:
but minor ones!

@thomaseichinger
Copy link
Owner

Great to see the progress. I saw you imported a lot of functions from the Atmel library. The basic philosophy of the periph driver interface is to work with as little overhead as possible e.g. there shouldn't be wrapping functions or similar. To illustrate what I mean you could take a look at the ADC implementation for the stm32f4 MCU
I can't merge your current code due to this but we could take this as a starting point and deflate the additional functions into the interface functions.
If you choose to do this yourself please also keep our coding conventions in mind. Else it'd be very much appreciated if you keep this PR open so one of the RIOT CoreDevs can take it as a entry point.

@wiredsource
Copy link
Author

OK
So you wan't this to be #define someFunc() instead of the wrapping functions...?

I spotted another thing that needs to be implemented. Regarding the Positive/Negative pins.
There should the defined all the other options.

I will go refactor must of the ADC code now, the RTC will be set on standby...

@thomaseichinger
Copy link
Owner

For example I meant that adc_disable or adc_enable() could be done right in adc_poweron() and adc_poweroff(). I.e.

void adc_poweroff(adc_t dev)
{
    switch (dev) 
    {
#if ADC_0_EN
        case ADC_0:
            while((&ADC_0_DEV)->STATUS.reg & ADC_STATUS_SYNCBUSY);
            (&ADC_0_DEV)->CTRLA.reg &= ~ADC_CTRLA_ENABLE;
            break;
#endif
    }
}
void adc_poweron(adc_t dev)
{
    switch (dev) 
    {
#if ADC_0_EN
        case ADC_0:
            while((&ADC_0_DEV)->STATUS.reg & ADC_STATUS_SYNCBUSY);
            (&ADC_0_DEV)->CTRLA.reg |= ADC_CTRLA_ENABLE;
            break;
#endif
    }
}

This holds for all the adc_system_*() functions too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants