-
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
Dev stm32 gpio pins rework #3665
Conversation
def4528
to
514b45f
Compare
case GPIO_PULLDOWN: | ||
LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); | ||
break; | ||
case GPIO_NOPULL: |
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.
Maybe use "default:" instead ?
LL_GPIO_SetPinMode(gpio, ll_pin, LL_GPIO_MODE_INPUT); | ||
LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); | ||
break; | ||
case GPIO_NOPULL: |
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.
Use default: ?
case GPIO_PULLDOWN: | ||
LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); | ||
break; | ||
case GPIO_NOPULL: |
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.
Use default: ?
case GPIO_PULLDOWN: | ||
LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); | ||
break; | ||
case GPIO_NOPULL: |
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.
Use default: ?
case GPIO_PULLDOWN: | ||
LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); | ||
break; | ||
case GPIO_NOPULL: |
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.
Use default: ?
case GPIO_PULLDOWN: | ||
LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); | ||
break; | ||
case GPIO_NOPULL: |
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.
Use default: ?
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.
@bcostm Thanks Bruno - I updated the code as suggested
/morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
@LMESTM Can you please rebase ? L0 PR was merged, so we can have a look at this one and test |
5af842c
to
ea15b87
Compare
@0xc0170 rebased now. |
any numbers, how does it change? What about footprint? I had a look at the structure for gpio IRQ , looks to me that it shall be the same at least for those pins RAM data. Ill rerun tests: /morph test-nightly |
targets/TARGET_STM/gpio_api.c
Outdated
inline void gpio_dir(gpio_t *obj, PinDirection direction) { | ||
|
||
if (direction == PIN_INPUT) | ||
{ |
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.
nit: block alignment as it was
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.
corrected with new commits
} exti_lines_t; | ||
|
||
// Used to return the index for channels array. | ||
static exti_lines_t pin_lines_desc[16] = |
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.
Why is array defined in the header file ?
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.
Because this is the family specific part - each family has a specific exti lines mapping.
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.
note: I just realized this can probably be declared as const
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.
should be definitely in flash.
I was asking mainly as this should be then included just once otherwise would be multiple defined (with multiple inclusions), variables should not be defined in header files is a good advice. The question would be why this is not defined in a code file, and included with some common header file where declaration is provided.
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 understand.
As it is now in this PR, gpio_irq_device.h is an extension with static inline functions and table of gpio_irq_api.c and only included from this file. I could indeed replace this file with 2 files: gpio_irq_device.h with declarations and gpio_irq_device.c file for instance
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.
@0xc0170 so do you want me to change the .h file into 2 separate files ?
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 you agree, then would be better (to overcome surprises).
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.
sure - will do
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 now
targets/TARGET_STM/gpio_irq_api.c
Outdated
obj->event = EDGE_FALL; | ||
} | ||
else | ||
{ |
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.
Code style consistency
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.
corrected with new commits
Here is the improvement as seen from FastIO bench: Before PR |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
The failure was caused by Windows 10 installing an update in the middle of a test. Even though I disabled it Microsoft still pushes them through sometimes it looks like 🙄 /morph test-nightly |
6a524cf
to
927a113
Compare
Result: ABORTEDYour command has finished executing! Here's what you wrote!
OutputTest Prep failed! |
@LMESTM I saw you pushed another commit. Please let me know when you've finished your changes and we'll restart CI. |
@bridadan thx - I'll keep you posted |
This requires the creation of gpio_irq_device.h file, where family specific EXTI IRQ mapping is defined
Instead of using HAL_GPIO_Init / Deinit which makes a lot of registers being written and re-written, and which creates extra gpio / pin / irq dependencies, we directly set the IRQ related registers thanks for the STM32 LL layers which provides APIs to modify registers.
Directly return a GPIO_TypeDef pointer to avoid extra casts. Also move it to GPIO file.
Those are minor changes to increase performance of widely used GPIO functions.
this first makes pinmap.c a common file then rework it with several goals: - avoid gpio / irq / pin management extra dependencies - improve performances when switching between pin modes This change is based on LL layer to access to registers level instead of using HAL higher level API. The family specific functions are implemented in pin_device.h of each family. Mostly this is F1 family that is differnt from other ones.
The default pin mode shall be set as part of the pinamp_pinout, and as defined in tables of PeripheralPins.c, but this is currently over-written by a call to pin_mode(pin, PullNone); from mbed_pinmap_common.c, so we need a set the mode again here, including OpenDrain config as needed for I2C.
As commented during PR review, better use default case.
Move the const table initialization from the header file to a new C file to avoid any multiple defined errors.
Correcting the style format errors. Also updating the copyright year.
ce3ecb4
to
d7902e5
Compare
/morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Description
This PR is an update of the pins, gpio and gpio irqs management.
Until now all those 3 services were using the same STM32 high level service from HAL which was a bit cumbersome. After this change the design is simpler and each drivers gpio_api.c, gpio_irq_api.c and pinmap.c will manage the corresponding registers in an independant way.
After this PR, we have following benefit:
Status
READY
Related PRs
Need #3629 (also part of this branch for now - would disappear after rebase when #3629 gets merged)
Tests results
Non regression on with ci-tests-shields are ok
ci-test-shield.zip
MBED non-regression ongoing for all platforms.
F1 results:
F1 pins non-reg