-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Allow MISO/MOSI set to NC during SPI initialisation (fix for issue #12435) #12460
Conversation
Static pinmap extension required to use pin_function() and pin_mode() functions instead of pinmap_pinout(). Unfortunatelly pin_function() does not allow passing NC pin. Call pin_function() and pin_mode() only if MISO/MOSI pin is not NC.
Because of this, we end-up with a lot of checks (if (pin != NC)) everywhere in the code, including in this PR. Shouldn't we actually rather change pin_function to simply return when NC pin is passed as a parameter ? Other than that this question, I am fine with the change as it is now - so I will approve it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the ST driver part - looks ok to me
@mprse, thank you for your changes. |
Can this update be extended to include K66F and KW41D? |
I agree this is good. This should be changed in the future if there is no objection to change |
Quick test done:
Seems that none of MOSI/MISO are set to NC ? |
Good point. I used |
Seems fairly straightforward for ST targets, we would need to replace the ASSERT by a simple return. |
OK, seems it is only print issue as test is doing 2 sub cases: 1 with only MOSI pin, 1 with MISO... Maybe a new type "SPINoCs1Line" could be good instead of SPINoCSPort ? |
With the extra prints it will look like this:
Is that acceptable? |
Additionally, remove redundant pin checks against NC when above functions are used.
741107d
to
713be4f
Compare
@LMESTM please review 713be4f. @mmahadevan108 Is such change acceptable also for NXP targets? Test results (NUCLEO_F429ZI):
|
ping @mmahadevan108 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one style, otherwise looks fine to em
} else { | ||
} else if (mosi == NC) { | ||
spi_per = (SPIName)pinmap_merge(spi_miso, spi_sclk); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else should be on line 50
Started CI meanwhile we complete reviews |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
CI completed, just one approval. Please complete your reviews |
Marked as ready for merge, would like to integrate later today |
Summary of changes
This PR fixes issue #12435.
Static pin-map extension required to use
pin_function()
andpin_mode()
functions instead ofpinmap_pinout()
. Unfortunatelypin_function()
does not allow passingNC
pin.The proposition is to call
pin_function()
andpin_mode()
only ifMISO/MOSI
pin is notNC
.Additionally extended SPI FPGA test to verify all possible pin configurations including MISO and MOSI unconnected.
The idea is to add also similar tests for other peripherals if this proposal will be approved. I think that this should be added for peripherals that use more than one pin and provide the availability to specify at least one pin as NC.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers
@jeromecoutant @LMESTM @mmahadevan108
@fkjagodzinski @maciejbocianski
@jamesbeyond