Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse. #2514

Closed
wants to merge 1 commit into from

Conversation

pfalcon
Copy link
Contributor

@pfalcon pfalcon commented Oct 13, 2016

As long as a port implement mp_hal_sleep_ms(), mp_hal_ticks_ms(), etc.
functions, it can just use standard implementations of utime.sleel_ms(),
utime.ticks_ms(), etc. Python-level functions.

@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 13, 2016

I had this refactor in mind for a year or so. Now that zephyr port is in queue, there's no excuse to not make it (indeed, proposed implementation of zephyr's utime module duplicates all standard implementations).

@dpgeorge
Copy link
Member

How shall we handle negative args to sleep_XX functions? stmhal treats negative sleep as zero sleep. Is it up to the utime wrappers to check for negative values, or the port's mp_hal_sleep functions?

Otherwise +1. But mind the build error, the file will need to be guarded by MICROPY_PY_UTIME, or something like that.

@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 14, 2016

How shall we handle negative args to sleep_XX functions? stmhal treats negative sleep as zero sleep.

Let's move them in here (as a next step), I'm happy to drop "undefined behavior" idea for them.

@dpgeorge
Copy link
Member

Let's move them in here (as a next step), I'm happy to drop "undefined behavior" idea for them.

Ok!

…or reuse.

As long as a port implement mp_hal_sleep_ms(), mp_hal_ticks_ms(), etc.
functions, it can just use standard implementations of utime.sleel_ms(),
utime.ticks_ms(), etc. Python-level functions.
@pfalcon
Copy link
Contributor Author

pfalcon commented Oct 14, 2016

Fixed and merged.

@pfalcon pfalcon closed this Oct 14, 2016
@pfalcon pfalcon deleted the utime-reuse branch October 14, 2016 17:13
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request May 18, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants