[sam] Fixed wrap-around bug in delay() (Mark Tillotson)

Fixes #1736
This commit is contained in:
Cristian Maglie 2013-12-14 00:31:45 +01:00
parent e2b15c852b
commit 2e7b645571
2 changed files with 10 additions and 4 deletions

View File

@ -8,6 +8,9 @@ ARDUINO 1.5.6 BETA
* TFT: warning messages in PImage class and strings inside examples now stored in flash to save RAM.
* Ethernet: added operator == for EthernetClient class (Norbert Truchsess)
[core]
* sam: Fixed wrap-around bug in delay() (Mark Tillotson)
ARDUINO 1.5.5 BETA 2013.11.28
NOTICE:

View File

@ -25,7 +25,7 @@ extern "C" {
uint32_t millis( void )
{
// todo: ensure no interrupts
return GetTickCount() ;
return GetTickCount() ;
}
// Interrupt-compatible version of micros
@ -74,9 +74,12 @@ uint32_t micros( void )
void delay( uint32_t ms )
{
uint32_t end = GetTickCount() + ms;
while (GetTickCount() < end)
yield();
if (ms == 0)
return;
uint32_t start = GetTickCount();
do {
yield();
} while (GetTickCount() - start < ms);
}
#if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */