base/ANTInterface.c
USHORT ANT_SendPartialBurst(UCHAR ucAntChannel_, UCHAR* pucBuffer_, USHORT usPackets_, ULONG ulInitialPacket_, BOOL bIncludeLast_)
{

   UCHAR ucSeq;
   UCHAR* pucRxMesg;
   BOOL bBurstFailure = FALSE;

   // Get initial sequence number
   if(ulInitialPacket_ <= 4)
      ucSeq = (ulInitialPacket_ - 1) * SEQUENCE_NUMBER_INC;
   else
      ucSeq = (1 + ((ulInitialPacket_ + 1) % 3)) * SEQUENCE_NUMBER_INC;     // adjust for rollover

   do
   {
      if (usPackets_ == 1 && bIncludeLast_)
         ucSeq |= SEQUENCE_LAST_MESSAGE;

      //Check if the Burst transfer has failed if we are in the middle of one, break early if failure occurred
      pucRxMesg = Serial_Scan_Rx_Top();
      if(ucSeq && pucRxMesg[BUFFER_INDEX_MESG_ID] == MESG_RESPONSE_EVENT_ID)
      {
         if(pucRxMesg[BUFFER_INDEX_RESPONSE_MESG_ID] == MESG_EVENT_ID && pucRxMesg[BUFFER_INDEX_RESPONSE_CODE] == EVENT_TRANSFER_TX_FAILED)
            bBurstFailure = TRUE;
         else if((pucRxMesg[BUFFER_INDEX_RESPONSE_MESG_ID] == MESG_BURST_DATA_ID) && (pucRxMesg[BUFFER_INDEX_RESPONSE_CODE] != RESPONSE_NO_ERROR))
            bBurstFailure = TRUE;
      }

      if(!bBurstFailure && ANT_BurstPacket(ucSeq | ucAntChannel_, pucBuffer_))
      {
         //Move to next 8 byte block in data
         pucBuffer_ += MESG_DATA_SIZE - 1;  //Use size - 1 since the channel data is not in the data buffer
         //Adjust sequence number
         if (ucSeq == SEQUENCE_NUMBER_ROLLOVER)
            ucSeq = SEQUENCE_NUMBER_INC;
         else
            ucSeq += SEQUENCE_NUMBER_INC;
      }

      // Transmit and recieve messages to/from ANT
      Serial_Transaction();
   }while(--usPackets_ && !bBurstFailure);

   return usPackets_;
}
////////////////////////////////////////////////////////////////////////////////
// ANT_SendPartialBurst
//
// usInitialPacket_ = number of initial packet within the burst sequence (eg. 3 for the third packet)
// bIncludeLast_ = FALSE if the last sequence number is not to be included in this block, TRUE otherwise
//
////////////////////////////////////////////////////////////////////////////////
ANT_SendPartialBurst
usInitialPacket_ = number of initial packet within the burst sequence
bIncludeLast_ = FALSE if the last sequence number is not to be included in this block, TRUE otherwise
ANT_SendPartialBurst usInitialPacket_ = number of initial packet within the burst sequence bIncludeLast_ = FALSE if the last sequence number is not to be included in this block TRUE otherwise
USHORT ANT_SendPartialBurst(UCHAR ucAntChannel_, UCHAR* pucBuffer_, USHORT usPackets_, ULONG ulInitialPacket_, BOOL bIncludeLast_)
{
   UCHAR ucSeq;
   UCHAR* pucRxMesg;
   BOOL bBurstFailure = FALSE;
   if(ulInitialPacket_ <= 4)
      ucSeq = (ulInitialPacket_ - 1) * SEQUENCE_NUMBER_INC;
   else
      ucSeq = (1 + ((ulInitialPacket_ + 1) % 3)) * SEQUENCE_NUMBER_INC;     
   do
   {
      if (usPackets_ == 1 && bIncludeLast_)
         ucSeq |= SEQUENCE_LAST_MESSAGE;
      pucRxMesg = Serial_Scan_Rx_Top();
      if(ucSeq && pucRxMesg[BUFFER_INDEX_MESG_ID] == MESG_RESPONSE_EVENT_ID)
      {
         if(pucRxMesg[BUFFER_INDEX_RESPONSE_MESG_ID] == MESG_EVENT_ID && pucRxMesg[BUFFER_INDEX_RESPONSE_CODE] == EVENT_TRANSFER_TX_FAILED)
            bBurstFailure = TRUE;
         else if((pucRxMesg[BUFFER_INDEX_RESPONSE_MESG_ID] == MESG_BURST_DATA_ID) && (pucRxMesg[BUFFER_INDEX_RESPONSE_CODE] != RESPONSE_NO_ERROR))
            bBurstFailure = TRUE;
      }
      if(!bBurstFailure && ANT_BurstPacket(ucSeq | ucAntChannel_, pucBuffer_))
      {
         pucBuffer_ += MESG_DATA_SIZE - 1;  
         if (ucSeq == SEQUENCE_NUMBER_ROLLOVER)
            ucSeq = SEQUENCE_NUMBER_INC;
         else
            ucSeq += SEQUENCE_NUMBER_INC;
      }
      Serial_Transaction();
   }while(--usPackets_ && !bBurstFailure);
   return usPackets_;
}
USHORT ANT_SendPartialBurst ( UCHAR ucAntChannel_ , UCHAR * pucBuffer_ , USHORT usPackets_ , ULONG ulInitialPacket_ , BOOL bIncludeLast_ ) { UCHAR ucSeq ; UCHAR * pucRxMesg ; BOOL bBurstFailure = FALSE ; if ( ulInitialPacket_ <= 4 ) ucSeq = ( ulInitialPacket_ - 1 ) * SEQUENCE_NUMBER_INC ; else ucSeq = ( 1 + ( ( ulInitialPacket_ + 1 ) % 3 ) ) * SEQUENCE_NUMBER_INC ; do { if ( usPackets_ == 1 && bIncludeLast_ ) ucSeq |= SEQUENCE_LAST_MESSAGE ; pucRxMesg = Serial_Scan_Rx_Top ( ) ; if ( ucSeq && pucRxMesg [ BUFFER_INDEX_MESG_ID ] == MESG_RESPONSE_EVENT_ID ) { if ( pucRxMesg [ BUFFER_INDEX_RESPONSE_MESG_ID ] == MESG_EVENT_ID && pucRxMesg [ BUFFER_INDEX_RESPONSE_CODE ] == EVENT_TRANSFER_TX_FAILED ) bBurstFailure = TRUE ; else if ( ( pucRxMesg [ BUFFER_INDEX_RESPONSE_MESG_ID ] == MESG_BURST_DATA_ID ) && ( pucRxMesg [ BUFFER_INDEX_RESPONSE_CODE ] != RESPONSE_NO_ERROR ) ) bBurstFailure = TRUE ; } if ( ! bBurstFailure && ANT_BurstPacket ( ucSeq | ucAntChannel_ , pucBuffer_ ) ) { pucBuffer_ += MESG_DATA_SIZE - 1 ; if ( ucSeq == SEQUENCE_NUMBER_ROLLOVER ) ucSeq = SEQUENCE_NUMBER_INC ; else ucSeq += SEQUENCE_NUMBER_INC ; } Serial_Transaction ( ) ; } while ( -- usPackets_ && ! bBurstFailure ) ; return usPackets_ ; }
ANT_SendPartialBurst
usInitialPacket_ = number of initial packet within the burst sequence (eg.
ANT_SendPartialBurst usInitialPacket_ = number of initial packet within the burst sequence ( eg .
// Get initial sequence number // adjust for rollover //Check if the Burst transfer has failed if we are in the middle of one, break early if failure occurred //Move to next 8 byte block in data //Use size - 1 since the channel data is not in the data buffer //Adjust sequence number // Transmit and recieve messages to/from ANT