File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333#include "py/obj.h"
3434#include "py/mphal.h"
3535#include "py/smallint.h"
36+ #include "py/runtime.h"
3637#include "extmod/utime_mphal.h"
3738
3839STATIC mp_obj_t time_sleep (mp_obj_t seconds_o ) {
40+ MP_THREAD_GIL_EXIT ();
3941 #if MICROPY_PY_BUILTINS_FLOAT
4042 mp_hal_delay_ms (1000 * mp_obj_get_float (seconds_o ));
4143 #else
4244 mp_hal_delay_ms (1000 * mp_obj_get_int (seconds_o ));
4345 #endif
46+ MP_THREAD_GIL_ENTER ();
4447 return mp_const_none ;
4548}
4649MP_DEFINE_CONST_FUN_OBJ_1 (mp_utime_sleep_obj , time_sleep );
4750
4851STATIC mp_obj_t time_sleep_ms (mp_obj_t arg ) {
4952 mp_int_t ms = mp_obj_get_int (arg );
5053 if (ms > 0 ) {
54+ MP_THREAD_GIL_EXIT ();
5155 mp_hal_delay_ms (ms );
56+ MP_THREAD_GIL_ENTER ();
5257 }
5358 return mp_const_none ;
5459}
@@ -57,7 +62,9 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms);
5762STATIC mp_obj_t time_sleep_us (mp_obj_t arg ) {
5863 mp_int_t us = mp_obj_get_int (arg );
5964 if (us > 0 ) {
65+ MP_THREAD_GIL_EXIT ();
6066 mp_hal_delay_us (us );
67+ MP_THREAD_GIL_ENTER ();
6168 }
6269 return mp_const_none ;
6370}
You can’t perform that action at this time.
0 commit comments