base/serial.c
void Asynchronous_Transaction()
{
   if(sqTxMessages.ucMessageCount > 0)  // if we have a message to send
   {
      ASYNC_SLEEP_DEASSERT();       // keep ANT from sleeping

      //Wait until RTS drops
      while(IS_RTS_ASSERTED());

      UCHAR ucCheckSum = MESG_TX_SYNC;
      UCHAR* pucTxBuffer;
      UCHAR ucMesgLen;
      UCHAR ucIndex;

      pucTxBuffer = sqTxMessages.aucMessages[sqTxMessages.ucTail].aucBuffer;

      Asynchronous_WriteByte(MESG_TX_SYNC);

      ucMesgLen = pucTxBuffer[0] + MESG_SAVED_FRAME_SIZE;                           // read the message length of the message to send and adjust for frame size
      ucIndex   = 0;

      do
      {
         Asynchronous_WriteByte(pucTxBuffer[ucIndex]);                              // write out message byte
         ucCheckSum ^= pucTxBuffer[ucIndex];                                        // update the checksum

      } while (++ucIndex < ucMesgLen);                                              // loop through message


      Asynchronous_WriteByte(ucCheckSum);                                           // write out the checksum byte

      //Wait until RTS is high to signal that ANT has begun toggling RTS to show that it has begun processing the message
      while(!IS_RTS_ASSERTED());

      //Wait until RTS drops
      while(IS_RTS_ASSERTED());

      // Wait until tx flag is enabled.
      while(!(UART_ASYNC_UCI_IFR & UART_ASYNC_TX_INT));

      //Check if we can allow ANT to go to sleep after having sent this message
      if(sqTxMessages.aucMessages[sqTxMessages.ucTail].bGoToSleep)
         ASYNC_SLEEP_ASSERT();      // let ANT sleep

      sqTxMessages.ucMessageCount--;
      sqTxMessages.ucTail = (sqTxMessages.ucTail + 1) & (SERIAL_QUEUE_TX_SIZE-1);   // Update queue
   }
}
////////////////////////////////////////////////////////////////////////////
// Asynchronous_Transaction
//
// If there is a message in the serial queue, send it.
// 
////////////////////////////////////////////////////////////////////////////
Asynchronous_Transaction
If there is a message in the serial queue, send it.
Asynchronous_Transaction If there is a message in the serial queue send it .
void Asynchronous_Transaction()
{
   if(sqTxMessages.ucMessageCount > 0)  
   {
      ASYNC_SLEEP_DEASSERT();       
      while(IS_RTS_ASSERTED());
      UCHAR ucCheckSum = MESG_TX_SYNC;
      UCHAR* pucTxBuffer;
      UCHAR ucMesgLen;
      UCHAR ucIndex;
      pucTxBuffer = sqTxMessages.aucMessages[sqTxMessages.ucTail].aucBuffer;
      Asynchronous_WriteByte(MESG_TX_SYNC);
      ucMesgLen = pucTxBuffer[0] + MESG_SAVED_FRAME_SIZE;                           
      ucIndex   = 0;
      do
      {
         Asynchronous_WriteByte(pucTxBuffer[ucIndex]);                              
         ucCheckSum ^= pucTxBuffer[ucIndex];                                        
      } while (++ucIndex < ucMesgLen);                                              
      Asynchronous_WriteByte(ucCheckSum);                                           
      while(!IS_RTS_ASSERTED());
      while(IS_RTS_ASSERTED());
      while(!(UART_ASYNC_UCI_IFR & UART_ASYNC_TX_INT));
      if(sqTxMessages.aucMessages[sqTxMessages.ucTail].bGoToSleep)
         ASYNC_SLEEP_ASSERT();      
      sqTxMessages.ucMessageCount--;
      sqTxMessages.ucTail = (sqTxMessages.ucTail + 1) & (SERIAL_QUEUE_TX_SIZE-1);   
   }
}
void Asynchronous_Transaction ( ) { if ( sqTxMessages . ucMessageCount > 0 ) { ASYNC_SLEEP_DEASSERT ( ) ; while ( IS_RTS_ASSERTED ( ) ) ; UCHAR ucCheckSum = MESG_TX_SYNC ; UCHAR * pucTxBuffer ; UCHAR ucMesgLen ; UCHAR ucIndex ; pucTxBuffer = sqTxMessages . aucMessages [ sqTxMessages . ucTail ] . aucBuffer ; Asynchronous_WriteByte ( MESG_TX_SYNC ) ; ucMesgLen = pucTxBuffer [ 0 ] + MESG_SAVED_FRAME_SIZE ; ucIndex = 0 ; do { Asynchronous_WriteByte ( pucTxBuffer [ ucIndex ] ) ; ucCheckSum ^= pucTxBuffer [ ucIndex ] ; } while ( ++ ucIndex < ucMesgLen ) ; Asynchronous_WriteByte ( ucCheckSum ) ; while ( ! IS_RTS_ASSERTED ( ) ) ; while ( IS_RTS_ASSERTED ( ) ) ; while ( ! ( UART_ASYNC_UCI_IFR & UART_ASYNC_TX_INT ) ) ; if ( sqTxMessages . aucMessages [ sqTxMessages . ucTail ] . bGoToSleep ) ASYNC_SLEEP_ASSERT ( ) ; sqTxMessages . ucMessageCount -- ; sqTxMessages . ucTail = ( sqTxMessages . ucTail + 1 ) & ( SERIAL_QUEUE_TX_SIZE - 1 ) ; } }
Asynchronous_Transaction
If there is a message in the serial queue, send it.
Asynchronous_Transaction If there is a message in the serial queue send it .
// if we have a message to send // keep ANT from sleeping //Wait until RTS drops // read the message length of the message to send and adjust for frame size // write out message byte // update the checksum // loop through message // write out the checksum byte //Wait until RTS is high to signal that ANT has begun toggling RTS to show that it has begun processing the message //Wait until RTS drops // Wait until tx flag is enabled. //Check if we can allow ANT to go to sleep after having sent this message // let ANT sleep // Update queue