summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-22 12:49:21 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-22 12:49:21 +1100
commit2e3fc778094c0c31c3e15e196e1c7b3b838239fe (patch)
treedc087c8fb6fcd374cc1b0db96313d0e63a3256ac
parent96c35d0ac4b63dfbb746b6391f0850a923ed87d6 (diff)
extmod/utime_mphal: Don't exit/enter the GIL in generic sleep functions.
GIL behaviour should be handled by the port. And ports probably want to define sleep_us so that it doesn't release the GIL, to improve timing accuracy.
-rw-r--r--extmod/utime_mphal.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/extmod/utime_mphal.c b/extmod/utime_mphal.c
index f447b3a68..e99ba46ce 100644
--- a/extmod/utime_mphal.c
+++ b/extmod/utime_mphal.c
@@ -37,13 +37,11 @@
#include "extmod/utime_mphal.h"
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
- MP_THREAD_GIL_EXIT();
#if MICROPY_PY_BUILTINS_FLOAT
mp_hal_delay_ms(1000 * mp_obj_get_float(seconds_o));
#else
mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o));
#endif
- MP_THREAD_GIL_ENTER();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
@@ -51,9 +49,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
mp_int_t ms = mp_obj_get_int(arg);
if (ms > 0) {
- MP_THREAD_GIL_EXIT();
mp_hal_delay_ms(ms);
- MP_THREAD_GIL_ENTER();
}
return mp_const_none;
}
@@ -62,9 +58,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms);
STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
mp_int_t us = mp_obj_get_int(arg);
if (us > 0) {
- MP_THREAD_GIL_EXIT();
mp_hal_delay_us(us);
- MP_THREAD_GIL_ENTER();
}
return mp_const_none;
}