From 0f6f9a79bfb1234bbfe2c561d4ce18953750c2e8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 28 Jul 2013 23:26:55 +0200 Subject: rename i2cwrite to i2cset for i2c-tools compatibility --- commandline/Makefile | 6 +++--- commandline/i2cset.c | 31 +++++++++++++++++++++++++++++++ commandline/i2cwrite.c | 22 ---------------------- 3 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 commandline/i2cset.c delete mode 100644 commandline/i2cwrite.c diff --git a/commandline/Makefile b/commandline/Makefile index 587f86c..3a1c918 100644 --- a/commandline/Makefile +++ b/commandline/Makefile @@ -9,7 +9,7 @@ LIBS = $(USBLIBS) PREFIX ?= /usr/local bin_dir = ${DESTDIR}${PREFIX}/bin -PROGRAMS = vusb-i2c vusb-i2cdetect vusb-i2cwrite vusb-i2cget +PROGRAMS = vusb-i2c vusb-i2cdetect vusb-i2cset vusb-i2cget all: $(PROGRAMS) @@ -19,7 +19,7 @@ all: $(PROGRAMS) i2c.o: i2c.c i2c-util.c i2c-util.h i2c-util.o: i2c-util.c i2cdetect.o: i2cdetect.c i2c-util.c i2c-util.h -i2cwrite.o: i2cwrite.c i2c-util.c i2c-util.h +i2cset.o: i2cset.c i2c-util.c i2c-util.h i2cget.o: i2cget.c i2c-util.c i2c-util.h vusb-i2c: i2c.o i2c-util.o @@ -28,7 +28,7 @@ vusb-i2c: i2c.o i2c-util.o vusb-i2cdetect: i2cdetect.o i2c-util.o $(CC) -o $@ $^ $(LIBS) -vusb-i2cwrite: i2cwrite.o i2c-util.o +vusb-i2cset: i2cset.o i2c-util.o $(CC) -o $@ $^ $(LIBS) vusb-i2cget: i2cget.o i2c-util.o diff --git a/commandline/i2cset.c b/commandline/i2cset.c new file mode 100644 index 0000000..971783a --- /dev/null +++ b/commandline/i2cset.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include "i2c-util.h" + +int main(int argc, char **argv) +{ + int i, address, got_ack; + + i2c_init(); + i2c_start(); + + if (argc < 3) { + fputs("Usage: i2cset
", stderr); + return 1; + } + + address = atoi(argv[1]) << 1; + + got_ack = i2c_tx_byte(address); + + for (i = 2; i < argc; i++) { + i2c_tx_byte(atoi(argv[i])); + } + + i2c_stop(); + i2c_deinit(); + + return got_ack ? 0 : 1; +} diff --git a/commandline/i2cwrite.c b/commandline/i2cwrite.c deleted file mode 100644 index 56031f9..0000000 --- a/commandline/i2cwrite.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include -#include -#include "i2c-util.h" - -int main(int argc, char **argv) -{ - int i; - - i2c_init(); - i2c_start(); - - for (i = 1; i < argc; i++) { - i2c_tx_byte(atoi(argv[i])); - } - - i2c_stop(); - i2c_deinit(); - - return 0; -} -- cgit v1.2.3