-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
TMOTORF7V2 BlackBox fix #7955
TMOTORF7V2 BlackBox fix #7955
Conversation
src/main/drivers/bus_spi_hal_ll.c
Outdated
@@ -189,6 +189,11 @@ bool spiInitDevice(SPIDevice device, bool leadingEdge) | |||
IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_SCK_CFG_HIGH, spi->af); | |||
} | |||
IOConfigGPIOAF(IOGetByTag(spi->miso), SPI_IO_AF_MISO_CFG, spi->af); | |||
|
|||
// If MOSI pin for SPI3 is PB2 -> AF7, not AF6 | |||
if (spiDeviceByInstance(spi->dev) == SPIDEV_3 && IO_TAG(SPI3_MOSI_PIN) == IO_TAG(PB2)) { |
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.
Can't we do it in a different way that is driven by a target file? We should avoid hacks like this as long as possible
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 it can be, in this case target file will contain additional defines (any combination of MOSI_AF, MISO_AF and SCK_AF) and use them if not - uses defaults.
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.
@DzikuVx
Reworked.
Now custom SPI AF's can be taken from target.h if provided. In case they are not - "old" defaults are used (for compatibility).
If custom definintions are used, all three (SCK, MISO, MOSI) should be provided together, otherwise preprocessor error will appear.
@erstec could you please rebase on |
0a9dc93
to
006a19e
Compare
Fix for #7953
On STM32F7 TMOTORF7V2 FC uses PB2 as MOSI for SPI3, it is unique for this FC only.
PB2 is on AF7, but all other SPI3 pins are on AF6.
As INAV maps one AF resource for all SPI pins used on exact SPI periphery, I've added "check-and-adjust" for mentioned conditions.
It will affect only SPI3, only if MOSI pin is PB2 and only for F7's and H7's as they are same in this aspect.