runtime: support boards without DDS

This commit is contained in:
Sebastien Bourdeauducq 2016-07-27 19:20:49 +08:00
parent 8fab789e39
commit f1d8848bb1
6 changed files with 30 additions and 1 deletions

View File

@ -18,6 +18,7 @@ static void rtio_output_blind(int channel, int addr, int data)
rtio_o_we_write(1); rtio_o_we_write(1);
} }
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
static void dds_write(int bus_channel, int addr, int data) static void dds_write(int bus_channel, int addr, int data)
{ {
rtio_output_blind(bus_channel, addr, data); rtio_output_blind(bus_channel, addr, data);
@ -39,6 +40,7 @@ static int dds_read(int bus_channel, int addr)
rtio_i_re_write(1); rtio_i_re_write(1);
return r; return r;
} }
#endif
static void send_ready(void) static void send_ready(void)
{ {
@ -73,6 +75,7 @@ void bridge_main(void)
mailbox_acknowledge(); mailbox_acknowledge();
break; break;
} }
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
case MESSAGE_TYPE_BRG_DDS_SEL: { case MESSAGE_TYPE_BRG_DDS_SEL: {
struct msg_brg_dds_sel *msg; struct msg_brg_dds_sel *msg;
@ -119,6 +122,7 @@ void bridge_main(void)
mailbox_acknowledge(); mailbox_acknowledge();
break; break;
} }
#endif /* RTIO_DDS_COUNT */
default: default:
mailbox_acknowledge(); mailbox_acknowledge();
break; break;

View File

@ -1,4 +1,7 @@
#include <generated/csr.h> #include <generated/csr.h>
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
#include <stdio.h> #include <stdio.h>
#include "artiq_personality.h" #include "artiq_personality.h"
@ -221,3 +224,5 @@ void dds_set(long long int timestamp, int bus_channel, int channel,
ftw, pow, phase_mode, amplitude); ftw, pow, phase_mode, amplitude);
} }
} }
#endif /* RTIO_DDS_COUNT */

View File

@ -5,6 +5,8 @@
#include <generated/csr.h> #include <generated/csr.h>
#include <generated/mem.h> #include <generated/mem.h>
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
/* Maximum number of commands in a batch */ /* Maximum number of commands in a batch */
#define DDS_MAX_BATCH 16 #define DDS_MAX_BATCH 16
@ -60,4 +62,6 @@ void dds_batch_exit(void);
void dds_set(long long int timestamp, int bus_channel, int channel, void dds_set(long long int timestamp, int bus_channel, int channel,
unsigned int ftw, unsigned int pow, int phase_mode, unsigned int amplitude); unsigned int ftw, unsigned int pow, int phase_mode, unsigned int amplitude);
#endif /* RTIO_DDS_COUNT */
#endif /* __DDS_H */ #endif /* __DDS_H */

View File

