[STM32F4][V1.11.0] Update serial_api.c to support new UART_HandleTypeDef

Following cube update, there has been changes in cube HAL that impact
the serial_api.c layer. The global state has been moved to separate
global/tx and rx states, so we can now differentiate both.
pull/1838/head
Erwan GOURIOU 2016-05-26 16:50:35 +02:00
parent 8955b6690d
commit 8e15a6cc55
1 changed files with 7 additions and 26 deletions

View File

@ -1082,15 +1082,8 @@ static void h_UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
in the UART CR3 register */
huart->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DMAR);
/* Check if a transmit process is ongoing or not */
if(huart->State == HAL_UART_STATE_BUSY_TX_RX)
{
huart->State = HAL_UART_STATE_BUSY_TX;
}
else
{
huart->State = HAL_UART_STATE_READY;
}
/* Update Rx state*/
huart->RxState = HAL_UART_STATE_READY;
}
HAL_UART_RxCpltCallback(huart);
}
@ -1104,7 +1097,7 @@ static void h_UART_DMAError(DMA_HandleTypeDef *hdma)
UART_HandleTypeDef* huart = ( UART_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
huart->RxXferCount = 0;
huart->TxXferCount = 0;
huart->State= HAL_UART_STATE_READY;
huart->gState= HAL_UART_STATE_READY;
huart->ErrorCode |= HAL_UART_ERROR_DMA;
HAL_UART_ErrorCallback(huart);
}
@ -1124,7 +1117,7 @@ static HAL_StatusTypeDef MBED_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_
uint32_t *tmp;
uint32_t tmp1 = 0;
tmp1 = huart->State;
tmp1 = HAL_UART_GetState(huart);
if((tmp1 == HAL_UART_STATE_READY) || (tmp1 == HAL_UART_STATE_BUSY_TX)) {
if((pData == NULL ) || (Size == 0)) {
return HAL_ERROR;
@ -1138,11 +1131,7 @@ static HAL_StatusTypeDef MBED_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_
huart->ErrorCode = HAL_UART_ERROR_NONE;
/* Check if a transmit process is ongoing or not */
if(huart->State == HAL_UART_STATE_BUSY_TX) {
huart->State = HAL_UART_STATE_BUSY_TX_RX;
} else {
huart->State = HAL_UART_STATE_BUSY_RX;
}
huart->RxState = HAL_UART_STATE_BUSY_RX;
/* Set the UART DMA transfer complete callback */
huart->hdmarx->XferCpltCallback = h_UART_DMAReceiveCplt;
@ -1517,11 +1506,7 @@ void serial_tx_abort_asynch(serial_t *obj)
// reset states
handle->TxXferCount = 0;
// update handle state
if (handle->State == HAL_UART_STATE_BUSY_TX_RX) {
handle->State = HAL_UART_STATE_BUSY_RX;
} else {
handle->State = HAL_UART_STATE_READY;
}
handle->gState = HAL_UART_STATE_READY;
}
/** Abort the ongoing RX transaction It disables the enabled interrupt for RX and
@ -1538,11 +1523,7 @@ void serial_rx_abort_asynch(serial_t *obj)
// reset states
handle->RxXferCount = 0;
// update handle state
if (handle->State == HAL_UART_STATE_BUSY_TX_RX) {
handle->State = HAL_UART_STATE_BUSY_TX;
} else {
handle->State = HAL_UART_STATE_READY;
}
handle->gState = HAL_UART_STATE_READY;
}
#endif