File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1049,9 +1049,8 @@ void operator delete[](void *ptr)
1049
1049
extern " C" clock_t clock ()
1050
1050
{
1051
1051
_mutex->lock ();
1052
- clock_t t = us_ticker_read ( );
1052
+ clock_t t = ticker_read ( get_us_ticker_data () );
1053
1053
t /= 1000000 / CLOCKS_PER_SEC; // convert to processor time
1054
1054
_mutex->unlock ();
1055
1055
return t;
1056
1056
}
1057
-
Original file line number Diff line number Diff line change @@ -30,8 +30,9 @@ void wait_ms(int ms) {
30
30
}
31
31
32
32
void wait_us (int us ) {
33
- uint32_t start = us_ticker_read ();
34
- while ((us_ticker_read () - start ) < (uint32_t )us );
33
+ const ticker_data_t * const ticker = get_us_ticker_data ();
34
+ uint32_t start = ticker_read (ticker );
35
+ while ((ticker_read (ticker ) - start ) < (uint32_t )us );
35
36
}
36
37
37
38
#endif // #ifndef MBED_CONF_RTOS_PRESENT
Original file line number Diff line number Diff line change 22
22
#include " hal/us_ticker_api.h"
23
23
#include " rtos/rtos.h"
24
24
#include " platform/mbed_critical.h"
25
+ #include " platform/mbed_sleep.h"
25
26
26
27
void wait (float s) {
27
28
wait_us (s * 1000000 .0f );
@@ -32,15 +33,19 @@ void wait_ms(int ms) {
32
33
}
33
34
34
35
void wait_us (int us) {
35
- uint32_t start = us_ticker_read ();
36
+ const ticker_data_t *const ticker = get_us_ticker_data ();
37
+
38
+ uint32_t start = ticker_read (ticker);
36
39
// Use the RTOS to wait for millisecond delays if possible
37
40
int ms = us / 1000 ;
38
41
if ((ms > 0 ) && core_util_are_interrupts_enabled ()) {
42
+ sleep_manager_lock_deep_sleep ();
39
43
Thread::wait ((uint32_t )ms);
44
+ sleep_manager_unlock_deep_sleep ();
40
45
}
41
46
// Use busy waiting for sub-millisecond delays, or for the whole
42
47
// interval if interrupts are not enabled
43
- while ((us_ticker_read ( ) - start) < (uint32_t )us);
48
+ while ((ticker_read (ticker ) - start) < (uint32_t )us);
44
49
}
45
50
46
51
#endif // #if MBED_CONF_RTOS_PRESENT
You can’t perform that action at this time.
0 commit comments