Skip to content

Commit a4c1108

Browse files
committed
tests: add gpio-sync test
1 parent e128cc1 commit a4c1108

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Makefile for user application
2+
3+
# Specify this directory relative to the current application.
4+
TOCK_USERLAND_BASE_DIR = ../../../..
5+
6+
# Which files to compile.
7+
C_SRCS := $(wildcard *.c)
8+
9+
# Include userland master makefile. Contains rules and flags for actually
10+
# building the application.
11+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
GPIO Sync Interrupt Test App
2+
=============
3+
4+
Test the libtock-sync/peripherals/gpio synchronous interrupt
5+
event functions.
6+
7+
Expected Output
8+
---------------
9+
10+
```
11+
[Test] GPIO Sync Interrupt
12+
Jump GPIO pin 0 low to start test.
13+
Then move the jumper to VCC
14+
tock$
15+
Pin 0 went high
16+
Now jumper back to ground
17+
Pin 0 went low
18+
Now jumper back to high
19+
Pin 0 went back high
20+
Success! Test done
21+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <stdio.h>
2+
3+
#include <libtock/interface/console.h>
4+
#include <libtock-sync/peripherals/gpio.h>
5+
#include <libtock/tock.h>
6+
7+
int main(void) {
8+
returncode_t ret;
9+
10+
printf("[Test] GPIO Sync Interrupt\n");
11+
printf("Jump GPIO pin 0 low to start test.\n");
12+
printf("Then move the jumper to VCC\n");
13+
14+
ret = libtocksync_gpio_wait_until_high(0, libtock_pull_down);
15+
if (ret != RETURNCODE_SUCCESS) {
16+
printf("[ERROR] %s\n", tock_strrcode(ret));
17+
return -1;
18+
}
19+
20+
printf("Pin 0 went high\n");
21+
printf("Now jumper back to ground\n");
22+
23+
libtocksync_gpio_wait_until_low(0, libtock_pull_up);
24+
25+
printf("Pin 0 went low\n");
26+
printf("Now jumper back to high\n");
27+
28+
libtocksync_gpio_wait_until_changed(0, libtock_pull_down);
29+
30+
printf("Pin 0 went back high\n");
31+
printf("Success! Test done\n");
32+
33+
return 0;
34+
}

0 commit comments

Comments
 (0)