diff --git a/c/common/i2cdriver.c b/c/common/i2cdriver.c index 1860ba0..6e864be 100644 --- a/c/common/i2cdriver.c +++ b/c/common/i2cdriver.c @@ -3,7 +3,9 @@ #include #include #include +#if !defined(WIN32) #include +#endif #include #include #define __STDC_FORMAT_MACROS diff --git a/c/go b/c/go index 9aef8b5..f17000d 100644 --- a/c/go +++ b/c/go @@ -2,9 +2,10 @@ set -e rm -rf build/* make -f linux/Makefile -build/i2ccl /dev/ttyUSB0 i +# build/i2ccl /dev/ttyUSB0 i d +# build/i2ccl /dev/ttyUSB0 w 0x48 3 r 0x48 2 -# make -f win32/Makefile +make -f win32/Makefile # cp build/spicl.exe /data/win10/ # # rm -f win32gui/obj/* win32gui/bin/Win32App.exe diff --git a/c/win32/Makefile b/c/win32/Makefile new file mode 100644 index 0000000..d499261 --- /dev/null +++ b/c/win32/Makefile @@ -0,0 +1,8 @@ +CC = /usr/bin/i686-w64-mingw32-g++ +CFLAGS += -I common -static-libgcc -static-libstdc++ + +all: build/i2ccl.exe + +build/i2ccl.exe: win32/i2c.c common/i2cdriver.c + mkdir -p build/ + $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $^ diff --git a/c/win32/i2c.c b/c/win32/i2c.c new file mode 100644 index 0000000..c9271f9 --- /dev/null +++ b/c/win32/i2c.c @@ -0,0 +1,18 @@ +#include +#include + +#include "i2cdriver.h" + +int main(int argc, char *argv[]) +{ + I2CDriver sd; + if (argc < 2) { + printf("Usage: i2ccl \n"); + exit(1); + } else { + i2c_connect(&sd, argv[1]); + if (!sd.connected) + exit(1); + return i2c_commands(&sd, argc - 2, argv + 2); + } +}