stm32-f4discovery-cc256x: use criticial section to avoid lossing TX Commplete Interrup

This commit is contained in:
Matthias Ringwald 2019-03-04 11:55:38 +01:00
parent d4bf5cc155
commit 82af58d38d

View File

@ -916,9 +916,22 @@ HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pDat
/* Process Unlocked */
__HAL_UNLOCK(huart);
//
// BK: SET_BIT is not IRQ-safe. If CR1 is modified from an IRQ, this change could get overwritten by SET_BIT
//
// fix: use critical section to modify control registers
// begin critical section - assumes IRQs are enabled (which holds true for calls from BTstack btstack_uart_block_embedded.c)
__disable_irq();
/* Enable the DMA transfer for transmit request by setting the DMAT bit
in the UART CR3 register */
SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
// end critical section
__enable_irq();
// BK: end fix
return HAL_OK;
}
@ -984,6 +997,14 @@ HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData
/* Process Unlocked */
__HAL_UNLOCK(huart);
//
// BK: SET_BIT is not IRQ-safe. If CR1 is modified from an IRQ, this change could get overwritten by SET_BIT
//
// fix: use critical section to modify control registers
// begin critical section - assumes IRQs are enabled (which holds true for calls from BTstack btstack_uart_block_embedded.c)
__disable_irq();
/* Enable the UART Parity Error Interrupt */
SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
@ -994,6 +1015,11 @@ HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData
in the UART CR3 register */
SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
// end critical section
__enable_irq();
// BK: end fix
return HAL_OK;
}
else