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
5357dad5
Commit
5357dad5
authored
5 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
esp8266: Fix ticks_ms to correctly handle wraparound of system counter.
Fixes issue #4795.
parent
c4a6d9c6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ports/esp8266/esp_mphal.c
+3
-1
3 additions, 1 deletion
ports/esp8266/esp_mphal.c
ports/esp8266/ets_alt_task.c
+14
-9
14 additions, 9 deletions
ports/esp8266/ets_alt_task.c
ports/esp8266/ets_alt_task.h
+2
-0
2 additions, 0 deletions
ports/esp8266/ets_alt_task.h
with
19 additions
and
10 deletions
ports/esp8266/esp_mphal.c
+
3
−
1
View file @
5357dad5
...
@@ -120,7 +120,9 @@ void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) {
...
@@ -120,7 +120,9 @@ void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) {
}
}
uint32_t
mp_hal_ticks_ms
(
void
)
{
uint32_t
mp_hal_ticks_ms
(
void
)
{
return
((
uint64_t
)
system_time_high_word
<<
32
|
(
uint64_t
)
system_get_time
())
/
1000
;
// Compute milliseconds from 64-bit microsecond counter
system_time_update
();
return
((
uint64_t
)
system_time_high_word
<<
32
|
(
uint64_t
)
system_time_low_word
)
/
1000
;
}
}
uint32_t
mp_hal_ticks_us
(
void
)
{
uint32_t
mp_hal_ticks_us
(
void
)
{
...
...
This diff is collapsed.
Click to expand it.
ports/esp8266/ets_alt_task.c
+
14
−
9
View file @
5357dad5
...
@@ -112,22 +112,27 @@ int ets_loop_iter_disable = 0;
...
@@ -112,22 +112,27 @@ int ets_loop_iter_disable = 0;
int
ets_loop_dont_feed_sw_wdt
=
0
;
int
ets_loop_dont_feed_sw_wdt
=
0
;
// to implement a 64-bit wide microsecond counter
// to implement a 64-bit wide microsecond counter
static
uint32_t
system_time_
prev
=
0
;
uint32_t
system_time_
low_word
=
0
;
uint32_t
system_time_high_word
=
0
;
uint32_t
system_time_high_word
=
0
;
bool
ets_loop_iter
(
void
)
{
void
system_time_update
(
void
)
{
if
(
ets_loop_iter_disable
)
{
// Handle overflow of system microsecond counter
return
false
;
}
// handle overflow of system microsecond counter
ets_intr_lock
();
ets_intr_lock
();
uint32_t
system_time_cur
=
system_get_time
();
uint32_t
system_time_cur
=
system_get_time
();
if
(
system_time_cur
<
system_time_
prev
)
{
if
(
system_time_cur
<
system_time_
low_word
)
{
system_time_high_word
+=
1
;
// record overflow of low 32-bits
system_time_high_word
+=
1
;
// record overflow of low 32-bits
}
}
system_time_
prev
=
system_time_cur
;
system_time_
low_word
=
system_time_cur
;
ets_intr_unlock
();
ets_intr_unlock
();
}
bool
ets_loop_iter
(
void
)
{
if
(
ets_loop_iter_disable
)
{
return
false
;
}
// Update 64-bit microsecond counter
system_time_update
();
// 6 words before pend_flag_noise_check is a variable that is used by
// 6 words before pend_flag_noise_check is a variable that is used by
// the software WDT. A 1.6 second period timer will increment this
// the software WDT. A 1.6 second period timer will increment this
...
...
This diff is collapsed.
Click to expand it.
ports/esp8266/ets_alt_task.h
+
2
−
0
View file @
5357dad5
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
extern
int
ets_loop_iter_disable
;
extern
int
ets_loop_iter_disable
;
extern
int
ets_loop_dont_feed_sw_wdt
;
extern
int
ets_loop_dont_feed_sw_wdt
;
extern
uint32_t
system_time_low_word
;
extern
uint32_t
system_time_high_word
;
extern
uint32_t
system_time_high_word
;
void
system_time_update
(
void
);
bool
ets_loop_iter
(
void
);
bool
ets_loop_iter
(
void
);
#endif // MICROPY_INCLUDED_ESP8266_ETS_ALT_TASK_H
#endif // MICROPY_INCLUDED_ESP8266_ETS_ALT_TASK_H
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