-
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
Conversation
Could you clarify a little on the background here - why this platform, specifically? (This is pre-empting wider changes including adding this facility to all platforms in #8445.) |
Added some background to description. |
@@ -57,6 +57,7 @@ typedef enum { | |||
UART_8 = (int)UART8_BASE | |||
} UARTName; | |||
|
|||
#define SPI_COUNT 6 |
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
No, it means that targets that don't provide this extra facility retain the existing single whole-system SPI mutex.
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.
@@ -92,6 +92,16 @@ 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 comment
The 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.
Please add check, if miso is NC, only merge mosi and 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.
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 comment
The 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 comment
The 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
SPIName spi_miso = (SPIName)pinmap_peripheral(miso, PinMap_SPI_MISO);
Otherwise, the system would crash here:
https://github.com/ARMmbed/mbed-os/blob/master/hal/mbed_pinmap_common.c#L78
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.
If miso is NC, should it even get there?
https://github.com/ARMmbed/mbed-os/blob/master/hal/mbed_pinmap_common.c#L73
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.
You're right - so that's OK - thanks !
This is to have support for per-peripheral mutex introduced in ARMmbed#9469 Together fixes an issue seen in ARMmbed#9149
9377d16
to
a9f0924
Compare
Actually this doesn't depend on the previous PR, at least for merging. |
True, the previous PR only justifies the changes made in this. |
@@ -92,6 +92,16 @@ 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 comment
The 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
SPIName spi_miso = (SPIName)pinmap_peripheral(miso, PinMap_SPI_MISO);
Otherwise, the system would crash here:
https://github.com/ARMmbed/mbed-os/blob/master/hal/mbed_pinmap_common.c#L78
@@ -57,6 +57,7 @@ typedef enum { | |||
UART_8 = (int)UART8_BASE | |||
} UARTName; | |||
|
|||
#define SPI_COUNT 6 |
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 ?
Basically yes, but as @kjbracey-arm stated:
|
CI started |
Test run: SUCCESSSummary: 13 of 13 test jobs passed |
@kjbracey-arm Shall this go in as it is? |
Yes, I think this is fine as-is. If the other PR needed a change, it could be done in that PR. |
Fix issue ARMmbed#9149. Port changes from ARMmbed#9845 also to targets: K64F, K66F, KW24D and KW41Z
This is to have support for per-peripheral mutex introduced in #9469
Together fixes an issue seen in #9149
Depends on: #9469
Background:
The issue has been seen while testing Wi-SUN with mbed-cloud-client while using SPI storage. The tested devices have been NUCLEO_F429ZI. If we add new targets for the Wi-SUN testing, the HAL-changes are needed to be added there also.
Description
Pull request type
Reviewers
@kjbracey-arm @bulislaw @ithinuel
Release Notes