mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Protect flashInit from NULL SPI instance
This commit is contained in:
parent
9e7e263abb
commit
4ab7ab03ef
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