<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/extmod/machine_spi.c, branch 5.0.0-beta.3</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=5.0.0-beta.3</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=5.0.0-beta.3'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2019-12-04T15:29:57+00:00</updated>
<entry>
<title>protocols: Allow them to be (optionally) type-safe</title>
<updated>2019-12-04T15:29:57+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-12-03T20:50:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=238e12123690debaf2cf8488fb2a4d4003a06506'/>
<id>urn:sha1:238e12123690debaf2cf8488fb2a4d4003a06506</id>
<content type='text'>
Protocols are nice, but there is no way for C code to verify whether
a type's "protocol" structure actually implements some particular
protocol.  As a result, you can pass an object that implements the
"vfs" protocol to one that expects the "stream" protocol, and the
opposite of awesomeness ensues.

This patch adds an OPTIONAL (but enabled by default) protocol identifier
as the first member of any protocol structure.  This identifier is
simply a unique QSTR chosen by the protocol designer and used by each
protocol implementer.  When checking for protocol support, instead of
just checking whether the object's type has a non-NULL protocol field,
use `mp_proto_get` which implements the protocol check when possible.

The existing protocols are now named:
    protocol_framebuf
    protocol_i2c
    protocol_pin
    protocol_stream
    protocol_spi
    protocol_vfs
(most of these are unused in CP and are just inherited from MP; vfs and
stream are definitely used though)

I did not find any crashing examples, but here's one to give a flavor of what
is improved, using `micropython_coverage`.  Before the change,
the vfs "ioctl" protocol is invoked, and the result is not intelligible
as json (but it could have resulted in a hard fault, potentially):

    &gt;&gt;&gt; import uos, ujson
    &gt;&gt;&gt; u = uos.VfsPosix('/tmp')
    &gt;&gt;&gt; ujson.load(u)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    ValueError: syntax error in JSON

After the change, the vfs object is correctly detected as not supporting
the stream protocol:
    &gt;&gt;&gt; ujson.load(p)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    OSError: stream operation not supported
</content>
</entry>
<entry>
<title>Fix unix build</title>
<updated>2019-01-18T20:52:27+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2019-01-18T20:52:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=58a2009cc11ac6b080d182854d0f669a6f65647a'/>
<id>urn:sha1:58a2009cc11ac6b080d182854d0f669a6f65647a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix esp and samd</title>
<updated>2018-08-17T00:41:35+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2018-08-16T20:34:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=2cd166b57370ab4877ec2d9666225faeac6127ce'/>
<id>urn:sha1:2cd166b57370ab4877ec2d9666225faeac6127ce</id>
<content type='text'>
</content>
</entry>
<entry>
<title>drivers/bus: Pull out software SPI implementation to dedicated driver.</title>
<updated>2018-03-09T13:59:43+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-03-09T06:25:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=58ebeca6a9a172a35b9298a911d450722797c409'/>
<id>urn:sha1:58ebeca6a9a172a35b9298a911d450722797c409</id>
<content type='text'>
This patch takes the software SPI implementation from extmod/machine_spi.c
and moves it to a dedicated file in drivers/bus/softspi.c.  This allows the
SPI driver to be used independently of the uPy runtime, making it a more
general component.
</content>
</entry>
<entry>
<title>extmod/machine_spi: Make SPI protocol structure public.</title>
<updated>2018-03-02T12:55:08+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-03-02T08:12:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=21d5527edf37ba550316ea0dbac87253c7791bd1'/>
<id>urn:sha1:21d5527edf37ba550316ea0dbac87253c7791bd1</id>
<content type='text'>
So it can be referenced directly without the need for the uPy object.
</content>
</entry>
<entry>
<title>extmod/machine_spi: Remove EVENT_POLL_HOOK from soft-SPI transfer func.</title>
<updated>2017-02-06T03:38:33+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-02-06T03:38:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=dee47949cc8782c2d565de6d6b7e5c1339000061'/>
<id>urn:sha1:dee47949cc8782c2d565de6d6b7e5c1339000061</id>
<content type='text'>
SPI needs to be fast, and calling the EVENT_POLL_HOOK every byte makes it
unusable for ports that need to do non-trivial work in the EVENT_POLL_HOOK
call.  And individual SPI transfers should be short enough in time that
EVENT_POLL_HOOK doesn't need to be called.

If something like this proves to be needed in practice then we will need
to introduce separate event hook macros, one for "slow" loops (eg
select/poll) and one for "fast" loops (eg software I2C, SPI).
</content>
</entry>
<entry>
<title>extmod/machine_spi: Provide reusable software SPI class.</title>
<updated>2016-12-08T02:47:01+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-12-08T02:47:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=1eb3c66e9136b5934fc306408f00f11a07dea584'/>
<id>urn:sha1:1eb3c66e9136b5934fc306408f00f11a07dea584</id>
<content type='text'>
So long as a port defines relevant mp_hal_pin_xxx functions (and delay) it
can make use of this software SPI class without the need for additional
code.
</content>
</entry>
<entry>
<title>extmod/machine_spi: Add optional support for fast software SPI.</title>
<updated>2016-10-04T02:46:40+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-10-04T02:46:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=b0eb0d6153d63cf823065792db35d2858fbb9406'/>
<id>urn:sha1:b0eb0d6153d63cf823065792db35d2858fbb9406</id>
<content type='text'>
If a port defines MICROPY_PY_MACHINE_SPI_MIN_DELAY then it can use a
faster software SPI loop that does not make calls to the delay_us
function.
</content>
</entry>
<entry>
<title>extmod/machine_spi: Use delay_half, not baudrate, for internal timing.</title>
<updated>2016-10-04T02:43:02+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-10-04T02:43:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=b932b2dd1faaf3091b13af7d213041a737e40fac'/>
<id>urn:sha1:b932b2dd1faaf3091b13af7d213041a737e40fac</id>
<content type='text'>
The delay_half parameter must be specified by the port to set up the
timing of the software SPI.  This allows the port to adjust the timing
value to better suit its timing characteristics, as well as provide a
more accurate printing of the baudrate.
</content>
</entry>
<entry>
<title>extmod/machine_spi: Factor out software SPI code from esp8266 to extmod.</title>
<updated>2016-10-03T05:43:44+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-10-03T05:43:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=d434ce3fca088959c4a4bf525b9d730ec9bdb7b4'/>
<id>urn:sha1:d434ce3fca088959c4a4bf525b9d730ec9bdb7b4</id>
<content type='text'>
</content>
</entry>
</feed>
