-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20045 from benpicco/periph_adc_continous
periph/adc: introduce periph_adc_continuous
- Loading branch information
Showing
9 changed files
with
237 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
BOARD ?= same54-xpro | ||
include ../Makefile.periph_common | ||
|
||
FEATURES_REQUIRED += periph_adc | ||
FEATURES_REQUIRED += periph_adc_continuous | ||
USEMODULE += ztimer | ||
USEMODULE += ztimer_msec | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
BOARD_INSUFFICIENT_MEMORY := \ | ||
atmega8 \ | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Expected result | ||
=============== | ||
When running this test, you should see the samples of all configured ADC lines | ||
continuously streamed to std-out. | ||
|
||
Background | ||
========== | ||
This test application will initialize each configured ADC lines to sample with | ||
10-bit accuracy. Once configured the application will continuously convert each | ||
available channel and print the conversion results to std-out. | ||
|
||
For verification of the output connect the ADC pins to known voltage levels | ||
and compare the output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2014-2015 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief Test application for peripheral ADC drivers | ||
* | ||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "ztimer.h" | ||
#include "periph/adc.h" | ||
|
||
#define RES ADC_RES_10BIT | ||
#define DELAY_MS 100U | ||
|
||
int main(void) | ||
{ | ||
int sample = 0; | ||
|
||
puts("\nRIOT ADC peripheral driver test\n"); | ||
puts("This test will sample all available ADC lines once every 100ms with\n" | ||
"a 10-bit resolution and print the sampled results to STDIO\n\n"); | ||
|
||
/* initialize all available ADC lines */ | ||
for (unsigned i = 0; i < ADC_NUMOF; i++) { | ||
if (adc_init(ADC_LINE(i)) < 0) { | ||
printf("Initialization of ADC_LINE(%u) failed\n", i); | ||
return 1; | ||
} else { | ||
printf("Successfully initialized ADC_LINE(%u)\n", i); | ||
} | ||
} | ||
|
||
adc_continuous_begin(RES); | ||
while (1) { | ||
for (unsigned i = 0; i < ADC_NUMOF; i++) { | ||
sample = adc_continuous_sample(ADC_LINE(i)); | ||
printf("ADC_LINE(%u): %i\n", i, sample); | ||
} | ||
ztimer_sleep(ZTIMER_MSEC, DELAY_MS); | ||
} | ||
|
||
adc_continuous_stop(); | ||
return 0; | ||
} |