Skip to content

Commit cd6e7bb

Browse files
committed
USB: Convert to Chrono
1 parent d1ae0d5 commit cd6e7bb

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

drivers/internal/AsyncOp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AsyncOp: public LinkEntry {
6868
*
6969
* @note - the host object's lock MUST NOT be held when this call is made
7070
*/
71-
void wait(rtos::Mutex *host_mutex, uint32_t milliseconds = osWaitForever);
71+
void wait(rtos::Mutex *host_mutex, rtos::Kernel::Clock::duration_u32 rel_time = rtos::Kernel::wait_for_u32_forever);
7272

7373
/**
7474
* Abort this asynchronous operation

drivers/source/usb/AsyncOp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AsyncOp::~AsyncOp()
3838
MBED_ASSERT(_list == NULL);
3939
}
4040

41-
void AsyncOp::wait(rtos::Mutex *host_mutex, uint32_t milliseconds)
41+
void AsyncOp::wait(rtos::Mutex *host_mutex, rtos::Kernel::Clock::duration_u32 rel_time)
4242
{
4343
// Optimization so semaphore is only created if necessary
4444
core_util_critical_section_enter();
@@ -63,7 +63,7 @@ void AsyncOp::wait(rtos::Mutex *host_mutex, uint32_t milliseconds)
6363
return;
6464
}
6565

66-
if (sem.try_acquire_for(milliseconds)) {
66+
if (sem.try_acquire_for(rel_time)) {
6767
// Operation completion signaled semaphore
6868
return;
6969
}

drivers/source/usb/USBMouse.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "ThisThread.h"
2222
#include "usb_phy_api.h"
2323

24+
using namespace std::chrono_literals;
2425

2526
USBMouse::USBMouse(bool connect_blocking, MOUSE_TYPE mouse_type, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
2627
USBHID(get_usb_phy(), 0, 0, vendor_id, product_id, product_release)
@@ -157,7 +158,7 @@ bool USBMouse::double_click()
157158
_mutex.unlock();
158159
return false;
159160
}
160-
rtos::ThisThread::sleep_for(100);
161+
rtos::ThisThread::sleep_for(100ms);
161162
bool ret = click(MOUSE_LEFT);
162163

163164
_mutex.unlock();
@@ -172,7 +173,7 @@ bool USBMouse::click(uint8_t button)
172173
_mutex.unlock();
173174
return false;
174175
}
175-
rtos::ThisThread::sleep_for(10);
176+
rtos::ThisThread::sleep_for(10ms);
176177
bool ret = update(0, 0, 0, 0);
177178

178179
_mutex.unlock();

drivers/source/usb/USBMouseKeyboard.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "usb_phy_api.h"
2121
#include "ThisThread.h"
2222

23+
using namespace std::chrono_literals;
24+
2325
typedef struct {
2426
unsigned char usage;
2527
unsigned char modifier;
@@ -709,7 +711,7 @@ bool USBMouseKeyboard::doubleClick()
709711
_mutex.unlock();
710712
return false;
711713
}
712-
rtos::ThisThread::sleep_for(100);
714+
rtos::ThisThread::sleep_for(100ms);
713715
bool ret = click(MOUSE_LEFT);
714716

715717
_mutex.unlock();
@@ -724,7 +726,7 @@ bool USBMouseKeyboard::click(uint8_t button)
724726
_mutex.unlock();
725727
return false;
726728
}
727-
rtos::ThisThread::sleep_for(10);
729+
rtos::ThisThread::sleep_for(10ms);
728730
bool ret = update(0, 0, 0, 0);
729731

730732
_mutex.unlock();

0 commit comments

Comments
 (0)