@ -118,10 +118,12 @@ static const struct symbol runtime_exports[] = {
{"rtio_input_timestamp", &rtio_input_timestamp}, {"rtio_input_timestamp", &rtio_input_timestamp},
{"rtio_input_data", &rtio_input_data}, {"rtio_input_data", &rtio_input_data},
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
{"dds_init", &dds_init}, {"dds_init", &dds_init},
{"dds_batch_enter", &dds_batch_enter}, {"dds_batch_enter", &dds_batch_enter},
{"dds_batch_exit", &dds_batch_exit}, {"dds_batch_exit", &dds_batch_exit},
{"dds_set", &dds_set}, {"dds_set", &dds_set},
#endif
{"i2c_init", &i2c_init}, {"i2c_init", &i2c_init},
{"i2c_start", &i2c_start}, {"i2c_start", &i2c_start},

View File

@ -38,13 +38,15 @@ struct monitor_reply {
long long int ttl_overrides; long long int ttl_overrides;
unsigned short int dds_rtio_first_channel; unsigned short int dds_rtio_first_channel;
unsigned short int dds_channels_per_bus; unsigned short int dds_channels_per_bus;
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
unsigned int dds_ftws[CONFIG_RTIO_DDS_COUNT*CONFIG_DDS_CHANNELS_PER_BUS]; unsigned int dds_ftws[CONFIG_RTIO_DDS_COUNT*CONFIG_DDS_CHANNELS_PER_BUS];
#endif
} __attribute__((packed)); } __attribute__((packed));
static void moninj_monitor(const ip_addr_t *addr, u16_t port) static void moninj_monitor(const ip_addr_t *addr, u16_t port)
{ {
struct monitor_reply reply; struct monitor_reply reply;
int i, j; int i;
struct pbuf *reply_p; struct pbuf *reply_p;
reply.ttl_levels = 0; reply.ttl_levels = 0;
@ -66,6 +68,9 @@ static void moninj_monitor(const ip_addr_t *addr, u16_t port)
reply.ttl_overrides |= 1LL << i; reply.ttl_overrides |= 1LL << i;
} }
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
int j;
reply.dds_rtio_first_channel = CONFIG_RTIO_FIRST_DDS_CHANNEL; reply.dds_rtio_first_channel = CONFIG_RTIO_FIRST_DDS_CHANNEL;
reply.dds_channels_per_bus = CONFIG_DDS_CHANNELS_PER_BUS; reply.dds_channels_per_bus = CONFIG_DDS_CHANNELS_PER_BUS;
for(j=0;j<CONFIG_RTIO_DDS_COUNT;j++) { for(j=0;j<CONFIG_RTIO_DDS_COUNT;j++) {
@ -76,6 +81,10 @@ static void moninj_monitor(const ip_addr_t *addr, u16_t port)
reply.dds_ftws[CONFIG_DDS_CHANNELS_PER_BUS*j+i] = rtio_moninj_mon_value_read(); reply.dds_ftws[CONFIG_DDS_CHANNELS_PER_BUS*j+i] = rtio_moninj_mon_value_read();
} }
} }
#else
reply.dds_rtio_first_channel = 0;
reply.dds_channels_per_bus = 0;
#endif
reply_p = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct monitor_reply), PBUF_RAM); reply_p = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct monitor_reply), PBUF_RAM);
if(!reply_p) { if(!reply_p) {

View File

@ -108,6 +108,8 @@ static void ttlo(char *n, char *value)
brg_ttlo(n2, value2); brg_ttlo(n2, value2);
} }
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
static int bus_channel = CONFIG_RTIO_FIRST_DDS_CHANNEL; static int bus_channel = CONFIG_RTIO_FIRST_DDS_CHANNEL;
static void ddsbus(char *n) static void ddsbus(char *n)
@ -360,6 +362,7 @@ static void ddstest(char *n, char *channel)
do_ddstest_one(j); do_ddstest_one(j);
} }
} }
#endif /* RTIO_DDS_COUNT */
#if (defined CSR_SPIFLASH_BASE && defined CONFIG_SPIFLASH_PAGE_SIZE) #if (defined CSR_SPIFLASH_BASE && defined CONFIG_SPIFLASH_PAGE_SIZE)
static void fsread(char *key) static void fsread(char *key)
@ -659,6 +662,7 @@ static void do_command(char *c)
else if(strcmp(token, "ttloe") == 0) ttloe(get_token(&c), get_token(&c)); else if(strcmp(token, "ttloe") == 0) ttloe(get_token(&c), get_token(&c));
else if(strcmp(token, "ttlo") == 0) ttlo(get_token(&c), get_token(&c)); else if(strcmp(token, "ttlo") == 0) ttlo(get_token(&c), get_token(&c));
#if ((defined RTIO_DDS_COUNT) && (RTIO_DDS_COUNT > 0))
else if(strcmp(token, "ddsbus") == 0) ddsbus(get_token(&c)); else if(strcmp(token, "ddsbus") == 0) ddsbus(get_token(&c));
else if(strcmp(token, "ddssel") == 0) ddssel(get_token(&c)); else if(strcmp(token, "ddssel") == 0) ddssel(get_token(&c));
else if(strcmp(token, "ddsw") == 0) ddsw(get_token(&c), get_token(&c)); else if(strcmp(token, "ddsw") == 0) ddsw(get_token(&c), get_token(&c));
@ -668,6 +672,7 @@ static void do_command(char *c)
else if(strcmp(token, "ddsfud") == 0) ddsfud(); else if(strcmp(token, "ddsfud") == 0) ddsfud();
else if(strcmp(token, "ddsftw") == 0) ddsftw(get_token(&c), get_token(&c)); else if(strcmp(token, "ddsftw") == 0) ddsftw(get_token(&c), get_token(&c));
else if(strcmp(token, "ddstest") == 0) ddstest(get_token(&c), get_token(&c)); else if(strcmp(token, "ddstest") == 0) ddstest(get_token(&c), get_token(&c));
#endif
#if (defined CSR_SPIFLASH_BASE && defined CONFIG_SPIFLASH_PAGE_SIZE) #if (defined CSR_SPIFLASH_BASE && defined CONFIG_SPIFLASH_PAGE_SIZE)
else if(strcmp(token, "fserase") == 0) fs_erase(); else if(strcmp(token, "fserase") == 0) fs_erase();