Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
3cc87b1e
Commit
3cc87b1e
authored
Oct 29, 2016
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix/modtime: Switch ticks/sleep_ms/us() to utime_mphal.
parent
6a870840
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
36 deletions
+4
-36
unix/modtime.c
unix/modtime.c
+4
-36
No files found.
unix/modtime.c
View file @
3cc87b1e
...
...
@@ -77,22 +77,6 @@ STATIC mp_obj_t mod_time_time(void) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
mod_time_time_obj
,
mod_time_time
);
STATIC
mp_obj_t
mod_time_ticks_us
(
void
)
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
mp_uint_t
us
=
tv
.
tv_sec
*
1000000
+
tv
.
tv_usec
;
return
MP_OBJ_NEW_SMALL_INT
(
us
&
MP_SMALL_INT_POSITIVE_MASK
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
mod_time_ticks_us_obj
,
mod_time_ticks_us
);
STATIC
mp_obj_t
mod_time_ticks_ms
(
void
)
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
mp_uint_t
ms
=
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
return
MP_OBJ_NEW_SMALL_INT
(
ms
&
MP_SMALL_INT_POSITIVE_MASK
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
mod_time_ticks_ms_obj
,
mod_time_ticks_ms
);
// Note: this is deprecated since CPy3.3, but pystone still uses it.
STATIC
mp_obj_t
mod_time_clock
(
void
)
{
#if MICROPY_PY_BUILTINS_FLOAT
...
...
@@ -143,22 +127,6 @@ STATIC mp_obj_t mod_time_sleep(mp_obj_t arg) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_time_sleep_obj
,
mod_time_sleep
);
STATIC
mp_obj_t
mod_time_sleep_ms
(
mp_obj_t
arg
)
{
MP_THREAD_GIL_EXIT
();
usleep
(
mp_obj_get_int
(
arg
)
*
1000
);
MP_THREAD_GIL_ENTER
();
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_time_sleep_ms_obj
,
mod_time_sleep_ms
);
STATIC
mp_obj_t
mod_time_sleep_us
(
mp_obj_t
arg
)
{
MP_THREAD_GIL_EXIT
();
usleep
(
mp_obj_get_int
(
arg
));
MP_THREAD_GIL_ENTER
();
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_time_sleep_us_obj
,
mod_time_sleep_us
);
STATIC
mp_obj_t
mod_time_strftime
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
time_t
t
;
if
(
n_args
==
1
)
{
...
...
@@ -179,11 +147,11 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_utime
)
},
{
MP_ROM_QSTR
(
MP_QSTR_clock
),
MP_ROM_PTR
(
&
mod_time_clock_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_sleep
),
MP_ROM_PTR
(
&
mod_time_sleep_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_sleep_ms
),
MP_ROM_PTR
(
&
m
od_
time_sleep_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_sleep_us
),
MP_ROM_PTR
(
&
m
od_
time_sleep_us_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_sleep_ms
),
MP_ROM_PTR
(
&
m
p_u
time_sleep_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_sleep_us
),
MP_ROM_PTR
(
&
m
p_u
time_sleep_us_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_time
),
MP_ROM_PTR
(
&
mod_time_time_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_ticks_ms
),
MP_ROM_PTR
(
&
m
od_
time_ticks_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_ticks_us
),
MP_ROM_PTR
(
&
m
od_
time_ticks_us_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_ticks_ms
),
MP_ROM_PTR
(
&
m
p_u
time_ticks_ms_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_ticks_us
),
MP_ROM_PTR
(
&
m
p_u
time_ticks_us_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_ticks_diff
),
MP_ROM_PTR
(
&
mp_utime_ticks_diff_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_strftime
),
MP_ROM_PTR
(
&
mod_time_strftime_obj
)
},
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment