From ba088614d85433094b6089d22dbf8bcef211b7f6 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 23 Jul 2014 11:49:48 -0600 Subject: [PATCH] runtime: add dds_program --- artiq/devices/runtime.py | 1 + soc/runtime/main.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/artiq/devices/runtime.py b/artiq/devices/runtime.py index 9aee65d54..c1f19efb4 100644 --- a/artiq/devices/runtime.py +++ b/artiq/devices/runtime.py @@ -8,6 +8,7 @@ _syscalls = [ ("gpio_set", "ii:v"), ("rtio_set", "iii:v"), ("rtio_sync", "i:v"), + ("dds_program", "ii:v"), ] def _str_to_functype(s): diff --git a/soc/runtime/main.c b/soc/runtime/main.c index fe046fe88..1974fe224 100644 --- a/soc/runtime/main.c +++ b/soc/runtime/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "elf_loader.h" @@ -145,11 +146,35 @@ static void rtio_sync(int channel) while(rtio_o_level_read() != 0); } +#define DDS_FTW 0x0a +#define DDS_PTW 0x0e +#define DDS_FUD 0x40 +#define DDS_GPIO 0x41 + +#define DDS_WRITE1(addr, data) \ + MMPTR(0xb0000000 + (addr)*4) = data + +#define DDS_WRITE2(addr, data) \ + DDS_WRITE1(addr, (data) >> 8); \ + DDS_WRITE1((addr) + 1, data) + +#define DDS_WRITE4(addr, data) \ + DDS_WRITE2(addr, (data) >> 16); \ + DDS_WRITE2((addr) + 2, data) + +static void dds_program(int channel, int ftw) +{ + DDS_WRITE1(DDS_GPIO, channel); + DDS_WRITE4(DDS_FTW, ftw); + DDS_WRITE1(DDS_FUD, 0); +} + static const struct symbol syscalls[] = { {"__syscall_rpc", rpc}, {"__syscall_gpio_set", gpio_set}, {"__syscall_rtio_set", rtio_set}, {"__syscall_rtio_sync", rtio_sync}, + {"__syscall_dds_program", dds_program}, {NULL, NULL} };