From a7e50d2f674c2bbaa00426019708662637cd3179 Mon Sep 17 00:00:00 2001 From: Ludwig Maier Date: Mon, 9 Dec 2013 14:21:30 +0100 Subject: [PATCH] trb_i2c -b option added --- HOWTO_COMPILE.TXT | 28 ---------------------------- trbnetd/server/Makefile | 2 +- trbrich/trb_i2c.c | 27 +++++++++++++++++++++------ 3 files changed, 22 insertions(+), 35 deletions(-) delete mode 100644 HOWTO_COMPILE.TXT diff --git a/HOWTO_COMPILE.TXT b/HOWTO_COMPILE.TXT deleted file mode 100644 index cbfd879..0000000 --- a/HOWTO_COMPILE.TXT +++ /dev/null @@ -1,28 +0,0 @@ -compile for old Etrax-Board - make distclean - make ETRAX=1 - make ETRAX=1 install - -compile for Pexor Card - make distclean - make PEXOR=1 - make PEXOR=1 install - -compile for new TRB3 - make distclean - make TRB3=1 - make TRB3=1 install - -In case ypu are not root you have to install the libtrbnet_perl libs manually by calling - -sudo make -C libtrbnet_perl PEXOR=1 install or -sudo make -C libtrbnet_perl TRB3=1 install - - -Recommendation to have the most essential commands available: - -cd ~/bin -ln -s $HOME/trbsoft/trbnettools/trbnetd/trbdhcp -ln -s $HOME/trbsoft/trbnettools/trbnetd/trbflash -ln -s $HOME/trbsoft/trbnettools/trbnetd/trbcmd -ln -s $HOME/trbsoft/trbnettools/trbnetd/server/trbnetd diff --git a/trbnetd/server/Makefile b/trbnetd/server/Makefile index c747f11..a67084a 100644 --- a/trbnetd/server/Makefile +++ b/trbnetd/server/Makefile @@ -103,7 +103,7 @@ depend: install: $(TARGETS) mkdir -p $(DESTDIR)/bin - install -m 775 $(TARGETS) $(DESTDIR)/binlocal/ + install -m 775 $(TARGETS) $(DESTDIR)/bin/ # ------------ Dependencies -------------------------------------------- diff --git a/trbrich/trb_i2c.c b/trbrich/trb_i2c.c index f358bc0..c2b0acf 100644 --- a/trbrich/trb_i2c.c +++ b/trbrich/trb_i2c.c @@ -24,10 +24,12 @@ static const unsigned int timeout = 1000; void usage(const char *progName) { - printf("Usage: %s [-h] [-d] [-d level] [-V] \n", progName); + printf("Usage: %s [-h] [-d] [-b numBytes] [-d level] [-V] \n", + progName); printf("Options:\n"); printf(" -h give this help\n"); printf(" -s SPI Mode\n"); + printf(" -b number of bytes to be read 1..4\n"); printf(" -d turn on Debugging Information\n"); printf(" -V Version number\n"); printf("\nCommands:\n"); @@ -133,10 +135,11 @@ int main(int argc, char** argv) { int i; int spi_mode = 0; + unsigned int num_bytes = 0; trb_debug = 0; /* Parse Arguments */ - while ((i = getopt(argc, argv, "+hsd:V")) != -1) { + while ((i = getopt(argc, argv, "+hsb:d:V")) != -1) { switch (i) { case '?': usage(basename(argv[0])); @@ -148,6 +151,13 @@ int main(int argc, char** argv) spi_mode = 1; trb_i2c_register = 0x8060; break; + case 'b': + num_bytes = strtoul(optarg, NULL, 0); + if (num_bytes > 4) { + usage(basename(argv[0])); + exit(EXIT_FAILURE); + } + break; case 'd': trb_debug = strtoul(optarg, NULL, 0); break; @@ -268,10 +278,15 @@ int main(int argc, char** argv) } /* Read Value */ - value = spi_mode == 0 - ? 0xff000000 | (i2c_chip << 16) | (i2c_register << 8) - : 0xff000000 | (i2c_register << 8); - + if (spi_mode == 0) { + value = num_bytes == 0 + ? (0xff000000 | (i2c_chip << 16) | (i2c_register << 8)) + : (0xc0000000 | (num_bytes << 24) | + (i2c_chip << 16) | (i2c_register << 8)); + } else { + value = (0xff000000 | (i2c_register << 8)); + } + if (trb_register_write(trb_address, trb_i2c_register, value) == -1) { trb_error("Error reading value"); clearI2C(trb_address); -- 2.43.0