File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -54,15 +54,11 @@ void mp_hal_wait_sem(struct k_sem *sem, uint32_t timeout_ms) {
54
54
mp_handle_pending (true);
55
55
MP_THREAD_GIL_EXIT ();
56
56
k_timeout_t wait ;
57
+ uint32_t dt = mp_hal_ticks_ms () - t0 ;
57
58
if (timeout_ms == (uint32_t )-1 ) {
58
59
wait = K_FOREVER ;
59
60
} else {
60
- uint32_t dt = mp_hal_ticks_ms () - t0 ;
61
- if (dt >= timeout_ms ) {
62
- MP_THREAD_GIL_ENTER ();
63
- return ;
64
- }
65
- wait = K_MSEC (timeout_ms - dt );
61
+ wait = K_MSEC ((timeout_ms > dt ) ? (timeout_ms - dt ) : 0 );
66
62
}
67
63
k_poll (wait_events , sem ? 2 : 1 , wait );
68
64
if (wait_events [0 ].state == K_POLL_STATE_SIGNALED ) {
@@ -73,5 +69,9 @@ void mp_hal_wait_sem(struct k_sem *sem, uint32_t timeout_ms) {
73
69
MP_THREAD_GIL_ENTER ();
74
70
return ;
75
71
}
72
+ if (dt >= timeout_ms ) {
73
+ MP_THREAD_GIL_ENTER ();
74
+ return ;
75
+ }
76
76
}
77
77
}
You can’t perform that action at this time.
0 commit comments