diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcc1bba --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +*.o +TAGS +tags +cscope.* + +.*.swp +.#* +*.bak +*~ + +/src/Makefile +/src/config.h +/src/config.log +/src/config.status +/src/libmpsse.a +/src/libmpsse.so + +/src/examples/bitbang +/src/examples/ds1305 +/src/examples/gpio +/src/examples/i2ceeprom +/src/examples/spiflash +/src/examples/spiflashfast diff --git a/src/examples/Makefile b/src/examples/Makefile index 1c03853..51ad472 100644 --- a/src/examples/Makefile +++ b/src/examples/Makefile @@ -1,4 +1,8 @@ -LDFLAGS=-lmpsse +CFLAGS = -g -Wall +CFLAGS += -I.. + +LDFLAGS = -L.. +LDFLAGS += -lmpsse all: spiflash spiflashfast i2ceeprom ds1305 gpio bitbang diff --git a/src/examples/bitbang.c b/src/examples/bitbang.c index 68e9ec6..d7ff97b 100644 --- a/src/examples/bitbang.c +++ b/src/examples/bitbang.c @@ -1,11 +1,14 @@ #include #include +#include #include int main(void) { struct mpsse_context *io = NULL; - int i = 0, retval = EXIT_FAILURE; + int retval = EXIT_FAILURE; + int i = 0; + int j = 0; io = MPSSE(BITBANG, 0, 0); @@ -13,13 +16,15 @@ int main(void) { for(i=0; i<10; i++) { - PinHigh(io, 0); - printf("Pin 0 is: %d\n", PinState(io, 0, -1)); - sleep(1); - - PinLow(io, 0); - printf("Pin 0 is: %d\n", PinState(io, 0, -1)); - sleep(1); + for (j=0; j<8; j++) + { + PinHigh(io, j); + printf("Pin %d is: %d\n", j, PinState(io, j, -1)); + usleep(100000); + + PinLow(io, j); + printf("Pin %d is: %d\n", j, PinState(io, j, -1)); + } } retval = EXIT_SUCCESS; diff --git a/src/examples/gpio.c b/src/examples/gpio.c index 326b626..47aa87e 100644 --- a/src/examples/gpio.c +++ b/src/examples/gpio.c @@ -1,25 +1,29 @@ #include #include +#include #include int main(void) { struct mpsse_context *io = NULL; int i = 0, retval = EXIT_FAILURE; + int j; - io = MPSSE(GPIO, 0, 0); + io = MPSSE(GPIO, 1, 0); if(io && io->open) { for(i=0; i<10; i++) { - PinHigh(io, GPIOL0); - printf("GPIOL0 State: %d\n", PinState(io, GPIOL0, -1)); - sleep(1); + for (j=GPIOL0; j <= GPIOL3; j++) + { + PinHigh(io, j); + printf("GPIOL%d State: %d\n", j - GPIOL0, PinState(io, j, -1)); + usleep(100000); - PinLow(io, GPIOL0); - printf("GPIOL0 State: %d\n", PinState(io, GPIOL0, -1)); - sleep(1); + PinLow(io, j); + printf("GPIOL%d State: %d\n", j - GPIOL0, PinState(io, j, -1)); + } } retval = EXIT_SUCCESS; diff --git a/src/examples/spiflash.c b/src/examples/spiflash.c index 2a86804..3447a4a 100644 --- a/src/examples/spiflash.c +++ b/src/examples/spiflash.c @@ -23,7 +23,7 @@ int main(void) data1 = Read(flash, SIZE); Stop(flash); - if(data) + if(data && data1) { fp = fopen(FOUT, "wb"); if(fp) @@ -35,9 +35,13 @@ int main(void) printf("Dumped %d bytes to %s\n", SIZE, FOUT); retval = EXIT_SUCCESS; } + } + if(data) free(data); - } + + if(data1) + free(data1); } else { diff --git a/src/examples/spiflashfast.c b/src/examples/spiflashfast.c index 271d655..215f018 100644 --- a/src/examples/spiflashfast.c +++ b/src/examples/spiflashfast.c @@ -27,7 +27,7 @@ int main(void) FastRead(flash, data, SIZE); Stop(flash); - if(data) + if(*data) { fp = fopen(FOUT, "wb"); if(fp)