USB: Convert to Chrono

pull/12902/head
Kevin Bracey 2020-02-13 16:37:00 +02:00
parent d1ae0d570c
commit cd6e7bb4cf
4 changed files with 10 additions and 7 deletions

View File

@ -68,7 +68,7 @@ public:
*
* @note - the host object's lock MUST NOT be held when this call is made
*/
void wait(rtos::Mutex *host_mutex, uint32_t milliseconds = osWaitForever);
void wait(rtos::Mutex *host_mutex, rtos::Kernel::Clock::duration_u32 rel_time = rtos::Kernel::wait_for_u32_forever);
/**
* Abort this asynchronous operation

View File

@ -38,7 +38,7 @@ AsyncOp::~AsyncOp()
MBED_ASSERT(_list == NULL);
}
void AsyncOp::wait(rtos::Mutex *host_mutex, uint32_t milliseconds)
void AsyncOp::wait(rtos::Mutex *host_mutex, rtos::Kernel::Clock::duration_u32 rel_time)
{
// Optimization so semaphore is only created if necessary
core_util_critical_section_enter();
@ -63,7 +63,7 @@ void AsyncOp::wait(rtos::Mutex *host_mutex, uint32_t milliseconds)
return;
}
if (sem.try_acquire_for(milliseconds)) {
if (sem.try_acquire_for(rel_time)) {
// Operation completion signaled semaphore
return;
}

View File

@ -21,6 +21,7 @@
#include "ThisThread.h"
#include "usb_phy_api.h"
using namespace std::chrono_literals;
USBMouse::USBMouse(bool connect_blocking, MOUSE_TYPE mouse_type, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
USBHID(get_usb_phy(), 0, 0, vendor_id, product_id, product_release)
@ -157,7 +158,7 @@ bool USBMouse::double_click()
_mutex.unlock();
return false;
}
rtos::ThisThread::sleep_for(100);
rtos::ThisThread::sleep_for(100ms);
bool ret = click(MOUSE_LEFT);
_mutex.unlock();
@ -172,7 +173,7 @@ bool USBMouse::click(uint8_t button)
_mutex.unlock();
return false;
}
rtos::ThisThread::sleep_for(10);
rtos::ThisThread::sleep_for(10ms);
bool ret = update(0, 0, 0, 0);
_mutex.unlock();

View File

@ -20,6 +20,8 @@
#include "usb_phy_api.h"
#include "ThisThread.h"
using namespace std::chrono_literals;
typedef struct {
unsigned char usage;
unsigned char modifier;
@ -709,7 +711,7 @@ bool USBMouseKeyboard::doubleClick()
_mutex.unlock();
return false;
}
rtos::ThisThread::sleep_for(100);
rtos::ThisThread::sleep_for(100ms);
bool ret = click(MOUSE_LEFT);
_mutex.unlock();
@ -724,7 +726,7 @@ bool USBMouseKeyboard::click(uint8_t button)
_mutex.unlock();
return false;
}
rtos::ThisThread::sleep_for(10);
rtos::ThisThread::sleep_for(10ms);
bool ret = update(0, 0, 0, 0);
_mutex.unlock();