Closed
Description
First mentioned here RobTillaart/MS5611_SPI#6
Summary
It should be safe to call SPI.end() before SPI.begin() to allow dynamic change SPI settings.
Now it crashes on the NANO33
Solution
Current code
From - https://github.com/arduino/ArduinoCore-mbed/blob/master/libraries/SPI/SPI.cpp
void arduino::MbedSPI::begin() {
if (dev == NULL) {
dev = new mbed_spi;
dev->obj = NULL;
}
if (dev->obj == NULL) {
dev->obj = new mbed::SPI(_mosi, _miso, _sck);
}
}
void arduino::MbedSPI::end() {
if (dev->obj != NULL) { // <<<<<<<<<< if dev == NULL this crashes.
delete dev->obj;
}
}
Proposal
void arduino::MbedSPI::end() {
if (dev != NULL) {
if (dev->obj != NULL) {
delete dev->obj;
}
}
}
Metadata
Metadata
Assignees
Labels
No labels