File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -31,16 +31,8 @@ void wait_ms(int ms) {
31
31
wait_us (ms * 1000 );
32
32
}
33
33
34
- // Wait for the given number of microseconds using a hardware timer
35
- // in a busy wait loop
36
- static void wait_us_busy (int us) {
37
- if (us > 0 ) {
38
- uint32_t start = us_ticker_read ();
39
- while ((us_ticker_read () - start) < (uint32_t )us);
40
- }
41
- }
42
-
43
34
void wait_us (int us) {
35
+ uint32_t start = us_ticker_read ();
44
36
// Use the RTOS to wait for millisecond delays if possible
45
37
int ms = us / 1000 ;
46
38
if ((ms > 0 ) && core_util_are_interrupts_enabled ()) {
@@ -49,7 +41,9 @@ void wait_us(int us) {
49
41
}
50
42
// Use busy waiting for sub-millisecond delays, or for the whole
51
43
// interval if interrupts are not enabled
52
- wait_us_busy (us);
44
+ if (us > 0 ) {
45
+ while ((us_ticker_read () - start) < (uint32_t )us);
46
+ }
53
47
}
54
48
55
49
#endif // #if MBED_CONF_RTOS_PRESENT
You can’t perform that action at this time.
0 commit comments