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
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
ae70e98e
Commit
ae70e98e
authored
9 years ago
by
danicampora
Browse files
Options
Downloads
Patches
Plain Diff
cc3200: Fix time.ticks_* functions.
parent
8faf2dc7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cc3200/mods/modutime.c
+5
-4
5 additions, 4 deletions
cc3200/mods/modutime.c
tests/wipy/time.py
+1
-2
1 addition, 2 deletions
tests/wipy/time.py
with
6 additions
and
6 deletions
cc3200/mods/modutime.c
+
5
−
4
View file @
ae70e98e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include MICROPY_HAL_H
#include MICROPY_HAL_H
#include
"py/nlr.h"
#include
"py/nlr.h"
#include
"py/obj.h"
#include
"py/obj.h"
#include
"py/smallint.h"
#include
"timeutils.h"
#include
"timeutils.h"
#include
"inc/hw_types.h"
#include
"inc/hw_types.h"
#include
"inc/hw_ints.h"
#include
"inc/hw_ints.h"
...
@@ -152,7 +153,7 @@ STATIC mp_obj_t time_ticks_ms(void) {
...
@@ -152,7 +153,7 @@ STATIC mp_obj_t time_ticks_ms(void) {
// We want to "cast" the 32 bit unsigned into a small-int. This means
// 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
// copying the MSB down 1 bit (extending the sign down), which is
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
return
MP_OBJ_NEW_SMALL_INT
(
HAL_GetTick
());
return
MP_OBJ_NEW_SMALL_INT
(
HAL_GetTick
()
&
MP_SMALL_INT_POSITIVE_MASK
);
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
time_ticks_ms_obj
,
time_ticks_ms
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
time_ticks_ms_obj
,
time_ticks_ms
);
...
@@ -160,7 +161,7 @@ STATIC mp_obj_t time_ticks_us(void) {
...
@@ -160,7 +161,7 @@ STATIC mp_obj_t time_ticks_us(void) {
// We want to "cast" the 32 bit unsigned into a small-int. This means
// 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
// copying the MSB down 1 bit (extending the sign down), which is
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
return
MP_OBJ_NEW_SMALL_INT
(
sys_tick_get_microseconds
());
return
MP_OBJ_NEW_SMALL_INT
(
sys_tick_get_microseconds
()
&
MP_SMALL_INT_POSITIVE_MASK
);
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
time_ticks_us_obj
,
time_ticks_us
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
time_ticks_us_obj
,
time_ticks_us
);
...
@@ -168,7 +169,7 @@ STATIC mp_obj_t time_ticks_cpu(void) {
...
@@ -168,7 +169,7 @@ STATIC mp_obj_t time_ticks_cpu(void) {
// We want to "cast" the 32 bit unsigned into a small-int. This means
// 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
// copying the MSB down 1 bit (extending the sign down), which is
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
return
MP_OBJ_NEW_SMALL_INT
(
SysTickValueGet
());
return
MP_OBJ_NEW_SMALL_INT
(
SysTickValueGet
()
&
MP_SMALL_INT_POSITIVE_MASK
);
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
time_ticks_cpu_obj
,
time_ticks_cpu
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
time_ticks_cpu_obj
,
time_ticks_cpu
);
...
@@ -178,7 +179,7 @@ STATIC mp_obj_t time_ticks_diff(mp_obj_t t0, mp_obj_t t1) {
...
@@ -178,7 +179,7 @@ STATIC mp_obj_t time_ticks_diff(mp_obj_t t0, mp_obj_t t1) {
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
uint32_t
start
=
mp_obj_get_int
(
t0
);
uint32_t
start
=
mp_obj_get_int
(
t0
);
uint32_t
end
=
mp_obj_get_int
(
t1
);
uint32_t
end
=
mp_obj_get_int
(
t1
);
return
MP_OBJ_NEW_SMALL_INT
((
end
>
start
)
?
(
end
-
start
)
:
(
start
-
end
)
);
return
MP_OBJ_NEW_SMALL_INT
((
end
-
start
)
&
MP_SMALL_INT_POSITIVE_MASK
);
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
time_ticks_diff_obj
,
time_ticks_diff
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
time_ticks_diff_obj
,
time_ticks_diff
);
...
...
This diff is collapsed.
Click to expand it.
tests/wipy/time.py
+
1
−
2
View file @
ae70e98e
...
@@ -43,7 +43,6 @@ def spot_test(seconds, expected_time):
...
@@ -43,7 +43,6 @@ def spot_test(seconds, expected_time):
return
return
print
(
"
time.localtime(
"
,
seconds
,
"
) returned
"
,
actual_time
,
"
(pass)
"
)
print
(
"
time.localtime(
"
,
seconds
,
"
) returned
"
,
actual_time
,
"
(pass)
"
)
test
()
test
()
spot_test
(
0
,
(
2000
,
1
,
1
,
0
,
0
,
0
,
5
,
1
))
spot_test
(
0
,
(
2000
,
1
,
1
,
0
,
0
,
0
,
5
,
1
))
spot_test
(
1
,
(
2000
,
1
,
1
,
0
,
0
,
1
,
5
,
1
))
spot_test
(
1
,
(
2000
,
1
,
1
,
0
,
0
,
1
,
5
,
1
))
...
@@ -75,4 +74,4 @@ print(time.ticks_diff(t1, t2) < 2000)
...
@@ -75,4 +74,4 @@ print(time.ticks_diff(t1, t2) < 2000)
t1
=
time
.
ticks_cpu
()
t1
=
time
.
ticks_cpu
()
t2
=
time
.
ticks_cpu
()
t2
=
time
.
ticks_cpu
()
print
(
time
.
ticks_diff
(
t1
,
t2
)
<
16384
)
print
(
time
.
ticks_diff
(
t1
,
t2
)
>=
0
)
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