BUG in HAL_UART_Transmit() and HAL_IRDA_Transmit()
This is the signature of the function:
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)where pData is the pointer to the data to be transmitted and Size the amount of data to be sent. In case of wordlength = 9bits and NO parity:
huart->TxXferSize = Size;
huart->TxXferCount = Size;
while(huart->TxXferCount > 0U)
{
huart->TxXferCount--;
if(UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
{
return HAL_TIMEOUT;
}
if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
{
tmp = (uint16_t*) pData;
huart->Instance->TDR = (*tmp & (uint16_t)0x01FFU);
pData += 2U;
}
else
{
huart->Instance->TDR = (*pData++ & (uint8_t)0xFFU);
}
}pData is incremented by 2 until it reaches 2 times the size of the array.. and BOOM!
Same problem with HAL_IRDA_Transmit(). With the receive the array has to be big enough (2xSize). Definetly confusing..
