@Andrew Neil wrote:
The setting is based on the current configuration of the UART
It's tested at runtime:
/* In case of 9bits/No Parity transfer, pData needs to be handled as a uint16_t pointer */
if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
{
pdata8bits = NULL;
pdata16bits = (const uint16_t *) pData;
}
else
{
pdata8bits = pData;
pdata16bits = NULL;
}
this is where it makes the decision to treat the buffer as 8 or 16 bits.
@Andrew Neil wrote:
whether it is sending 9-bit data frames, or 8-bit data frames.
Clearly, you can't fill a 9-bit data frame from a single 8-bit buffer entry - you need something at least 9 bits.
C doesn't provide a 9-bit datatype - the next available option after 8 bits (single byte) is 16 bits (two bytes).