diff --git a/Makefile b/Makefile index e64d860..1ea40d4 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ $(OBJDIR)/p1load.o \ $(OBJDIR)/ploader.o \ $(foreach x, $(OSINT), $(OBJDIR)/$(x).o) -CFLAGS+=-Wall +CFLAGS+=-Wall -DOS_$(OS) LDFLAGS=$(CFLAGS) .PHONY: default @@ -53,34 +53,20 @@ default: $(TARGET) DIRS=$(OBJDIR) $(BINDIR) $(TARGET): $(BINDIR) $(OBJDIR) $(OBJS) - @$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) - @$(ECHO) link $@ + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(OBJDIR)/%.o: $(SRCDIR)/%.c $(HDRS) $(OBJDIR) - @$(CC) $(CFLAGS) -c $< -o $@ - @$(ECHO) $(CC) $@ - -$(OBJDIR)/%.o: $(OBJDIR)/%.c $(HDRS) $(OBJDIR) - @$(CC) $(CFLAGS) -c $< -o $@ - @$(ECHO) $(CC) $@ - -.PHONY: bin2c -bin2c: $(BINDIR)/bin2c$(EXT) - -$(BINDIR)/bin2c$(EXT): $(SRCDIR)/tools/bin2c.c $(BINDIR) - @$(CC) $(CFLAGS) $(LDFLAGS) $(SRCDIR)/tools/bin2c.c -o $@ - @$(ECHO) cc $@ + $(CC) $(CFLAGS) -c $< -o $@ $(DIRS): $(MKDIR) $@ .PHONY: clean clean: - @$(RM) -f -r $(OBJDIR) - @$(RM) -f -r $(PROPOBJDIR) - @$(RM) -f -r $(BINDIR) + $(RM) -f -r $(OBJDIR) + $(RM) -f -r $(BINDIR) -.PHONY: -clean-all: clean - @$(RM) -f -r obj - @$(RM) -f -r bin +.PHONY: clean-all +clean-all: + $(RM) -f -r obj + $(RM) -f -r bin diff --git a/enumcom.c b/enumcom.c index 9cacd62..29ca0d3 100755 --- a/enumcom.c +++ b/enumcom.c @@ -30,6 +30,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ************************************************************************/ +#define INITGUID + #include #include #include @@ -37,9 +39,7 @@ #include #include -#ifndef GUID_DEVINTERFACE_COMPORT DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73); -#endif #ifdef MAIN int CheckPort(const char* port, void* data) diff --git a/p1load.c b/p1load.c index 89a7c8e..5f0e095 100644 --- a/p1load.c +++ b/p1load.c @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include #include #include "ploader.h" #include "osint.h" diff --git a/ploader.c b/ploader.c index dd0979f..2e050c4 100644 --- a/ploader.c +++ b/ploader.c @@ -1,3 +1,8 @@ +#ifdef OS_msys +#include +#else +#include +#endif #include "ploader.h" #ifndef TRUE @@ -7,6 +12,7 @@ #define ACK_TIMEOUT 20 +static int ms_sleep(unsigned long msecs); static void SerialInit(PL_state *state); static void TByte(PL_state *state, uint8_t x); static void TLong(PL_state *state, uint32_t x); @@ -36,7 +42,7 @@ int PL_LoadSpinBinary(PL_state *state, int loadType, uint8_t *image, int size) TLong(state, data); } TComm(state); - usleep(1000); + ms_sleep(1); /* wait for an ACK */ while (--retries >= 0) { @@ -51,6 +57,16 @@ int PL_LoadSpinBinary(PL_state *state, int loadType, uint8_t *image, int size) return retries >= 0 ? 0 : -1; } +static int ms_sleep(unsigned long msecs) +{ + struct timespec req; + req.tv_sec = (int)(msecs / 1000L); + req.tv_nsec = (msecs - (req.tv_sec * 1000)) * 1000000L; + while (nanosleep(&req, &req) < 0) + ; + return 1; +} + /* this code is adapted from Chip Gracey's PNut IDE */ int PL_HardwareFound(PL_state *state, int *pVersion)