-
Notifications
You must be signed in to change notification settings - Fork 3k
Add spi_get_peripheral_name() to stm_spi #9845
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,24 @@ void init_spi(spi_t *obj) | |
} | ||
} | ||
|
||
SPIName spi_get_peripheral_name(PinName mosi, PinName miso, PinName sclk) { | ||
SPIName spi_mosi = (SPIName)pinmap_peripheral(mosi, PinMap_SPI_MOSI); | ||
SPIName spi_miso = (SPIName)pinmap_peripheral(miso, PinMap_SPI_MISO); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case of "3 wires SPI" , miso is set as "NC" - so this needs to be taken into account. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pinmap_merge should handle a situation when other pin is set as NC, but I'll provide also a check here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs more change. The check should happen before calling to Otherwise, the system would crash here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If miso is NC, should it even get there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right - so that's OK - thanks ! |
||
SPIName spi_sclk = (SPIName)pinmap_peripheral(sclk, PinMap_SPI_SCLK); | ||
|
||
SPIName spi_per; | ||
|
||
// If 3 wire SPI is used, the miso is not connected. | ||
if (miso == NC) { | ||
spi_per = (SPIName)pinmap_merge(spi_mosi, spi_sclk); | ||
} else { | ||
SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); | ||
spi_per = (SPIName)pinmap_merge(spi_data, spi_sclk); | ||
} | ||
|
||
return spi_per; | ||
} | ||
|
||
void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) | ||
{ | ||
struct spi_s *spiobj = SPI_S(obj); | ||
|
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.
I think this addition is not needed for this PR ?
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.
It wasn't until yesterday.
#9469 introduced the static array (it was put back yesterday), so it is needed.
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.
#9469 is not merged.
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.
No it is not, but as said in the description, this PR depends on #9469
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.
Then all the STM targets need to be updated, why updating F429ZI only ?
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.
Background is stated on the description. Other STM targets would work like they would before like stated in the #9469
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.
But why would this change be valid for WISUN and F429 only ? Does the change have drawbacks that we don't want to deploy everywhere ? If there are only advantages and no drawbacks, I'd prefer to have the change deployed widely. We try to keep all STM targets behavior as aligned as possible otherwise maintenance becomes more complex.
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.
AFAIK there are mostly advantages, bit larger memory footprint because of the static array for peripherals is a drawback though. The changes done now are preceding a major change to SPI that are coming in a future release. (That will effectively overwrite the changes done now)
Wi-SUN testing has been mainly done with F429, so that is why it is the first one to get changes. Changes to different HAL's can be added later on if there is a need.
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.
ok then, but when the "major changes" are made, all targets should be aligned.