Commit 8b25e7a5 authored by Tristan Gingold's avatar Tristan Gingold

fip_urv: can remotely control the leds.

parent 303b3a49
# If it exists includes Makefile.specific. In this Makefile, you should put
# specific Makefile code that you want to run before this. For example,
# build a particular environment.
-include Makefile.specific
# define REPO_PARENT to get build environment
REPO_PARENT?=../../masterfip
-include $(REPO_PARENT)/parent_common.mk
-include ../version.mk
MFIP ?= $(REPO_PARENT)
TRTL ?= $(REPO_PARENT)/mockturtle/software
# use delivered version
CFLAGS += --std=gnu99 -O
CFLAGS += -Wall -ggdb $(DBG) -I. -I$(MFIP) -I$(MFIP)/include -I$(MFIP)/lib
CFLAGS += -D__GIT_VER__="\"$(GIT_VER)\"" -D__GIT_USR__="\"$(GIT_USR)\""
CXXFLAGS = $(CFLAGS) -std=c++11
LDLIBS += -Wl,-Bstatic -L$(MFIP)/lib -L$(TRTL)/lib
LDLIBS += -lmasterfip -lmockturtle
LDLIBS += -Wl,-Bdynamic -lpthread -lm -lrt
PROG := fip_urv
all: $(PROG)
.PHONY: all clean
clean:
$(RM) *.{o,so,a} $(PROG)
cleanall:
$(RM) *.{$(ALL_CPUS_COMMAS)}.{o,so,a}
PROGS_LIST=hello
install: install_prog_global
This diff is collapsed.
#define CMD_ERROR 0
#define CMD_SET_LEDS 1
#define CMD_GET_LEDS 2
#include <stdint.h>
#include "fip_urv_regs.h"
#include "fip_urv_cmd.h"
int
main (void)
......@@ -8,7 +9,8 @@ main (void)
volatile struct fip_urv_regs *regs =
(volatile struct fip_urv_regs *)0x100000;
int j;
unsigned char b;
unsigned char cmd;
unsigned char reply[8];
unsigned char rdy;
/* Init. */
......@@ -22,7 +24,20 @@ main (void)
/* Check for FIP message. */
unsigned int status = regs->fip_status;
regs->leds = (leds << 3) | status;
/* Control leds. */
if (leds & 0x80)
regs->leds = leds;
else
{
regs->leds = (leds << 3) | status;
j++;
if (j == 1000000)
{
leds = ((leds << 1) & 0x7) | ((leds >> 2) & 1);
j = 0;
}
}
/* Send leds status. */
if (status & 1)
......@@ -31,27 +46,41 @@ main (void)
/* Consume variable. */
regs->fip_var1 = 1;
b = regs->fip_reg[0x02];
cmd = regs->fip_reg[0x02];
/* Default reply: command + id. */
reply[0] = cmd;
reply[1] = regs->fip_reg[0x03];
switch (cmd)
{
case CMD_GET_LEDS:
reply[4] = leds;
break;
case CMD_SET_LEDS:
leds = regs->fip_reg[0x04];
break;
default:
reply[0] = CMD_ERROR;
break;
}
rdy = 1;
regs->fip_var1 = 0;
}
if ((status & 2) && rdy)
{
int i;
/* Produce variable. */
regs->fip_var3 = 1;
regs->fip_reg[0x102] = b;
regs->fip_reg[0x103] = leds;
for (i = 0; i < sizeof(reply); i++)
regs->fip_reg[0x102 + i] = reply[i];
regs->fip_var3 = 0;
rdy = 0;
}
j++;
if (j == 1000000)
{
leds = ((leds << 1) & 0x7) | ((leds >> 2) & 1);
j = 0;
}
}
}
#define CMD_ERROR 0
#define CMD_SET_LEDS 1
#define CMD_GET_LEDS 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment