-
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.
tests/atmega8: streamlined test bettery
- Loading branch information
1 parent
0cc47c2
commit 56c54fc
Showing
20 changed files
with
1,564 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
RIOTBASE ?= $(CURDIR)/../../.. | ||
BOARD ?= atmega8 | ||
PORT ?= /dev/ttyACM0 | ||
|
||
include ../../Makefile.tests_common | ||
|
||
FEATURES_REQUIRED = periph_adc | ||
|
||
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,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,60 @@ | ||
/* | ||
* Copyright (C) 2014-2015 Freie Universität Berlin | ||
* 2023 Hugues Larrive | ||
* | ||
* 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 <[email protected]> | ||
* @author Hugues Larrive <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "periph/adc.h" | ||
|
||
#define RES ADC_RES_10BIT | ||
|
||
int main(void) | ||
{ | ||
int sample = 0; | ||
|
||
puts("\nRIOT ADC peripheral driver test\n"); | ||
puts("This test will sample all available ADC lines 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); | ||
} | ||
} | ||
|
||
while (1) { | ||
for (unsigned i = 0; i < ADC_NUMOF; i++) { | ||
sample = adc_sample(ADC_LINE(i), RES); | ||
if (sample < 0) { | ||
printf("ADC_LINE(%u): selected resolution not applicable\n", i); | ||
} else { | ||
printf("%i\t", sample); | ||
} | ||
} | ||
printf("\n"); | ||
} | ||
|
||
return 0; | ||
} |
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,17 @@ | ||
RIOTBASE ?= $(CURDIR)/../../.. | ||
BOARD ?= atmega8 | ||
PORT ?= /dev/ttyACM0 | ||
|
||
include ../../Makefile.tests_common | ||
|
||
FEATURES_REQUIRED += periph_gpio | ||
|
||
USEMODULE += shell | ||
|
||
CFLAGS += -DNDEBUG -DLOG_LEVEL=LOG_NONE | ||
DISABLE_MODULE += core_msg | ||
DEVELHELP = 0 | ||
CFLAGS += -DTHREAD_STACKSIZE_IDLE=74 | ||
CFLAGS += -DTHREAD_STACKSIZE_MAIN=168 | ||
|
||
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,162 @@ | ||
/* | ||
* Copyright (C) 2014,2017 Freie Universität Berlin | ||
* 2023 Hugues Larrive | ||
* | ||
* 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 GPIO peripheral drivers | ||
* | ||
* @author Hauke Petersen <[email protected]> | ||
* @author Hugues Larrive <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "shell.h" | ||
#include "periph/gpio.h" | ||
|
||
#define SHELL_BUFSIZE (16) | ||
|
||
static int init_pin(int argc, char **argv, gpio_mode_t mode) | ||
{ | ||
int po, pi; | ||
|
||
if (argc < 3) { | ||
printf("usage: %s <port> <pin>\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
po = atoi(argv[1]); | ||
pi = atoi(argv[2]); | ||
|
||
if (gpio_init(GPIO_PIN(po, pi), mode) < 0) { | ||
printf("Error to initialize GPIO_PIN(%i, %02i)\n", po, pi); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int init_out(int argc, char **argv) | ||
{ | ||
return init_pin(argc, argv, GPIO_OUT); | ||
} | ||
|
||
static int init_in(int argc, char **argv) | ||
{ | ||
return init_pin(argc, argv, GPIO_IN); | ||
} | ||
|
||
static int init_in_pu(int argc, char **argv) | ||
{ | ||
return init_pin(argc, argv, GPIO_IN_PU); | ||
} | ||
|
||
static int init_in_pd(int argc, char **argv) | ||
{ | ||
return init_pin(argc, argv, GPIO_IN_PD); | ||
} | ||
|
||
static int init_od(int argc, char **argv) | ||
{ | ||
return init_pin(argc, argv, GPIO_OD); | ||
} | ||
|
||
static int init_od_pu(int argc, char **argv) | ||
{ | ||
return init_pin(argc, argv, GPIO_OD_PU); | ||
} | ||
|
||
static int cmd_read(int argc, char **argv) | ||
{ | ||
int port, pin; | ||
|
||
if (argc < 3) { | ||
printf("usage: %s <port> <pin>\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
port = atoi(argv[1]); | ||
pin = atoi(argv[2]); | ||
|
||
if (gpio_read(GPIO_PIN(port, pin))) { | ||
printf("GPIO_PIN(%i.%02i) is HIGH\n", port, pin); | ||
} | ||
else { | ||
printf("GPIO_PIN(%i.%02i) is LOW\n", port, pin); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int cmd_set(int argc, char **argv) | ||
{ | ||
if (argc < 3) { | ||
printf("usage: %s <port> <pin>\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
gpio_set(GPIO_PIN(atoi(argv[1]), atoi(argv[2]))); | ||
|
||
return 0; | ||
} | ||
|
||
static int cmd_clear(int argc, char **argv) | ||
{ | ||
if (argc < 3) { | ||
printf("usage: %s <port> <pin>\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
gpio_clear(GPIO_PIN(atoi(argv[1]), atoi(argv[2]))); | ||
|
||
return 0; | ||
} | ||
|
||
static int cmd_toggle(int argc, char **argv) | ||
{ | ||
if (argc < 3) { | ||
printf("usage: %s <port> <pin>\n", argv[0]); | ||
return 1; | ||
} | ||
|
||
gpio_toggle(GPIO_PIN(atoi(argv[1]), atoi(argv[2]))); | ||
|
||
return 0; | ||
} | ||
|
||
static const shell_command_t shell_commands[] = { | ||
{ "init_out", "init as output (push-pull mode)", init_out }, | ||
{ "init_in", "init as input w/o pull resistor", init_in }, | ||
{ "init_in_pu", "init as input with pull-up", init_in_pu }, | ||
{ "init_in_pd", "init as input with pull-down", init_in_pd }, | ||
{ "init_od", "init as output (open-drain without pull resistor)", init_od }, | ||
{ "init_od_pu", "init as output (open-drain with pull-up)", init_od_pu }, | ||
{ "read", "read pin status", cmd_read }, | ||
{ "set", "set pin to HIGH", cmd_set }, | ||
{ "clear", "set pin to LOW", cmd_clear }, | ||
{ "toggle", "toggle pin", cmd_toggle }, | ||
{ NULL, NULL, NULL } | ||
}; | ||
|
||
int main(void) | ||
{ | ||
puts("GPIO peripheral driver test\n"); | ||
|
||
/* start the shell */ | ||
char line_buf[SHELL_BUFSIZE]; | ||
shell_run(shell_commands, line_buf, SHELL_BUFSIZE); | ||
|
||
return 0; | ||
} |
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,15 @@ | ||
RIOTBASE ?= $(CURDIR)/../../.. | ||
BOARD ?= atmega8 | ||
PORT ?= /dev/ttyACM0 | ||
|
||
include ../../Makefile.tests_common | ||
|
||
USEMODULE += pcf8574a | ||
EXTERNAL_MODULE_DIRS += ./ | ||
USEMODULE += hd44780_avr | ||
|
||
CFLAGS += -DHD44780_PARAM_COLS=20 | ||
CFLAGS += -DHD44780_PARAM_ROWS=4 | ||
CFLAGS += -DPCF8574A_BASE_ADDR=0x3F | ||
|
||
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 @@ | ||
include $(RIOTBASE)/Makefile.base |
Oops, something went wrong.