beremiz

Fixed Win32 timer up to 1ms

2012-02-15, Edouard Tisserant
2db8b87016a0
Parents d376a8b0b602
Children e4e1da75d411
Fixed Win32 timer up to 1ms
--- 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"]
--- 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)
{