-
Notifications
You must be signed in to change notification settings - Fork 143
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
Support for STM32 F0/G0 remap pins #471
Support for STM32 F0/G0 remap pins #471
Conversation
There is the following in the g071 device file:
Therefore, lbuild tries to generate the A9 gpio header twice for the g071rb and fails. |
I see this is more complicated than I initially thought. I still think the device file has an issue and there should not be two A9 pins, so I'm checking this. |
Keep in mind that this PR still has the modm-devices version from before modm-io/modm-devices#47 was merged. |
Yes, for these weird G0 it doesn't work. Do you know how I would enable the |
I played around with CubeMX and the G071RB. The |
Of course, that makes sense, otherwise you'd need to have analog + AF mode, which isn't how this works. I suggest the following: Let's add a public |
I agree, with the G0 an automatic solution is very confusing and will not work. A public method called by the user is the only sensible way to go. Where would you add it? In the default pin class, the non-default or both? If it were in both and had a bool parameter, it is very confusing. |
I'd add it to only the pins occupying the same position (ie. A9/A11, A10/A12) and simply calling That way you'll get a "free" compiler error if you try it on a pin that cannot be remapped (same for AFs that don't exist on that pin). |
OK, I'll do that. |
603bbee
to
abb3123
Compare
abb3123
to
d0972e2
Compare
@salkinium I think the L1 failing in CI are not caused by my changes. |
Looks like a CMSIS header issue, considering only the |
There are still some issues with some G0, for example |
234af5e
to
b2cfa81
Compare
Could you stop rebasing for a second here, I'm trying to fix something here… |
Sorry, I was fighting against ST's inconsistent pin names across controller families, like for example: |
I know, I've been there, the trick is to not fight against ST's pin naming ;-P |
I think this code is equivalent to yours, but please double check. |
|
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.
@salkinium Looks good
Oh, there's another issue with modm-devices. Some STM32G0 devices have multiple GPIOs bonded to the same pin without any multiplexing: <package device-pin="y" name="WLCSP18">
<pin position="A1" name="PA13"/>
<pin position="A3" name="PA14-BOOT0"/>
<pin position="A3" name="PA15"/>
<pin position="A5" name="PB7"/>
<pin position="A5" name="PB8"/>
<pin position="A7" name="PC15-OSC32_OUT (PC15)"/>
<pin position="B2" name="PA12 [PA10]"/>
<pin position="B2" name="PA10 [PA12]" variant="remap"/>
<pin position="B4" name="PB3"/>
<pin position="B4" name="PB4"/>
<pin position="B4" name="PB5"/>
<pin position="B4" name="PB6"/>
<pin position="B6" name="PC14-OSC32_IN (PC14)"/>
<pin position="B6" name="PB9"/>
<pin position="C1" name="PA11 [PA9]"/>
<pin position="C1" name="PA9 [PA11]" variant="remap"/>
<pin position="C3" name="PA5"/>
<pin position="C5" name="PA1"/>
<pin position="C7" name="VDD/VDDA" type="power"/>
<pin position="D2" name="PA7"/>
<pin position="D4" name="PA3"/>
<pin position="D4" name="PA4"/>
<pin position="D6" name="VSS/VSSA" type="power"/>
<pin position="E1" name="PB0"/>
<pin position="E1" name="PB1"/>
<pin position="E1" name="PB2"/>
<pin position="E1" name="PA8"/>
<pin position="E3" name="PA6"/>
<pin position="E5" name="PA2"/>
<pin position="E7" name="PF2 - NRST"/>
<pin position="E7" name="PA0"/>
</package> |
Oh no, ST, why? |
The failure of the STM32L162QC and STML162ZC devices has its root problem in the selection of the appropriate define and thus CMSIS header file for the device. This is because modm tries to find the closest regular match, but the mapping is not regular. /* #define STM32L162xC */ /*!< STM32L162RC and STM32L162VC */
/* #define STM32L162xCA */ /*!< STM32L162RC-A, STM32L162VC-A, STM32L162QC and STM32L162ZC */ /* #define STM32L152xC */ /*!< STM32L152CC, STM32L152UC, STM32L152RC and STM32L152VC */
/* #define STM32L152xCA */ /*!< STM32L152RC-A, STM32L152VC-A, STM32L152QC and STM32L152ZC */ /* #define STM32L151xC */ /*!< STM32L151CC, STM32L151UC, STM32L151RC and STM32L151VC */
/* #define STM32L151xCA */ /*!< STM32L151RC-A, STM32L151VC-A, STM32L151QC and STM32L151ZC */ You can see that ST assigns the QC and ZC devices the A-variant header. 🙄 |
The |
Ah, I didn't think about disabling this. The issues is in the raw data, which doesn't include the
|
Try this modm-devices fix, which adds the remap-default back in for STM32F0. |
Nonono, none of this works right. |
Now modm-devices using the right position information to find the remap pin pairs. |
The STM32G0 compile all fails because the multi-bonded pins can also be remapped!! Yay!1!! <package device-pin="j" name="SO8N">
<pin position="1" name="PC14-OSC32_IN (PC14)"/>
<pin position="1" name="PB7"/>
<pin position="1" name="PB8"/>
<pin position="1" name="PB9"/>
<pin position="2" name="VDD/VDDA" type="power"/>
<pin position="3" name="VSS/VSSA" type="power"/>
<pin position="4" name="NRST" type="reset"/>
<pin position="4" name="PA0"/>
<pin position="4" name="PA1"/>
<pin position="4" name="PA2"/>
<pin position="5" name="PA9 [PA11]" variant="remap"/>
<pin position="5" name="PB0" variant="remap-default"/>
<pin position="5" name="PB1" variant="remap-default"/>
<pin position="5" name="PA8" variant="remap-default"/>
<pin position="5" name="PA11 [PA9]" variant="remap-default"/>
<pin position="6" name="PA10 [PA12]" variant="remap"/>
<pin position="6" name="PA12 [PA10]" variant="remap-default"/>
<pin position="7" name="PA13"/>
<pin position="8" name="PA14-BOOT0"/>
<pin position="8" name="PA15"/>
<pin position="8" name="PB5"/>
<pin position="8" name="PB6"/>
</package> |
Ok, I think I'm done with this now. I've checked that STM32G071 and STM32F042 now also generate the right A9 and A10 pins. Can you check again? Then I'll squash and merge everything. |
Looks good, go ahead! |
Fixes STM32L1 define/header selection
034f79f
to
48d73dc
Compare
This adds support for remapped gpio pins on small G0/F0 controllers.
@salkinium https://github.com/modm-io/modm-devices/pull/47/files breaks it. So we need to find a solution for that.