Skip to content

docs/spi: add information for data size - #2210

Closed
toolmacher wants to merge 1 commit into
micropython:masterfrom
toolmacher:master
Closed

docs/spi: add information for data size#2210
toolmacher wants to merge 1 commit into
micropython:masterfrom
toolmacher:master

Conversation

@toolmacher

Copy link
Copy Markdown

Hi,
think that was forgotten: data size description of bits in the class SPI. I added the information that the data size can also be 16.

Comment thread docs/library/pyb.SPI.rst
use of ``prescaler`` overrides ``baudrate``.
- ``polarity`` can be 0 or 1, and is the level the idle clock line sits at.
- ``phase`` can be 0 or 1 to sample data on the first or second clock edge
- ``bits`` can be 8 or 16, and is the data size.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find "and is the data size" part a bit confusing, why I don't merge this and leave for further review/discussion.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about:
"bits can be 8 or 16, stands for the data bytes"
or
" bits can be 8 or 16, and is the word size"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it usually called the word size

bits word size - can be 8 or 16.

@dpgeorge

Copy link
Copy Markdown
Member

Which port are you using that supports 16 bits wide SPI words?

@toolmacher

Copy link
Copy Markdown
Author

I use v1.8.1.
https://github.com/micropython/micropython/blob/master/stmhal/spi.c#L439
I measured it with the oscilloscope and it works.
>>> from pyb import SPI
>>> spi = SPI(1,SPI.MASTER,baudrate=1000,polarity=1,phase=0,bits=16)
>>> spi.send_recv(5)

@dpgeorge

Copy link
Copy Markdown
Member

I see, then the stmhal code works by accident, that's nice to know!

Regarding the docs, how about: "can be 8 or 16, and is the number of bits in each transferred word"

@pfalcon

pfalcon commented Sep 18, 2016

Copy link
Copy Markdown
Contributor

Applied with @dpgeorge's wording.

MarkR42 pushed a commit to MarkR42/micropython that referenced this pull request Oct 13, 2016
Taccart pushed a commit to Taccart/micropython that referenced this pull request May 23, 2026
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.

4 participants