Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
6a870840
Commit
6a870840
authored
8 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
extmod/utime_mphal: Add MP_THREAD_GIL_EXIT/ENTER warppers for sleep functions.
Ported from unix port.
parent
99ed0f25
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extmod/utime_mphal.c
+7
-0
7 additions, 0 deletions
extmod/utime_mphal.c
with
7 additions
and
0 deletions
extmod/utime_mphal.c
+
7
−
0
View file @
6a870840
...
@@ -33,14 +33,17 @@
...
@@ -33,14 +33,17 @@
#include
"py/obj.h"
#include
"py/obj.h"
#include
"py/mphal.h"
#include
"py/mphal.h"
#include
"py/smallint.h"
#include
"py/smallint.h"
#include
"py/runtime.h"
#include
"extmod/utime_mphal.h"
#include
"extmod/utime_mphal.h"
STATIC
mp_obj_t
time_sleep
(
mp_obj_t
seconds_o
)
{
STATIC
mp_obj_t
time_sleep
(
mp_obj_t
seconds_o
)
{
MP_THREAD_GIL_EXIT
();
#if MICROPY_PY_BUILTINS_FLOAT
#if MICROPY_PY_BUILTINS_FLOAT
mp_hal_delay_ms
(
1000
*
mp_obj_get_float
(
seconds_o
));
mp_hal_delay_ms
(
1000
*
mp_obj_get_float
(
seconds_o
));
#else
#else
mp_hal_delay_ms
(
1000
*
mp_obj_get_int
(
seconds_o
));
mp_hal_delay_ms
(
1000
*
mp_obj_get_int
(
seconds_o
));
#endif
#endif
MP_THREAD_GIL_ENTER
();
return
mp_const_none
;
return
mp_const_none
;
}
}
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_utime_sleep_obj
,
time_sleep
);
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_utime_sleep_obj
,
time_sleep
);
...
@@ -48,7 +51,9 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
...
@@ -48,7 +51,9 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
STATIC
mp_obj_t
time_sleep_ms
(
mp_obj_t
arg
)
{
STATIC
mp_obj_t
time_sleep_ms
(
mp_obj_t
arg
)
{
mp_int_t
ms
=
mp_obj_get_int
(
arg
);
mp_int_t
ms
=
mp_obj_get_int
(
arg
);
if
(
ms
>
0
)
{
if
(
ms
>
0
)
{
MP_THREAD_GIL_EXIT
();
mp_hal_delay_ms
(
ms
);
mp_hal_delay_ms
(
ms
);
MP_THREAD_GIL_ENTER
();
}
}
return
mp_const_none
;
return
mp_const_none
;
}
}
...
@@ -57,7 +62,9 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms);
...
@@ -57,7 +62,9 @@ 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
)
{
STATIC
mp_obj_t
time_sleep_us
(
mp_obj_t
arg
)
{
mp_int_t
us
=
mp_obj_get_int
(
arg
);
mp_int_t
us
=
mp_obj_get_int
(
arg
);
if
(
us
>
0
)
{
if
(
us
>
0
)
{
MP_THREAD_GIL_EXIT
();
mp_hal_delay_us
(
us
);
mp_hal_delay_us
(
us
);
MP_THREAD_GIL_ENTER
();
}
}
return
mp_const_none
;
return
mp_const_none
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment