Пример #1
0
//! Receives a series of 17 bit messages & Transmits next command
//!
//! @param count       => number of messages to receive
//! @param dataPtr     => pointer to message data buffer
//! @param nextCommand => next command to send
//!
//! @return  \ref BDM_RC_OK                    => Success                                \n
//!          \ref BDM_RC_CF_BUS_ERROR          => Target returned Bus Error              \n
//!          \ref BDM_RC_CF_ILLEGAL_COMMAND    => Target returned Illegal Command error  \n
//!          \ref BDM_RC_NO_CONNECTION         => No connection / unexpected response
//!
//! @note The first byte stored in the buffer is the MSB of the first message
//! @note Transmits the next command while receiving the last message
//!
U8 bdmcf_rxtx(U8 count, U8 *dataPtr, U16 nextCommand) {
U8   retryCount,status;
U16  data;
U16  dataOut = _BDMCF_CMD_NOP; // Dummy command to send 

   while(count>0) {
      retryCount = BDMCF_RETRY;
      
      count--;
      if (count == 0) {          // Last word to Tx?
         dataOut = nextCommand;  // Yes - send next command
      }
      do {
         status = bdmcf_txrx_start();
         data   = bdmcf_txRx16( dataOut );
         if (status == BDMCF_STATUS_OK) 
            break;
         if (data != BDMCF_RES_NOT_READY)
            break;
      } while ((retryCount--)>0);
      
      if (status != BDMCF_STATUS_OK)
         switch (data) {
            case BDMCF_RES_BUS_ERROR : return BDM_RC_CF_BUS_ERROR;
            case BDMCF_RES_ILLEGAL   : return BDM_RC_CF_ILLEGAL_COMMAND;
            case BDMCF_RES_NOT_READY : return BDM_RC_CF_NOT_READY;
            default                  : return BDM_RC_NO_CONNECTION;
         }
      *(U16*)dataPtr  = data;
      dataPtr        += 2;
   }
   return(BDM_RC_OK);
}
Пример #2
0
//! Transmits a 17 bit message
//!
//! @param dataOut  => data to Tx
//!
//! @return  \ref BDM_RC_OK                    => Success                                \n
//!          \ref BDM_RC_CF_BUS_ERROR          => Target returned Bus Error              \n
//!          \ref BDM_RC_CF_ILLEGAL_COMMAND    => Target returned Illegal Command error  \n
//!          \ref BDM_RC_NO_CONNECTION         => No connection / unexpected response
//!
//! @note To be used for transmitting the second message in a multi-message command which can fail \n 
//!      (e.g. because target is not halted). The correct target response in these cases is Not Ready
//!
U8 bdmcf_tx_msg_half_rx(U16 dataOut) {
U16 dataIn;

   (void)bdmcf_txrx_start();
   dataIn = bdmcf_txRx16(dataOut);
   switch (dataIn) {
      case BDMCF_RES_BUS_ERROR : return BDM_RC_CF_BUS_ERROR;
      case BDMCF_RES_ILLEGAL   : return BDM_RC_CF_ILLEGAL_COMMAND;
      case BDMCF_RES_NOT_READY : return BDM_RC_OK;
      default                  : return BDM_RC_NO_CONNECTION;
   }
}
Пример #3
0
//! Waits for command complete indication & send the next command.
//!
//! @param  next_cmd => next command to send
//!
//! @return  \ref BDM_RC_OK                    => Success                                \n
//!          \ref BDM_RC_CF_BUS_ERROR          => Target returned Bus Error              \n
//!          \ref BDM_RC_CF_ILLEGAL_COMMAND    => Target returned Illegal Command error  \n
//!          \ref BDM_RC_NO_CONNECTION         => No connection / unexpected response
//!
//! @note The next command is sent, the return value is for the \b PREVIOUS command. \n
//!       On error the next command, although sent, would be ignored by the target
//!
U8 bdmcf_complete_chk(U16 next_cmd) {
U8 retryCount = BDMCF_RETRY;
U8 status;
U16 returnData;

   do {
      status     = bdmcf_txrx_start();
      returnData = bdmcf_txRx16(next_cmd);
      if (status == BDMCF_STATUS_OK) {
         return(BDM_RC_OK);
      }
      if (returnData != BDMCF_RES_NOT_READY) { 
         break;
      }
   } while ((retryCount--)>0);
   
   switch (returnData) {
      case BDMCF_RES_BUS_ERROR : return BDM_RC_CF_BUS_ERROR;
      case BDMCF_RES_ILLEGAL   : return BDM_RC_CF_ILLEGAL_COMMAND;
      default                  : return BDM_RC_NO_CONNECTION;
   }
}
Пример #4
0
//! Transmits 16 bits, discards Rx data
//!
//! @param data => data to Tx
//!
void bdmcf_tx16(U16 data) {
	(void)bdmcf_txRx16(data);
}
Пример #5
0
//! Receives a 17 bit message while sending a NOP
//!
//! @param data  => pointer to where to store the Rx data
//!
//! @return status bit
//!
U8 bdmcf_rx_msg(U16 *data) {
U8 status;
   status  = bdmcf_txrx_start();
   *data   = bdmcf_txRx16(_BDMCF_CMD_NOP);
   return(status);
}
Пример #6
0
//! Transmits 16 bits, discards Rx data
//!
//! @param data => data to Tx
//!
void bdmcf_tx16(uint16_t data) {
	(void)bdmcf_txRx16(data);
}
Пример #7
0
//! Receives a 17 bit message while sending a NOP
//!
//! @param data  => pointer to where to store the Rx data
//!
//! @return status bit
//!
uint8_t bdmcf_rx_msg(uint16_t *data) {
uint8_t status;
   status  = bdmcf_txrx_start();
   *data   = bdmcf_txRx16(_BDMCF_CMD_NOP);
   return(status);
}