Browse Source

BUGFIX:mtd hardfault in no SPI

NULL check needed to be done before SPI_XXXX calls
sbg
David Sidrane 8 years ago committed by Daniel Agar
parent
commit
1af3ea322c
  1. 11
      src/systemcmds/mtd/mtd.c

11
src/systemcmds/mtd/mtd.c

@ -208,18 +208,19 @@ ramtron_attach(void) @@ -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…
Cancel
Save