Esempio n. 1
0
int printf(const char *format, ...) {
	register int *varg = (int *) (&format);
	char *bufptr = buf;
	int sz = print(&bufptr, varg);
	int i;
/*	
	int x = 0;
	for (x = 0; x < sz; x++) {
		puts(buf[x]);
	}
*/
	i=sz;
		
	buf[i++] = '\r';
	buf[i++] = '\n';
	while(i < 255){
		buf[i++] = '\r';			
	}
		
		USB_To_USART_Send_Data(buf,i);
		
				
//		i++;
//		sz=sz-64;	
//	}
	//USB_OTG_BSP_uDelay(1000);
	return sz;
}
Esempio n. 2
0
/*******************************************************************************
* Function Name  : EP3_OUT_Callback
* Description    :
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void EP3_OUT_Callback(void)
{
  uint16_t USB_Rx_Cnt;
  char *BootCodeStr = "CM9X";
  uint16_t i;

  /* Get the received data buffer and update the counter */
  USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer);
  
  /* USB data will be immediately processed, this allow next USB traffic being 
  NAKed till the end of the USART Xfer */

  if( reset_state == DTR_NEGEDGE ) 
  {
    reset_state = DTR_LOW;

    if( USB_Rx_Cnt >= 4 )
    {
      for( i=0; i<4; i++ )
      {
        if( BootCodeStr[i] != USB_Rx_Buffer[i] ) break;
      }

      if( i == 4 )
      {
        Hw_IWDG_GoToBoot();
      }
    }
  }

  USB_To_USART_Send_Data(USB_Rx_Buffer, USB_Rx_Cnt);
 
  /* Enable the receive of data on EP3 */
  SetEPRxValid(ENDP3);
}
Esempio n. 3
0
/*******************************************************************************
* Function Name  : EP3_OUT_Callback
* Description    :
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void EP3_OUT_Callback(void)
{
	uint16_t USB_Rx_Cnt;

	/* Get the received data buffer and update the counter */
	USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer);

	/* USB data will be immediately processed, this allow next USB traffic being 
	NAKed till the end of the USART Xfer */
	USB_To_USART_Send_Data(USB_Rx_Buffer, USB_Rx_Cnt);
	/* Enable the receive of data on EP3 */
	SetEPRxValid(ENDP3);
}
Esempio n. 4
0
/*******************************************************************************
* Function Name  : EP3_OUT_Callback
* Description    :
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void EP3_OUT_Callback(void)
{
  uint16_t USB_Rx_Cnt;
  int i;
  

  /* Get the received data buffer and update the counter */
  USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer);
  
  /* USB data will be immediately processed, this allow next USB traffic being 
  NAKed till the end of the USART Xfer */
  
  USB_To_USART_Send_Data(USB_Rx_Buffer, USB_Rx_Cnt);
 
  if( USB_Rx_Cnt >= 4 )
  {
	  uint8_t cmpBuf[4] = {0x43,0x4D,0x39,0x58};//{0x31, 0x45, 0x41, 0x46};
	  if (reset_state == DTR_NEGEDGE)
	  {
		  reset_state = DTR_LOW;
	      bool cmpMatch = TRUE;
	      for (i=0; i<4; i++)
	      {
	          if (USB_Rx_Buffer[i] != cmpBuf[i]) {
	              cmpMatch = FALSE;
	          }
	      }


	      if( cmpMatch == TRUE )
	      {
	    		IWDG->PR  = 0; 		// divider / 4
	    		IWDG->RLR = 1;
	    		IWDG->KR  = 0xCCCC;	// Start
	      }
	  }
  }


  //dbg_print("USB Rx\r\n");

  /* Enable the receive of data on EP3 */
  SetEPRxValid(ENDP3);
}