Merge pull request #5216 from kjbracey-arm/UARTSerial_wait

Avoid wait_ms() spin
pull/4955/head
Jimmy Brisson 2017-10-13 09:20:41 -05:00 committed by GitHub
commit 493e3788e3
3 changed files with 19 additions and 1 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

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

View File

@ -66,7 +66,7 @@ int poll(pollfh fhs[], unsigned nfhs, int timeout)
#ifdef MBED_CONF_RTOS_PRESENT
// TODO - proper blocking
// wait for condition variable, wait queue whatever here
rtos::Thread::yield();
rtos::Thread::wait(1);
#endif
}
return count;