-
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.
- Loading branch information
Showing
3 changed files
with
100 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,13 @@ | ||
include ../Makefile.sys_common | ||
|
||
LOW_POWER ?= 0 | ||
|
||
ifeq (1,$(LOW_POWER)) | ||
USEMODULE += ztimer_msec | ||
else | ||
USEMODULE += ztimer_usec | ||
endif | ||
|
||
USEMODULE += delay_us_spinning | ||
|
||
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,53 @@ | ||
/* | ||
* Copyright (C) 2023 Otto-von-Guericke-Universität Magdeburg | ||
* | ||
* 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 the sys/delay | ||
* | ||
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <assert.h> | ||
#include <stdio.h> | ||
|
||
#include "delay.h" | ||
#include "irq.h" | ||
#include "led.h" | ||
|
||
int main(void) | ||
{ | ||
printf( | ||
"Test Application for sys/delay\n" | ||
"==============================\n" | ||
"\n" | ||
); | ||
|
||
printf("Delay: 1 s\n"); | ||
delay_s(1); | ||
printf("Done\n"); | ||
printf("Delay: 100 ms\n"); | ||
delay_ms(100); | ||
printf("Done\n"); | ||
|
||
printf("Now blinking LED with a 100 μs pulse every 100 ms\n"); | ||
while (1) { | ||
unsigned state = irq_disable(); | ||
LED0_ON; | ||
delay_us_spinning(100); | ||
LED0_OFF; | ||
irq_restore(state); | ||
delay_ms(100); | ||
} | ||
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,34 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg | ||
# | ||
# 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. | ||
|
||
# @author Marian Buschsieweke <marian.buschsieweke@ovgu.de> | ||
|
||
import sys | ||
import time | ||
from testrunner import run | ||
|
||
|
||
def testfunc(child): | ||
child.expect("Test Application for sys/delay") | ||
child.expect(r"Delay: (\d+) s") | ||
start = time.time() | ||
expected = int(child.match.group(1)) | ||
child.expect("Done") | ||
elapsed = time.time() - start | ||
assert elapsed > expected | ||
|
||
child.expect(r"Delay: (\d+) ms") | ||
start = time.time() | ||
expected = int(child.match.group(1)) | ||
child.expect("Done") | ||
elapsed = time.time() - start | ||
assert elapsed > expected / 1000 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(run(testfunc)) |