<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/extmod/utime_mphal.c, branch 6.0.x</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.0.x</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.0.x'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2020-07-06T18:16:25+00:00</updated>
<entry>
<title>Add license to some obvious files.</title>
<updated>2020-07-06T18:16:25+00:00</updated>
<author>
<name>Diego Elio Pettenò</name>
<email>flameeyes@flameeyes.com</email>
</author>
<published>2020-06-03T22:40:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=34b4993d63a6b576f29d624385c681f679b4124c'/>
<id>urn:sha1:34b4993d63a6b576f29d624385c681f679b4124c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py,extmod: Some casts and minor refactors to quiet compiler warnings.</title>
<updated>2017-07-07T01:32:22+00:00</updated>
<author>
<name>Tom Collins</name>
<email>tom.collins@digi.com</email>
</author>
<published>2017-06-30T23:23:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=145796f037715e180b441b38c1ec1ba45ff77797'/>
<id>urn:sha1:145796f037715e180b441b38c1ec1ba45ff77797</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/utime_mphal: Don't exit/enter the GIL in generic sleep functions.</title>
<updated>2017-03-22T01:49:21+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-03-22T01:49:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=2e3fc778094c0c31c3e15e196e1c7b3b838239fe'/>
<id>urn:sha1:2e3fc778094c0c31c3e15e196e1c7b3b838239fe</id>
<content type='text'>
GIL behaviour should be handled by the port.  And ports probably want to
define sleep_us so that it doesn't release the GIL, to improve timing
accuracy.
</content>
</entry>
<entry>
<title>extmod/utime_mphal: ticks_diff/ticks_add: Don't hardcode 32-bit types.</title>
<updated>2016-11-03T20:54:16+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-11-03T20:54:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=9b345a9e482f28547e270b5c86ed3e022e56e237'/>
<id>urn:sha1:9b345a9e482f28547e270b5c86ed3e022e56e237</id>
<content type='text'>
Use normal mp_int_t/mp_uint_t types, algorithms (hm, formulas) can work
with any type width.
</content>
</entry>
<entry>
<title>extmod/utime_mphal: ticks_diff(): Optimize to avoid if conditions.</title>
<updated>2016-11-01T23:50:48+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-11-01T23:50:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=10bde6933e45289eeb8b0a564b088fadc4309c17'/>
<id>urn:sha1:10bde6933e45289eeb8b0a564b088fadc4309c17</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/utime_mphal: Fix implementation of new semantics of ticks_diff().</title>
<updated>2016-10-30T00:07:22+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-10-30T00:07:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e429daa5724e5e3c5f8866742abc64eb90ded71d'/>
<id>urn:sha1:e429daa5724e5e3c5f8866742abc64eb90ded71d</id>
<content type='text'>
Now the function properly uses ring arithmetic to return signed value
in range (inclusive):
[-MICROPY_PY_UTIME_TICKS_PERIOD/2, MICROPY_PY_UTIME_TICKS_PERIOD/2-1].

That means that function can properly process 2 time values away from
each other within MICROPY_PY_UTIME_TICKS_PERIOD/2 ticks, but away in
both directions. For example, if tick value 'a' predates tick value 'b',
ticks_diff(a, b) will return negative value, and positive value otherwise.
But at positive value of MICROPY_PY_UTIME_TICKS_PERIOD/2-1, the result
of the function will wrap around to negative -MICROPY_PY_UTIME_TICKS_PERIOD/2,
in other words, if a follows b in more than MICROPY_PY_UTIME_TICKS_PERIOD/2 - 1
ticks, the function will "consider" a to actually predate b.
</content>
</entry>
<entry>
<title>extmod/utime_mphal: Allow ticks functions period be configurable by a port.</title>
<updated>2016-10-30T00:02:07+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-10-30T00:02:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=76146b3d9ab0ab88ce0f0d1cfa0235ec0758a4a9'/>
<id>urn:sha1:76146b3d9ab0ab88ce0f0d1cfa0235ec0758a4a9</id>
<content type='text'>
Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
</content>
</entry>
<entry>
<title>extmod/utime_mphal: Implement ticks_add(), add to all maintained ports.</title>
<updated>2016-10-29T14:30:05+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-10-29T14:30:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=d86cac4b8268bbe9203cdd7ab8d8c2a65d142986'/>
<id>urn:sha1:d86cac4b8268bbe9203cdd7ab8d8c2a65d142986</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/utime_mphal: Add MP_THREAD_GIL_EXIT/ENTER warppers for sleep functions.</title>
<updated>2016-10-29T10:42:36+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-10-29T10:42:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=6a87084019e3e78eda0a21a3c80d600d0bd21991'/>
<id>urn:sha1:6a87084019e3e78eda0a21a3c80d600d0bd21991</id>
<content type='text'>
Ported from unix port.
</content>
</entry>
<entry>
<title>extmod/utime_mphal: ticks_diff(): switch arg order, return signed value.</title>
<updated>2016-10-29T02:02:24+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-10-29T02:02:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=6ed5583f8cfa5aa0afb776654cd996abaaa5fba3'/>
<id>urn:sha1:6ed5583f8cfa5aa0afb776654cd996abaaa5fba3</id>
<content type='text'>
Based on the earlier discussed RFC. Practice showed that the most natural
order for arguments corresponds to mathematical subtraction:

ticks_diff(x, y) &lt;=&gt; x - y

Also, practice showed that in real life, it's hard to order events by time
of occurance a priori, events tend to miss deadlines, etc. and the expected
order breaks. And then there's a need to detect such cases. And ticks_diff
can be used exactly for this purpose, if it returns a signed, instead of
unsigned, value. E.g. if x is scheduled time for event, and y is the current
time, then if ticks_diff(x, y) &lt; 0 then event has missed a deadline (and e.g.
needs to executed ASAP or skipped). Returning in this case a large unsigned
number (like ticks_diff behaved previously) doesn't make sense, and such
"large unsigned number" can't be reliably detected per our definition of
ticks_* function (we don't expose to user level maximum value, it can be
anything, relatively small or relatively large).
</content>
</entry>
</feed>
