HAL_ChibiOS: fixed DMA allocation bug on SPI
thanks to Mark Whitehorn for finding this crash
This commit is contained in:
parent
29add8a880
commit
e29b79f41b
@ -73,7 +73,10 @@ void SPIBus::dma_allocate(void)
|
||||
void SPIBus::dma_deallocate(void)
|
||||
{
|
||||
// another non-SPI peripheral wants one of our DMA channels
|
||||
spiStop(spi_devices[bus].driver);
|
||||
if (spi_started) {
|
||||
spiStop(spi_devices[bus].driver);
|
||||
spi_started = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -262,6 +265,7 @@ bool SPIDevice::set_chip_select(bool set)
|
||||
bus.spicfg.cr1 = (uint16_t)(freq_flag | device_desc.mode);
|
||||
bus.spicfg.cr2 = 0;
|
||||
spiStart(spi_devices[device_desc.bus].driver, &bus.spicfg); /* Setup transfer parameters. */
|
||||
bus.spi_started = true;
|
||||
spiSelectI(spi_devices[device_desc.bus].driver); /* Slave Select assertion. */
|
||||
cs_forced = true;
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ public:
|
||||
uint8_t bus;
|
||||
SPIConfig spicfg;
|
||||
void dma_allocate(void);
|
||||
void dma_deallocate(void);
|
||||
void dma_deallocate(void);
|
||||
bool spi_started;
|
||||
};
|
||||
|
||||
struct SPIDesc {
|
||||
|
Loading…
Reference in New Issue
Block a user