示例#1
0
//! Transmits a series of 17 bit messages
//!
//! @param count => number of messages to send
//! @param data  => pointer to message data buffer
//!
//! @note The first byte in the buffer is the MSB of the first message
//!
void bdmcf_tx(U8 count, U8 *data) {
   while(count--) {
      (void)bdmcf_txrx_start();
      bdmcf_tx16(*(U16*)data);
      data+=2;
   }
}
示例#2
0
	//! Resynchronizes communication with the target in case of noise on the CLK line, etc.
	//!
	//! @return  \ref BDM_RC_OK                    => success                     \n
	//!          \ref BDM_RC_NO_CONNECTION         => no connection with target   
	//!
	U8 bdmcf_resync(void) {
	U8  bitCount;
	U16 data;

	   (void)bdmcf_tx_msg(_BDMCF_CMD_NOP);     // Send in 3 NOPs to clear any error
	   (void)bdmcf_tx_msg(_BDMCF_CMD_NOP);
	   (void)bdmcf_rx_msg(&data);
	   if ((data&3)==0) {
	      // The last NOP did not return the expected value (at least one of the two bits should be 1)
	      return(BDM_RC_NO_CONNECTION);             
	   }
	   for (bitCount=20; bitCount>0; bitCount--) {  
		  // Now start sending in another NOP and watch the result
	      if (bdmcf_txrx_start()==0) {
	         break;   // The first 0 is the status bit
	      }
	   }
	   if (bitCount==0) { // No status bit found in 20 bits
	      return(BDM_RC_NO_CONNECTION);
	   }
	   // Transmitted & received the status bit, finish the NOP
	   bdmcf_tx16(_BDMCF_CMD_NOP);
	   
	   return(BDM_RC_OK);
	}
示例#3
0
//! Transmits a 17 bit message
//!
//! @param data  => data to Tx
//!
//! @return status bit
//!
U8 bdmcf_tx_msg(U16 data) {
U8 status;

   status = bdmcf_txrx_start();
   bdmcf_tx16(data);
   return(status);
}
示例#4
0
//! Transmits a series of 17 bit messages
//!
//! @param count => number of messages to send
//! @param data  => pointer to message data buffer
//!
//! @note The first byte in the buffer is the MSB of the first message
//!
void bdmcf_tx(uint8_t count, uint8_t *data) {
   while(count--) {
      (void)bdmcf_txrx_start();
      bdmcf_tx16(*(uint16_t*)data);
      data+=2;
   }
}
示例#5
0
//! Transmits a 17 bit message
//!
//! @param data  => data to Tx
//!
//! @return status bit
//!
uint8_t bdmcf_tx_msg(uint16_t data) {
uint8_t status;

   status = bdmcf_txrx_start();
   bdmcf_tx16(data);
   return(status);
}
示例#6
0
//! Resynchronizes communication with the target in case of noise on the CLK line, etc.
//!
//! @return  \ref BDM_RC_OK                    => success                     \n
//!          \ref BDM_RC_NO_CONNECTION         => no connection with target   
//!
U8 bdmcf_resync(void) {
U8  bitCount;
U16 data;
U8 status;

   (void)bdmcf_tx_msg(_BDMCF_CMD_NOP);     // Send in 3 NOPs to clear any error
   (void)bdmcf_tx_msg(_BDMCF_CMD_NOP);
   status = bdmcf_rx_msg(&data);

   if (status == 1) {
	   // Check for cases that are unlikely to be chance on loss of sync
	   // and likely to confuse the sync which looks for a single zero bit
	   switch (data) {
	      case BDMCF_RES_BUS_ERROR :	// 1,00000000,00000001 
	    	  return BDM_RC_CF_BUS_ERROR; 
	      case BDMCF_RES_NOT_READY :	// 1,00000000,00000000 
	    	  return BDM_RC_CF_NOT_READY;
	      default                  :    // Fall through
	    	  break; 
	   }	   
   }
   
   for (bitCount=20; bitCount>0; bitCount--) {  
	  // Now start sending in another NOP and watch the result
      if (bdmcf_txrx_start()==0) {
         break;   // The first 0 is the status bit
      }
   }
   if (bitCount==0) { // No status bit found in 20 bits
      return(BDM_RC_NO_CONNECTION);
   }
   // Transmitted & received the status bit, finish the NOP
   bdmcf_tx16(_BDMCF_CMD_NOP);
   
   return(BDM_RC_OK);
}