File tree Expand file tree Collapse file tree
examples/tests/gpio/gpio_sync Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments