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
78185e6a
Commit
78185e6a
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal/modpyb: Use utime ticks ms/us functions instead of custom ones.
parent
89738e82
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
stmhal/modpyb.c
+3
-31
3 additions, 31 deletions
stmhal/modpyb.c
with
3 additions
and
31 deletions
stmhal/modpyb.c
+
3
−
31
View file @
78185e6a
...
@@ -72,20 +72,6 @@ STATIC mp_obj_t pyb_fault_debug(mp_obj_t value) {
...
@@ -72,20 +72,6 @@ STATIC mp_obj_t pyb_fault_debug(mp_obj_t value) {
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_fault_debug_obj
,
pyb_fault_debug
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_fault_debug_obj
,
pyb_fault_debug
);
/// \function millis()
/// Returns the number of milliseconds since the board was last reset.
///
/// The result is always a micropython smallint (31-bit signed number), so
/// after 2^30 milliseconds (about 12.4 days) this will start to return
/// negative numbers.
STATIC
mp_obj_t
pyb_millis
(
void
)
{
// We want to "cast" the 32 bit unsigned into a small-int. This means
// copying the MSB down 1 bit (extending the sign down), which is
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
return
MP_OBJ_NEW_SMALL_INT
(
HAL_GetTick
());
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_millis_obj
,
pyb_millis
);
/// \function elapsed_millis(start)
/// \function elapsed_millis(start)
/// Returns the number of milliseconds which have elapsed since `start`.
/// Returns the number of milliseconds which have elapsed since `start`.
///
///
...
@@ -98,25 +84,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
...
@@ -98,25 +84,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
/// # Perform some operation
/// # Perform some operation
STATIC
mp_obj_t
pyb_elapsed_millis
(
mp_obj_t
start
)
{
STATIC
mp_obj_t
pyb_elapsed_millis
(
mp_obj_t
start
)
{
uint32_t
startMillis
=
mp_obj_get_int
(
start
);
uint32_t
startMillis
=
mp_obj_get_int
(
start
);
uint32_t
currMillis
=
HAL_GetTick
();
uint32_t
currMillis
=
mp_hal_ticks_ms
();
return
MP_OBJ_NEW_SMALL_INT
((
currMillis
-
startMillis
)
&
0x3fffffff
);
return
MP_OBJ_NEW_SMALL_INT
((
currMillis
-
startMillis
)
&
0x3fffffff
);
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_elapsed_millis_obj
,
pyb_elapsed_millis
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_elapsed_millis_obj
,
pyb_elapsed_millis
);
/// \function micros()
/// Returns the number of microseconds since the board was last reset.
///
/// The result is always a micropython smallint (31-bit signed number), so
/// after 2^30 microseconds (about 17.8 minutes) this will start to return
/// negative numbers.
STATIC
mp_obj_t
pyb_micros
(
void
)
{
// We want to "cast" the 32 bit unsigned into a small-int. This means
// copying the MSB down 1 bit (extending the sign down), which is
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
return
MP_OBJ_NEW_SMALL_INT
(
mp_hal_ticks_us
());
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_micros_obj
,
pyb_micros
);
/// \function elapsed_micros(start)
/// \function elapsed_micros(start)
/// Returns the number of microseconds which have elapsed since `start`.
/// Returns the number of microseconds which have elapsed since `start`.
///
///
...
@@ -169,9 +141,9 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
...
@@ -169,9 +141,9 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_have_cdc
),
(
mp_obj_t
)
&
pyb_have_cdc_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_have_cdc
),
(
mp_obj_t
)
&
pyb_have_cdc_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_hid
),
(
mp_obj_t
)
&
pyb_hid_send_report_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_hid
),
(
mp_obj_t
)
&
pyb_hid_send_report_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_millis
),
(
mp_obj_t
)
&
pyb_milli
s_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_millis
),
(
mp_obj_t
)
&
mp_utime_ticks_m
s_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_elapsed_millis
),
(
mp_obj_t
)
&
pyb_elapsed_millis_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_elapsed_millis
),
(
mp_obj_t
)
&
pyb_elapsed_millis_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_micros
),
(
mp_obj_t
)
&
pyb_micro
s_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_micros
),
(
mp_obj_t
)
&
mp_utime_ticks_u
s_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_elapsed_micros
),
(
mp_obj_t
)
&
pyb_elapsed_micros_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_elapsed_micros
),
(
mp_obj_t
)
&
pyb_elapsed_micros_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_delay
),
(
mp_obj_t
)
&
mp_utime_sleep_ms_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_delay
),
(
mp_obj_t
)
&
mp_utime_sleep_ms_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_udelay
),
(
mp_obj_t
)
&
mp_utime_sleep_us_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_udelay
),
(
mp_obj_t
)
&
mp_utime_sleep_us_obj
},
...
...
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