Added safety for timer hardware items with no DMA.

This commit is contained in:
blckmn 2016-11-14 08:56:42 +11:00
parent 31e01531d7
commit 92bcd91790
2 changed files with 10 additions and 0 deletions

View File

@ -184,6 +184,11 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
DMA_Channel_TypeDef *channel = timerHardware->dmaChannel;
if (channel == NULL) {
/* trying to use a non valid channel */
return;
}
dmaInit(timerHardware->dmaIrqHandler, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
dmaSetHandler(timerHardware->dmaIrqHandler, motor_DMA_IRQHandler, NVIC_BUILD_PRIORITY(1, 2), motorIndex);

View File

@ -182,6 +182,11 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
DMA_Stream_TypeDef *stream = timerHardware->dmaStream;
if (stream == NULL) {
/* trying to use a non valid stream */
return;
}
dmaInit(timerHardware->dmaIrqHandler, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
dmaSetHandler(timerHardware->dmaIrqHandler, motor_DMA_IRQHandler, NVIC_BUILD_PRIORITY(1, 2), motorIndex);