Skip to content
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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Romaric-RILLET
Copy link

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)

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)
@robert-hh
Copy link
Contributor

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), allowing to connect two different SPI peripherals.

@robert-hh
Copy link
Contributor

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.

@Romaric-RILLET
Copy link
Author

Romaric-RILLET commented Feb 1, 2022 via email

@robert-hh
Copy link
Contributor

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.
I think it is less of a problem to use D0 and D1 instead of D38 and D39, if that is only a Teensy 4.1 request.
Sorry, I did not look to deep into your code yet. But if you go for Signal keyword options, then it should be generic.

@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 

@dpgeorge
Copy link
Member

@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.

@robert-hh
Copy link
Contributor

Not for me. It is superseded by 0f048a5, which allows to use any pin for CS.

@Romaric-RILLET
Copy link
Author

Romaric-RILLET commented Jan 19, 2023 via email

@robert-hh
Copy link
Contributor

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.

@robert-hh
Copy link
Contributor

Compiling for the MIMXRT1015_EVK and MIMXRT1170_EVK boards fails.

@codecov-commenter
Copy link

Codecov Report

Merging #8236 (a0e043a) into master (41ed01f) will not change coverage.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants