# HG changeset patch
# User Edouard Tisserant
# Date 1329320396 -3600
# Node ID 2db8b87016a07e258919d12011d80a753093e04d
# Parent  d376a8b0b602fe751c0af91353b3912a0fd58d75
Fixed Win32 timer up to 1ms

diff -r d376a8b0b602 -r 2db8b87016a0 targets/Win32/__init__.py
--- a/targets/Win32/__init__.py	Wed Feb 15 00:44:24 2012 +0100
+++ b/targets/Win32/__init__.py	Wed Feb 15 16:39:56 2012 +0100
@@ -3,4 +3,4 @@
 class Win32_target(toolchain_gcc):
     extension = ".dll"
     def getBuilderLDFLAGS(self):
-        return toolchain_gcc.getBuilderLDFLAGS(self) + ["-shared"]
+        return toolchain_gcc.getBuilderLDFLAGS(self) + ["-shared", "-lwinmm"]
diff -r d376a8b0b602 -r 2db8b87016a0 targets/Win32/plc_Win32_main.c
--- a/targets/Win32/plc_Win32_main.c	Wed Feb 15 00:44:24 2012 +0100
+++ b/targets/Win32/plc_Win32_main.c	Wed Feb 15 16:39:56 2012 +0100
@@ -38,7 +38,7 @@
 	/* arg 2 of SetWaitableTimer take 100 ns interval*/
 	liDueTime.QuadPart =  next / (-100);
 
-	if (!SetWaitableTimer(PLC_timer, &liDueTime, period/1000000, NULL, NULL, 0))
+	if (!SetWaitableTimer(PLC_timer, &liDueTime, period<1000000?1:period/1000000, NULL, NULL, 0))
     {
         printf("SetWaitableTimer failed (%d)\n", GetLastError());
     }
@@ -116,6 +116,7 @@
 
 
     /* Create a waitable timer */
+    timeBeginPeriod(1);
     PLC_timer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer");
     if(NULL == PLC_timer)
     {