-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An intentionally simple test for multiple alarms that only sets exactly two repeating alarms that should overlap frequently (one is twice the other's frequency).
- Loading branch information
Showing
3 changed files
with
41 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,11 @@ | ||
# Makefile for user application | ||
|
||
# Specify this directory relative to the current application. | ||
TOCK_USERLAND_BASE_DIR = ../../.. | ||
|
||
# Which files to compile. | ||
C_SRCS := $(wildcard *.c) | ||
|
||
# Include userland master makefile. Contains rules and flags for actually | ||
# building the application. | ||
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk |
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,7 @@ | ||
# Test Multiple Alarms (Simple) | ||
|
||
This tests the virtual alarms available to userspace. It sets two | ||
repeating alarms, at 500ms and 1s respectively, each prints the alarm | ||
index (1 or 2), current tick and alarm expiration to the console. When | ||
successful, both alarms should fire and alarm 1 should fire twice as | ||
often as alarm 2. |
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,23 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#include <libtock-sync/services/alarm.h> | ||
|
||
static void event_cb(__attribute__ ((unused)) uint32_t now, | ||
__attribute__ ((unused)) uint32_t expiration, | ||
void* ud) { | ||
int i = (int)ud; | ||
printf("%d %ld %ld\n", i, now, expiration); | ||
} | ||
|
||
int main(void) { | ||
libtock_alarm_t t1; | ||
libtock_alarm_t t2; | ||
|
||
libtock_alarm_repeating_every_ms( 500, event_cb, (void*)1, &t1); | ||
libtock_alarm_repeating_every_ms(1000, event_cb, (void*)2, &t2); | ||
|
||
while (1) { | ||
yield(); | ||
} | ||
} |