-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat(PeriphDrivers): Provide user a way to manually drive SPI slave select pin #674
Conversation
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 some minor comment revision.
It might also be useful to add a function that lets you select the slave select pin to drive if the HW CS control scheme is disabled.
|
||
/** | ||
* @brief Enable disable HW CS control feature. | ||
* | ||
* Depend on the application user might would like to drive slave select pin | ||
* The SPI driver able to drive SS pin automatically this feature can be disable/enable | ||
* by this function | ||
* | ||
* @param spi Pointer to SPI registers (selects the SPI block used.) | ||
* @param state true or false | ||
*/ | ||
void MXC_SPI_HWSSControl(mxc_spi_regs_t *spi, int state); |
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.
/**
* @brief Enable/Disable HW CS control feature.
*
* Depending on the application, the user might need to manually drive the slave select pin.
* The SPI driver automatically drives the SS pin and this function enables/disables this
* feature.
*
* @param spi Pointer to SPI registers (selects the SPI block used.)
* @param state true or false
*/
I revised the tone and grammar. Maybe something like this? ^^
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.
Fine, thanks.
@Jacob-Scheiffler @EdwinFairchild I think I remember you two making updates to the bootloader examples (Bootloader and BLE_OTAS) and having some flash size problems for the ME17. These new SPI changes caused the project size of those two examples to exceed the flash size which throws build errors. Is there a way to provide some more space in those examples? The library size is going to increase over time as we add fixes and features to the MSDK, so we're going to run into this issue again in the future. We may need to have a discussion about improving the memory footprint of our drivers and, as a start, enforce the proper use of integer type sizes ( |
It is also an option but CS pin might be a standard GPIO too, so it will be more generic if CS pin configure and drive by app layer instead of driver layer. |
bb3ac01
to
50ab37f
Compare
Can it be merged? |
We need to resolve the build failure |
Our SPI drivers are already the biggest drivers in the SDK. Even with I think we should be trying to reduce this instead of forcing projects to adapt to driver bloat. Surely we can trim 48 bytes of code somewhere to get this build to pass.
|
Yeah there is always some issue with bootloader space on the ME17 since that baby does not have the second flash bank we partition it's single bank for bootloader and app. That bootloader is as lean as it can get, i think asserts are turned off ? among other little tweaks, but I agree maybe the real issue is the ever-growing SPI driver so maybe tackling otherwise increasing bootloader space to buy usa few more revisions lol |
* feature. | ||
* | ||
* @param spi Pointer to SPI registers (selects the SPI block used.) | ||
* @param state true or false |
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.
The description for the state variable should provide more detail. Please update this in all header files to something like, "Non-zero values: enable HW SS mode. Zero: disable HW SS mode."
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.
Added.
Asserts are always added to @EdwinFairchild @sihyung-maxim @Jacob-Scheiffler @ozersa... Please re-approve given the changes below: I reduced the SPI_RevA object size by 830KB by removing unnecessary asserts (acaf898) Almost every single function had something along the lines of int spi_num;
spi_num = MXC_SPI_GET_IDX((mxc_spi_regs_t *)spi);
MXC_ASSERT(spi_num >= 0);
(void)spi_num;
|
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.
Approved pending Jacob's comment:
Looks good, I like clean code. |
I thought the assert was for cases when the user defines its own SPI instance instead of using the predefined instances in the CMSIS part header file. Although rare for this to happen, there have been previous projects in the past that defined their own instances, and it's meant for scenarios like this.
Edit: And also, the asserts should only be for functions that have a void return type. For all other functions that return a signed integer type, it should be replaced with an error-checking if statement that returns the appropriate error value. |
Hmm okay, I didn't consider this case... 830KB is still too much overhead to handle it though. I'll add some lightweight checks back in |
@Jake-Carter one proposal, how about to manage optimization related change on a different PR then after it to be merged rebase this one. |
I think it would be acceptable to merge in the commits above because it gets the bootloader builds to pass. But I'm open to rebasing, I agree it's cleaner. Up to you - it will take us a little more time to apply universally. We can merge this now, or I can revert my changes and we can rebase in a few days. |
Alternatively, I can do a separate PR just for the SPI RevA file and we can rebase on that. We could merge that in a few minutes. |
@ozersa My changes have been reverted in favor of the separate PR |
Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>
Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>
Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>
Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>
6d0801d
to
273870b
Compare
Rebased this branch, @Jacob-Scheiffler ready to merge pending your approval |
Description
While using SPI manual chip drive requires, existing SPI driver drive SS pin by HW, there is no any option to disable this behaviour, This feature exactly require while porting Zephyr/MBED... On these platform i add an patch at the top of SDK layer.
It will be nice if SDK support it on default.
Checklist Before Requesting Review