forked from M-Labs/artiq
soc/runtime: fix DDS programming
This commit is contained in:
parent
b2bb837d22
commit
06cc9302f8
|
@ -146,27 +146,27 @@ static void rtio_sync(int channel)
|
|||
while(rtio_o_level_read() != 0);
|
||||
}
|
||||
|
||||
#define DDS_FTW 0x0a
|
||||
#define DDS_PTW 0x0e
|
||||
#define DDS_FTW0 0x0a
|
||||
#define DDS_FTW1 0x0b
|
||||
#define DDS_FTW2 0x0c
|
||||
#define DDS_FTW3 0x0d
|
||||
#define DDS_FUD 0x40
|
||||
#define DDS_GPIO 0x41
|
||||
|
||||
#define DDS_WRITE1(addr, data) \
|
||||
#define DDS_READ(addr) \
|
||||
MMPTR(0xb0000000 + (addr)*4)
|
||||
|
||||
#define DDS_WRITE(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);
|
||||
DDS_WRITE(DDS_GPIO, channel);
|
||||
DDS_WRITE(DDS_FTW0, ftw & 0xff);
|
||||
DDS_WRITE(DDS_FTW1, (ftw >> 8) & 0xff);
|
||||
DDS_WRITE(DDS_FTW2, (ftw >> 16) & 0xff);
|
||||
DDS_WRITE(DDS_FTW3, (ftw >> 24) & 0xff);
|
||||
DDS_WRITE(DDS_FUD, 0);
|
||||
}
|
||||
|
||||
static const struct symbol syscalls[] = {
|
||||
|
@ -178,6 +178,22 @@ static const struct symbol syscalls[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static void dds_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
DDS_WRITE(DDS_GPIO, 1 << 7);
|
||||
|
||||
for(i=0;i<8;i++) {
|
||||
DDS_WRITE(DDS_GPIO, i);
|
||||
DDS_WRITE(0x00, 0x78);
|
||||
DDS_WRITE(0x01, 0x00);
|
||||
DDS_WRITE(0x02, 0x00);
|
||||
DDS_WRITE(0x03, 0x00);
|
||||
DDS_WRITE(DDS_FUD, 0);
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*kernel_function)(void);
|
||||
|
||||
int main(void)
|
||||
|
@ -198,6 +214,7 @@ int main(void)
|
|||
if(length > 0) {
|
||||
if(load_elf(syscalls, kbuf, length, kcode, sizeof(kcode))) {
|
||||
flush_cpu_icache();
|
||||
dds_init();
|
||||
rtio_reset_write(0);
|
||||
k();
|
||||
rtio_reset_write(1);
|
||||
|
|
Loading…
Reference in New Issue