mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Merge pull request #7470 from jflyper/bfdev-protect-flashInit-from-NULL-SPI-instance
[FLASH] Protect flashInit from NULL SPI instance
This commit is contained in:
commit
28de73ab13
1 changed files with 7 additions and 1 deletions
|
@ -62,7 +62,13 @@ bool flashInit(const flashConfig_t *flashConfig)
|
|||
}
|
||||
|
||||
busdev->bustype = BUSTYPE_SPI;
|
||||
spiBusSetInstance(busdev, spiInstanceByDevice(SPI_CFG_TO_DEV(flashConfig->spiDevice)));
|
||||
|
||||
SPI_TypeDef *instance = spiInstanceByDevice(SPI_CFG_TO_DEV(flashConfig->spiDevice));
|
||||
if (!instance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
spiBusSetInstance(busdev, instance);
|
||||
|
||||
IOInit(busdev->busdev_u.spi.csnPin, OWNER_FLASH_CS, 0);
|
||||
IOConfigGPIO(busdev->busdev_u.spi.csnPin, SPI_IO_CS_CFG);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue