From 82a7d9cd997d91590a163eaa63458be73f2ddb27 Mon Sep 17 00:00:00 2001 From: hadaq Date: Sun, 1 Nov 2009 18:31:57 +0000 Subject: [PATCH] updates, added com_reset comand to trbcmd --- libtrbnet/trbcmd.c | 42 +++++++++++++++++++++++++++-------------- libtrbnet/trbnet.c | 47 +++++++++++++++++++++++++++++++++++++++------- libtrbnet/trbnet.h | 2 ++ 3 files changed, 70 insertions(+), 21 deletions(-) diff --git a/libtrbnet/trbcmd.c b/libtrbnet/trbcmd.c index 555c760..ee6ac49 100644 --- a/libtrbnet/trbcmd.c +++ b/libtrbnet/trbcmd.c @@ -16,7 +16,7 @@ static int hexMode = HEXMODE; -static const char trbcmd_version[] = "$Revision: 2.37 $"; +static const char trbcmd_version[] = "$Revision: 2.38 $"; /* ---- User Buffer Size ----------------------------------------------- */ @@ -66,6 +66,8 @@ void usage(const char *progName) "reload FPGA\n"); printf(" reset -> " "reset TRBNetwork\n"); + printf(" comreset -> " + "reset Etrax-FIFO Logic\n"); printf(" f -> " "flush FIFO of channel\n"); printf(" R -> " @@ -701,30 +703,42 @@ int main(int argc, char ** argv) fprintf(stderr, "Command: RESET:\n"); } - if (fpga_register_write(0x10, 0x0000) == -1) { + if (network_reset() == -1) { if (scriptFile != NULL) { fprintf(stderr, "Line #%d: ", lineCtr); } - trb_error("fpga_register_write failed"); + trb_error("TRBNet RESET failed"); exit(EXIT_FAILURE); } + + } else if (strncmp(cmd[0], "reset", CMD_SIZE) == 0) { - if (fpga_register_write(0x10, 0x8000) == -1) { + /*******************************************/ + /* Etrax-FIFO Reset */ + /*******************************************/ + + if (cmdLen != 1) { if (scriptFile != NULL) { - fprintf(stderr, "Line #%d: ", lineCtr); + fprintf(stderr, "Line #%d: Invalid command\n", lineCtr); + } else { + usage(basename(argv[0])); } - trb_error("fpga_register_write failed"); exit(EXIT_FAILURE); - } else { - if (fpga_register_write(0x10, 0x0000) == -1) { - if (scriptFile != NULL) { - fprintf(stderr, "Line #%d: ", lineCtr); - } - trb_error("fpga_register_write failed"); - exit(EXIT_FAILURE); - } } + /* DEBUG Info */ + if (trb_debug > 0) { + fprintf(stderr, "Command: COMRESET:\n"); + } + + if (com_reset() == -1) { + if (scriptFile != NULL) { + fprintf(stderr, "Line #%d: ", lineCtr); + } + trb_error("Etrax RESET failed"); + exit(EXIT_FAILURE); + } + } else if (strncmp(cmd[0], "reload", CMD_SIZE) == 0) { /*********************************************/ diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index a1f10d1..098815a 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -1,4 +1,4 @@ -const char trbnet_version[] = "$Revision: 2.49 $"; +const char trbnet_version[] = "$Revision: 2.50 $"; #include #include @@ -245,12 +245,6 @@ static inline int read32_from_FPGA_dma(uint16_t fifo_address, return -1; } -static void com_reset() -{ - setbitsPC(0x30000); - clrbitsPC(0x30000); -} - /* ------ Internal Functions -------------------------------------------- */ static void TRB_Package_dump(const TRB_Package* pkg) @@ -1538,3 +1532,42 @@ int fpga_register_write(uint16_t reg_address, uint32_t value) return 0; } + +int network_reset() +{ + trb_errno = TRB_NONE; + + if (lockPorts() == -1) return -1; + + /* DEBUG INFO */ + if (trb_debug > 0) { + fprintf(stderr, "network_reset started.\n"); + } + + if (fpga_register_write(0x10, 0x0000) == -1) return -1; + if (fpga_register_write(0x10, 0x8000) == -1) return -1; + if (fpga_register_write(0x10, 0x0000) == -1) return -1; + + if (unlockPorts() == -1) return -1; + + return 0; +} + +int com_reset() +{ + trb_errno = TRB_NONE; + + if (lockPorts() == -1) return -1; + + /* DEBUG INFO */ + if (trb_debug > 0) { + fprintf(stderr, "com_reset started.\n"); + } + + setbitsPC(0x30000); + clrbitsPC(0x30000); + + if (unlockPorts() == -1) return -1; + + return 0; +} diff --git a/libtrbnet/trbnet.h b/libtrbnet/trbnet.h index 5d9c83d..b9281d2 100644 --- a/libtrbnet/trbnet.h +++ b/libtrbnet/trbnet.h @@ -69,7 +69,9 @@ int fpga_register_write(uint16_t reg_address, uint32_t value); int trb_fifo_flush(uint8_t channel); +int network_reset(); +int com_reset(); /* ---------------------------------------------------------------------- */ -- 2.43.0