Avoid wait_ms() spin

System's wait_ms() spins to achieve a precise delay - we don't want this.
Call Thread::wait directly.
pull/5216/head
Kevin Bracey 2017-09-28 10:44:43 +03:00
parent 3759d03fa1
commit b18332cb4d
2 changed files with 18 additions and 0 deletions

View File

@ -19,7 +19,12 @@
#include <errno.h>
#include "UARTSerial.h"
#include "platform/mbed_poll.h"
#if MBED_CONF_RTOS_PRESENT
#include "rtos/Thread.h"
#else
#include "platform/mbed_wait_api.h"
#endif
namespace mbed {
@ -277,6 +282,17 @@ void UARTSerial::tx_irq(void)
}
}
void UARTSerial::wait_ms(uint32_t millisec)
{
/* wait_ms implementation for RTOS spins until exact microseconds - we
* want to just sleep until next tick.
*/
#if MBED_CONF_RTOS_PRESENT
rtos::Thread::wait(millisec);
#else
::wait_ms(millisec);
#endif
}
} //namespace mbed
#endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN)

View File

@ -160,6 +160,8 @@ public:
private:
void wait_ms(uint32_t millisec);
/** SerialBase lock override */
virtual void lock(void);