/* Event function to signal to this module that the entire transfer completed.  */
static void TbxMbRtuTransmitComplete(tTbxMbUartPort port)
/* Event function to signal to this module that the entire transfer completed.  */
static void TbxMbRtuTransmitComplete(tTbxMbUartPort port)
{
  TBX_ASSERT(port < TBX_MB_UART_NUM_PORT);
  if (port < TBX_MB_UART_NUM_PORT)
  {
    tTbxMbTpCtx volatile * tpCtx = tbxMbRtuCtx[port];
    TBX_ASSERT(tpCtx != NULL)
    if (tpCtx != NULL)
    {
      TbxCriticalSectionEnter();
      uint8_t stateCopy = tpCtx->state;
      TbxCriticalSectionExit();
      TBX_ASSERT(stateCopy == TBX_MB_RTU_STATE_TRANSMISSION);
      if (stateCopy == TBX_MB_RTU_STATE_TRANSMISSION)
      {
        TbxCriticalSectionEnter();
        tpCtx->txDoneTime = TbxMbPortTimerCount();
        TbxCriticalSectionExit();
        tTbxMbEvent newEvent;
        newEvent.context = (void *)tpCtx;
        newEvent.id = TBX_MB_EVENT_ID_START_POLLING;
        TbxMbOsalEventPost(&newEvent, TBX_TRUE);
      }
    }
  }
}