mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 03:23:33 +08:00
BUGFIX:mtd hardfault in no SPI
NULL check needed to be done before SPI_XXXX calls
This commit is contained in:
committed by
Daniel Agar
parent
01f520dfd2
commit
1af3ea322c
@@ -208,18 +208,19 @@ ramtron_attach(void)
|
|||||||
/* initialize the right spi */
|
/* initialize the right spi */
|
||||||
struct spi_dev_s *spi = px4_spibus_initialize(PX4_SPI_BUS_RAMTRON);
|
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 */
|
/* this resets the spi bus, set correct bus speed again */
|
||||||
SPI_SETFREQUENCY(spi, 10 * 1000 * 1000);
|
SPI_SETFREQUENCY(spi, 10 * 1000 * 1000);
|
||||||
SPI_SETBITS(spi, 8);
|
SPI_SETBITS(spi, 8);
|
||||||
SPI_SETMODE(spi, SPIDEV_MODE3);
|
SPI_SETMODE(spi, SPIDEV_MODE3);
|
||||||
SPI_SELECT(spi, SPIDEV_FLASH(0), false);
|
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 */
|
/* start the RAMTRON driver, attempt 5 times */
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
mtd_dev = ramtron_initialize(spi);
|
mtd_dev = ramtron_initialize(spi);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user