mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
BUGFIX:mtd hardfault in no SPI
NULL check needed to be done before SPI_XXXX calls
This commit is contained in:
parent
01f520dfd2
commit
1af3ea322c
@ -208,18 +208,19 @@ ramtron_attach(void)
|
||||
/* initialize the right spi */
|
||||
struct spi_dev_s *spi = px4_spibus_initialize(PX4_SPI_BUS_RAMTRON);
|
||||
|
||||
if (spi == NULL) {
|
||||
PX4_ERR("failed to locate spi bus");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* this resets the spi bus, set correct bus speed again */
|
||||
SPI_SETFREQUENCY(spi, 10 * 1000 * 1000);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETMODE(spi, SPIDEV_MODE3);
|
||||
SPI_SELECT(spi, SPIDEV_FLASH(0), false);
|
||||
|
||||
if (spi == NULL) {
|
||||
PX4_ERR("failed to locate spi bus");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* start the RAMTRON driver, attempt 5 times */
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
mtd_dev = ramtron_initialize(spi);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user