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
mimxrt: Allow to choose the pin to use for miso and cs #8236
base: master
Are you sure you want to change the base?
Conversation
Use keywords mosi and cs to give pins (machine.Pin) objects to use for mosi ans cs signals. Teensy 4.1 may use pin D1 or D39 for mosi, pin D0 or D38 for CS0. Example usage: spi = SPI(1,cs=Pin.board.D0, miso=Pin.board.D1)
Thank you for the contribution. After working so much at that mimxrt port, I am happy if someone else chimes in. I like the idea of using pointers instead of macros in the pin definition. That saves space. I use that in a PR for ETH as well, but that one is not yet published. |
Thank you for the contribution. After working so much at that mimxrt port, I am happy if someone else chimes in. I like the idea of using pointers instead of macros in the pin definition. That saves space. I use that in a PR for ETH as well, but that one is not yet published. |
My need with this PR is to use Pin 1 for MISO and 0 for CS0 with Teensy 4.1.
I can change mpconfigport.h, but other users of teensy 4.1 may want to use
pin 39 for miso, 38 for CS or both.
This will need 4 versions of mpconfigport.h.
I did not add the keyword "mosi" because for the 3 spi mosi signal, only
one of the two cpu pins is available on board pins.
(On Arch Mix, LPSPI4_SDO may be available on GPIO_B0_02/board 29
or GPIO_B1_06/board 5 but I don't have this board to test) .
I may add mosi and sck keywords if this is preferred (this may be more
coherent with doc
https://docs.micropython.org/en/latest/library/machine.SPI.html).
With this PR, it also possible to select cs number (like with the previous
cs keyword)
SPI(0,cs=Pin.board.D37) # CS 1
SPI(0,cs=Pin.board.D10) # CS 0
but it's also possible du select the pin for CS 0
SPI(1,cs=Pin.board.D0) # CS 0
SPI(1,cs=Pin.board.D38) # CS 0
Le mar. 1 févr. 2022 à 09:00, Robert Hammelrath ***@***.***>
a écrit :
… Thank you for the contribution. After working so much at that mimxrt port,
I am happy if someone else chimes in. I like the idea of using pointers
instead of macros in the pin definition. That saves space. I use that in a
PR for ETH as well, but that one is not yet published.
Nevertheless, If the intention for this PR is to use Teensy 4.1 Pin 38 and
39 for MISO1 and CS1, then a simple change in mpconfigport.h is sufficient.
Otherwise I do not like to have cs and miso keywords, but not mosi. And,
the cs keyword was already introduced recently to select between using cs=0
and cs=1 of a SPI hardware. So you could use pin 10, or 37 for cs at
SPI(0), allowiQng to connect two different SPI peripherals.
—
Reply to this email directly, view it on GitHub
<#8236 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF4CMXBS5IMMNT2NFZ7TCFTUY6HKLANCNFSM5NHP22LQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
The existing usage for the cs=Pin keyword is different from yours. With your implementation, you assign different Pin to the CS0 signal of the SPI module, whereas the existing cs=0|1 keyword selects between the CS0 and CS1 signal of the SPI module. |
Code size report:
|
@Romaric-RILLET @robert-hh is this PR still interesting? If so then it needs to first be rebased on the latest master, since a lot changed in the mimxrt port since this was opened. |
Not for me. It is superseded by 0f048a5, which allows to use any pin for CS. |
This PR is still interesting.
It allows selecting the pin used for each signal.
0f048a5
<0f048a5>
allows
to select which cs is used.
https://www.pjrc.com/teensy/IMXRT1060RM_rev3.pdf at page 306, shows the
muxing possibility for each signal.
0f048a5
<0f048a5>
uses
le cs keyword as an integer to select the chip select number (and -1 to
disable chip select).
This pr uses cs and miso keywords as pin object so is incompatible with
0f048a5
<0f048a5>
nrf, rp2, samd, esp32 ports use sck, mosi, miso keywords as pin object.
Le jeu. 19 janv. 2023 à 12:55, Robert Hammelrath ***@***.***>
a écrit :
… Not for me. It is superseded by 0f048a5
<0f048a5>,
which allows to use any pin for CS.
—
Reply to this email directly, view it on GitHub
<#8236 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF4CMXFDHZO3OGTRXLEUX6TWTETS7ANCNFSM5NHP22LQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Still this commit and 0f048a5 have different intention. The latter of the two aim at not using the automatic cs feature of the hardware, which is needed for some ports. The first allows to select between alternate pins available for the hardware signals, limited to cs and miso, with the Teensy 4.1 as primary board. This can be useful, but at least the option of not using the automatic CS signal and using scripted CS must be maintained. @alphaFred and me discussed to change the selection of pins for interfaces like UART, I2C and SPI in the same way as the SAMD port, by embedding a representation of the IOMUX table into the code and deciding on-the-fly, if a certain signal is available for a pin. With default assignments of course to keep backward compatibility for the code, like it is done e.g. for the rp2 port. And that will hopefully reduce the complexity of the mpconfigboard.h files. But that will not happen before next year (I know it's January), because @alphaFred is ATM very busy with family business. P.S.: @Romaric-RILLET Even with your PR you can use pin numbers for referencing a pin. Calling pin_find() will resolve this. That applies to all occurences except machine.Pin where a Pin has to be selected. |
Use keywords mosi and cs to give pins (machine.Pin) objects to use for mosi ans cs signals. Teensy 4.1 may use pin D1 or D39 for mosi, pin D0 or D38 for CS0. Example usage: spi = SPI(1,cs=Pin.board.D0, miso=Pin.board.D1)
Compiling for the MIMXRT1015_EVK and MIMXRT1170_EVK boards fails. |
Codecov Report
@@ Coverage Diff @@
## master #8236 +/- ##
=======================================
Coverage 98.50% 98.50%
=======================================
Files 155 155
Lines 20540 20540
=======================================
Hits 20232 20232
Misses 308 308 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Use keywords mosi and cs to give pins (machine.Pin) objects to use for mosi ans cs signals.
Teensy 4.1 may use pin D1 or D39 for mosi, pin D0 or D38 for CS0.
Example usage:
spi = SPI(1,cs=Pin.board.D0, miso=Pin.board.D1)