From 301b7d51fa6c53c3b10278a973e0f9bfe6641ce8 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 5 Jul 2014 22:46:43 +0200 Subject: [PATCH] add gpio_out syscall --- artiq/devices/runtime.py | 3 ++- soc/runtime/main.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/artiq/devices/runtime.py b/artiq/devices/runtime.py index 628f68c56..47055d2de 100644 --- a/artiq/devices/runtime.py +++ b/artiq/devices/runtime.py @@ -1,7 +1,8 @@ from llvm import core as lc _syscalls = [ - ("printint", lc.Type.void(), [lc.Type.int()]) + ("print_int", lc.Type.void(), [lc.Type.int()]), + ("gpio_set", lc.Type.void(), [lc.Type.int(), lc.Type.int()]) ] class Environment: diff --git a/soc/runtime/main.c b/soc/runtime/main.c index 40bd61a1e..5f8e7ca34 100644 --- a/soc/runtime/main.c +++ b/soc/runtime/main.c @@ -55,13 +55,19 @@ static int download_kernel(void *buffer, int maxlength) return length; } -static void printint(int x) +static void print_int(int x) { printf("%d\n", x); } +static void gpio_set(int channel, int level) +{ + leds_out_write(!!level); +} + static const struct symbol syscalls[] = { - {"__syscall_printint", printint}, + {"__syscall_print_int", print_int}, + {"__syscall_gpio_set", gpio_set}, {NULL, NULL} };