Common mistakes

Informative

Pitfalls when using the UART driver, and how to avoid them. Each maps to a rule in Uart — Requirements or an error in Errors.

  • Passing a real pointer to Uart_Init. configPtr MUST be NULL_PTR — a non-null pointer raises UART_DEVERR_PARAM_POINTER (CHI-UART-MUST-06). The configuration is selected at build time.

  • Expecting reception right after Uart_Init. No frames are received until Uart_StartRxTransaction is called (CHI-UART-MUST-06).

  • Freeing the buffer too early. txDataPtr / rxDataPtr must stay valid until the matching callout fires (Uart_Callout_OnTransmission / Uart_Callout_OnStreamingDataRequest / Uart_Callout_OnReception) (CHI-UART-MUST-08, CHI-UART-MUST-12).

  • Mixing the two TX callback styles. A channel is either HwCompletion (Uart_Callout_OnTransmission) or Streaming (Uart_Callout_OnStreamingDataRequest) — never both. Implement the one your channel is configured for (CHI-UART-MUST-11).

  • Treating Uart_Callout_OnStreamingDataRequest as “sent”. It fires when the software buffer empties; the hardware FIFO/shift register may still be draining. Use HwCompletion if you need a true on-the-bus confirmation (CHI-UART-MUST-10, CHI-UART-MUST-11).

  • Losing bytes on buffer switch. To keep receiving without gaps, call Uart_StartRxTransaction from inside Uart_Callout_OnReception; if you don’t, the driver stops reception after the callout returns (CHI-UART-MUST-14).

  • Calling Uart_SetAdditionalRxLenTrg outside the callout. It may be called only from within Uart_Callout_OnReception (CHI-UART-MUST-15).

  • Starting a TX while BUSY. Uart_StartTxTransaction is accepted only in IDLE or (streaming) READY; otherwise it raises UART_DEVERR_INVALID_CH_STATE (CHI-UART-MUST-20).

  • Forgetting to service polled channels. A Polling channel needs Uart_PollFunction called cyclically, or no transfer progresses and no callout fires (CHI-UART-MUST-18).