diff options
author | Damien George <damien.p.george@gmail.com> | 2014-12-08 21:34:07 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-12-08 21:34:07 +0000 |
commit | b66a31c42cc99b8b584a4e90eab4f58b87904886 (patch) | |
tree | 237ba0dd204005aaae24eb3e035dd81ed0903b41 /docs/library/pyb.SPI.rst | |
parent | 008251180d860f0bdf1b23c2772a2a7bfdc736fb (diff) | |
download | micropython-b66a31c42cc99b8b584a4e90eab4f58b87904886.tar.gz micropython-b66a31c42cc99b8b584a4e90eab4f58b87904886.zip |
stmhal: Allow SPI.init to specify prescaler directly; improve SPI docs.
Diffstat (limited to 'docs/library/pyb.SPI.rst')
-rw-r--r-- | docs/library/pyb.SPI.rst | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/docs/library/pyb.SPI.rst b/docs/library/pyb.SPI.rst index 5c732fccba..70d6454015 100644 --- a/docs/library/pyb.SPI.rst +++ b/docs/library/pyb.SPI.rst @@ -52,12 +52,29 @@ Methods Turn off the SPI bus. -.. method:: spi.init(mode, baudrate=328125, \*, polarity=1, phase=0, bits=8, firstbit=SPI.MSB, ti=False, crc=None) +.. method:: spi.init(mode, baudrate=328125, \*, prescaler, polarity=1, phase=0, bits=8, firstbit=SPI.MSB, ti=False, crc=None) Initialise the SPI bus with the given parameters: - ``mode`` must be either ``SPI.MASTER`` or ``SPI.SLAVE``. - ``baudrate`` is the SCK clock rate (only sensible for a master). + - ``prescaler`` is the prescaler to use to derive SCK from the APB bus frequency; + 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 + respectively. + - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. + - ``crc`` can be None for no CRC, or a polynomial specifier. + + Note that the SPI clock frequency will not always be the requested baudrate. + The hardware only supports baudrates that are the APB bus frequency + (see :meth:`pyb.freq`) divided by a prescaler, which can be 2, 4, 8, 16, 32, + 64, 128 or 256. SPI(1) is on AHB2, and SPI(2) is on AHB1. For precise + control over the SPI clock frequency, specify ``prescaler`` instead of + ``baudrate``. + + Printing the SPI object will show you the computed baudrate and the chosen + prescaler. .. method:: spi.recv(recv, \*, timeout=5000) |