-
Notifications
You must be signed in to change notification settings - Fork 2k
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
boards/common/blxxxpill: Fix pin conflicts in periph_conf #18785
Conversation
ac9f595
to
f3f1cf9
Compare
This is definitely breaking qdec :/ |
f3f1cf9
to
8650e8d
Compare
#ifndef MODULE_PERIPH_PWM | ||
{ | ||
.dev = TIM3, | ||
.max = 0x0000ffff, | ||
.rcc_mask = RCC_APB1ENR_TIM3EN, | ||
.chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 }, | ||
{ .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 } }, | ||
.bus = APB1, | ||
.irqn = TIM3_IRQn, | ||
/* be default TIM3 is routed to PA6 (cc_chan 0) and PA7 (cc_chan 1) */ | ||
.remap = AFIO_MAPR_TIM3_REMAP_1, | ||
}, | ||
#endif |
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.
This one now works with support for remapping implemented. Still, the QDEC for TIM4 doesn't work. I think it never worked... I wonder how it got upstreamed.
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, this took me way longer to figure out than I had hoped for: The STM32F103xxx bluepill I used has no TIM4. With my Blackpill, the TIM4 (PB6 / PB7) QDEC config works just fine.
a4b4a7c
to
3c011c4
Compare
ADC channels
are still in conflict with ADC channels
are in conflict with |
Indeed. Sorry for being lazy here and only fixing the issue related to my use case. I should have done this properly in the first place. I will do so now. |
3c011c4
to
6d6339c
Compare
OK, done as suggested. I favored PWM over ADC for PB0 and PB1 (as this results in 6 external ADC pins + 4 PWM pins instead of 8 ADC pins and 2 PWM pins), but when PWM is unused all 8 pins of the Bluepill remain available. Ideally these prefer one over the other decisions should be configurable. But I'd prefer to wait until the KConfig migration is done to only model this once. I added a pinout generated using https://github.com/stevenj/GenPinoutSVG and the source CSV file it was generated from. That pinout contains the peripheral configuration of the board provided this PR. (Compared to other pinouts, it uses the RIOT numbering and omits peripheral support not configured in RIOT, making the pinout much more handy for RIOT users and much less handy for everybody else.)
Update: Fixed upstream :)
I am not entirely happy with that tool. I would have favored something that is more descriptive and splits out the styling. But I couldn't find anything better quickly. |
Wouldn't this change be a new board?This likely breakes user applications that use the old board definition. |
RIOT has a history of regularly changing board definitions. If you attach hardware permanently to your board (e.g. by adding a shield), application developers will naturally create a copy of that board and extend the In this case, it fixes bugs:
Quite generally, the STM32F1 routes peripherals to pins, not pins to peripheral (like all other STM32s). You can route two peripherals to the same pin. I have not checked what happens when two peripherals try to drive the exact same pin to opposite logic levels. But the current config of the Bluepill board should have never been merged. The issue seems that only the added config has been tested in isolation. E.g. ADC without SPI works fine. |
@maribu Please squash. |
Murdock results✔️ PASSED 051a1f1 boards/common/blxxxpill: rework periph configuration
ArtifactsThis only reflects a subset of all builds from https://ci-prod.riot-os.org. Please refer to https://ci.riot-os.org for a complete build for now. |
C++ is not happy |
This allows including C headers from C++. It sadly reduced the diagnostics on C++ code as well, were there warning may make sense as unintended side effect. We may be able to drop that later on, when more C APIs are properly wrapped in native C++ APIs, so that C headers do no longer need to be compatible with C++ compilers.
Add support to route peripheral to alternative pins for the STM32F1 family.
Add support to route timer peripheral to alternative pins for the STM32F1.
The peripheral configuration has been completely reworked to resolve pin conflicts while provided as much of the peripherals as possible. The changes include: - Move `I2C_DEV(0)` from PB6/PB7 to PB8/PB9 to solve pin conflict with `QDEC_DEV(2)`. - Use pins PB0, PB1, PB4, and PB5 for PWM instead PA8, PA9, PA10, and PA11 - PA9 and PA10 is in pin conflict with `UART_DEV(0)` which is used for stdio with `stdio_uart`, PA8 was in conflict with `QDEC_DEV(0)`, PA11 was in conflict with USB D- - Use PB6, PB7 as `QDEC_DEV(0)` (previously `QDEC_DEV(2)`), as this is the only completely conflict free setting - Use PB4/PB5 instead of PA6/PA7 for QDEC_DEV(1) - This fixes a pin conflict with `SPI_DEV(0)` MISO (and `ADC_LINE(4)`) - Only provide QDEC at PB4/PB5 when PWM is not used to avoid conflict - Only provide QDEC at PA8/PA9 when UART is not used to avoid conflict - Use SPI2 (PB15, PB14, PB13, PB12) as `SPI_DEV(0)` instead of SPI1, use SPI1 (PA7, PA6, PA5, PA4) as `SPI_DEV(1)` - Only provide `SPI_DEV(1)` if the ADC is not in used to resolve a pin conflict - Move PB0 and PB1 at the end of the ADC lines (previously `ADC_LINE(6)` and `ADC_LINE(7)`, now `ADC_LINE(8)` and `ADC_LINE(9)`) - Only provide them when PWM is not in use (to resolve pin conflict with PWM) - Also do not provide them for the Blackpill boards, which are missing pins PB0 and PB1 on the headers To make life of users easier, a Pinout diagram with the new configuration was added.
3f0403d
to
051a1f1
Compare
All green now. Note that while I did reorder the initializer list to match the declaration list to please C++ compilers, I didn't add bogus |
thx :) |
Contribution description
I2C_DEV(0)
from PB6/PB7 to PB8/PB9 to solve pin conflict withQDEC_DEV(2)
.The main advantage is now that an application can now use at least the first instance of any peripheral without any conflicts with other peripherals, if I didn't miss anything.
Testing procedure
i2c_scan
)tests/periph_pwm
and an LED)tests/periph_qdec
)I2C test results
None