Esempio n. 1
0
static void App_HandleUserInput(void)
{
 uint_8 character = TERMIO_GetCharNB();
 
 switch(character)
 {
  case '1': if(_usb_otg_hnp_enable(0, TRUE) == USB_OK)
            {    
             printf("\n\rHNP enabled");
            }
            else
            {
             printf("\n\rError enabling HNP");
            }
   break;
  
  case '2': if(_usb_otg_hnp_enable(0, FALSE) == USB_OK)
            {    
             printf("\n\rHNP disabled");
            }
            else
            {
             printf("\n\rError disabling HNP");
            }             
   break;
  
  case '3': if(_usb_otg_bus_request(otg_handle) == USB_OK)
            {    
             printf("\n\rBus request");
            }
            else
            {
             printf("\n\rError requesting the bus");
            }            
   break;
  
  case '4': if(_usb_otg_bus_release(otg_handle) == USB_OK)
            {    
             printf("\n\rBus release");
            }
            else
            {
             printf("\n\rError releasing the bus");
            }             
   break;         
  
  
  case '5': if(_usb_otg_session_request(otg_handle) == USB_OK)
            {    
             printf("\n\rSRP request");
            }
            else
            {
             printf("\n\rError rerequesting SRP");
            }
   break;           
   
    case '6': _usb_otg_set_a_bus_req(otg_handle , TRUE);
                
             printf("\n\rA BUS REQ");
            
   break;
    case '7': _usb_otg_set_a_bus_req(otg_handle , FALSE);
                
             printf("\n\rA BUS RELEASE");
   break;
   
    case '8': _usb_otg_set_a_bus_drop(otg_handle , TRUE);
                
             printf("\n\rA BUS DROP TRUE");
   break;
    case '9': _usb_otg_set_a_bus_drop(otg_handle , FALSE);
                
             printf("\n\rA BUS DROP FALSE");
   break;
    case 'a':
    case 'A':
             _usb_otg_set_a_clear_err(otg_handle);
   break; 
  
  case 'p':
  case 'P': App_PrintMenu();
   break;
  
  
  default: break;          
 }
}
Esempio n. 2
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : App_OtgCallback
* Returned Value : none
* Comments       :
*
*
*END*--------------------------------------------------------------------*/
void App_OtgCallback(usb_otg_handle handle, uint32_t event)
{
    (void)handle; /* not used */

    if (event & OTG_B_IDLE)
    {
        g_dev_type = dev_b;               /* Device type: B */
        g_sess_vld = FALSE;               /* session not valid */
        g_otg_state = OTG_B_IDLE;
    }

    if (event & OTG_B_IDLE_SRP_READY)
    {
        g_otg_state = OTG_B_IDLE_SRP_READY;
    }
    if (event & OTG_B_PERIPHERAL)
    {
        g_otg_state = OTG_B_PERIPHERAL;
        if (g_sess_vld == FALSE)
        {
            g_sess_vld = TRUE;                /* session valid */
        }
    }
    if (event & OTG_B_HOST)
    {
        g_otg_state = OTG_B_HOST;
    }
    if (event & OTG_B_A_HNP_REQ)
    {
        (void)_usb_otg_bus_release(g_otg_handle);
    }
    if (event & OTG_A_WAIT_BCON_TMOUT)
    {
        _usb_otg_set_a_bus_req(g_otg_handle , FALSE);
    }
    if (event & OTG_A_BIDL_ADIS_TMOUT)
    {
        _usb_otg_set_a_bus_req(g_otg_handle, TRUE);
    }
    if (event & OTG_A_B_HNP_REQ)
    {
        _usb_otg_set_a_bus_req( handle , FALSE);
    }
    if (event & OTG_A_IDLE)
    {
        g_dev_type = dev_a;                 /* Device type: A */
        g_sess_vld = FALSE;
        g_otg_state = OTG_A_IDLE;
    }
    if (event & OTG_A_WAIT_VRISE)
    {
        g_otg_state = OTG_A_WAIT_VRISE;
        _usb_otg_set_a_bus_req( handle , TRUE);
    }
    if (event & OTG_A_WAIT_BCON)
    {
        g_sess_vld = TRUE;
        g_otg_state = OTG_A_WAIT_BCON;
    }
    if (event & OTG_A_HOST)
    {
        g_otg_state = OTG_A_HOST;
    }
    if (event & OTG_A_SUSPEND)
    {
        g_otg_state = OTG_A_SUSPEND;
    }
    if (event & OTG_A_PERIPHERAL)
    {
        g_otg_state = OTG_A_PERIPHERAL;
    }
    if (event & OTG_A_WAIT_VFALL)
    {
        if (g_vbus_err == TRUE)
        {
            g_vbus_err = FALSE;
        }
        g_otg_state = OTG_A_WAIT_VFALL;
    }
    if (event & OTG_A_VBUS_ERR)
    {
        g_vbus_err = TRUE;
        g_otg_state = OTG_A_VBUS_ERR;
    }
    OS_Event_set(g_otg_app_event_handle, event);
}
Esempio n. 3
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : App_OtgCallback
* Returned Value : none
* Comments       :
*     
*
*END*--------------------------------------------------------------------*/
void App_OtgCallback(_usb_otg_handle handle, OTG_EVENT event)
{
	(void)handle; /* not used */		

	
	if(event & OTG_B_IDLE)
	{
	  printf("\n\r>B: OTG state change to B idle");
		dev_type = dev_b;               /* Device type: B */
		sess_vld = FALSE;           /* session not valid */
	}
	
	if(event & OTG_B_IDLE_SRP_READY)
	{
	  printf("\n\r>B: OTG is ready to initialize SRP");
	}
	
	if(event & OTG_B_SRP_INIT)
	{
	  printf("\n\r>B: OTG has initialized SRP");
	}	
	
	if(event & OTG_B_SRP_FAIL)
	{
	  printf("\n\r>B: OTG SRP failed to get a response from the Host");
	}	
	
	if(event & OTG_B_PERIPHERAL)
	{
	  printf("\n\r>B: OTG state change to B peripheral.");
	  printf("\n\r>B: USB peripheral stack initialized.");
	  DISABLE_USB_5V; /* disable Vhost */
	  if(sess_vld == FALSE)
	  {
	    sess_vld = TRUE;      /* session valid */  
	  }	  
	}
	
	if(event & OTG_B_PERIPHERAL_LOAD_ERROR)	
	{
	  printf("\n\r>B: OTG state change to B peripheral.");
	  printf("\n\r>B: USB peripheral stack initialization failed."); 
	}
	
	if(event & OTG_B_PERIPHERAL_HNP_READY)
	{
	  printf("\n\r>B: OTG is ready to initialize HNP. Press SW1 to request the bus.");	  
	}
	
	if(event & OTG_B_PERIPHERAL_HNP_START)
	{
	  printf("\n\r>B: OTG has initialized the HNP to request the bus from Host");	  
	}
	
	if(event & OTG_B_PERIPHERAL_HNP_FAIL)
	{
	  printf("\n\r>B: HNP failed. OTG is back into peripheral state");
	}
	
  if(event & OTG_B_HOST)
	{ 	  
 	  printf("\n\r>B: OTG is in the Host state");
 	  printf("\n\r>B: USB host stack initialized.");
	}

  if(event & OTG_B_HOST_LOAD_ERROR)
  {
    printf("\n\r>B: OTG is in the Host state");
    printf("\n\r>B: USB host stack initialization failed.");    
  }
  
  if(event & OTG_B_A_HNP_REQ) 
  {
    if(_usb_otg_bus_release(otg_handle) == USB_OK)
    {    
      printf("\n\rBus release");
    }
    else
    {
      printf("\n\rError releasing the bus");
    }
  }
	
	if(event & OTG_A_WAIT_BCON_TMOUT)
	{
	 printf("\n\r>A: OTG_A_WAIT_BCON_TMOUT");
	 _usb_otg_set_a_bus_req(otg_handle , FALSE);
	 
 	}

	if(event & OTG_A_BIDL_ADIS_TMOUT)
	{
	  printf("\n\r>A: OTG_A_BIDL_ADIS_TMOUT");
	  _usb_otg_set_a_bus_req(otg_handle, TRUE);	 
 	}

	if(event & OTG_A_AIDL_BDIS_TMOUT)
	{
	  printf("\n\r>A: OTG_A_AIDL_BDIS_TMOUT");
 	}

	
  if(event & OTG_A_ID_TRUE)
  {
    printf("\n\r>A: ID = TRUE ");
    ENABLE_USB_5V; /* enable Vhost */
  }
	
	
	if(event & OTG_A_WAIT_VRISE_TMOUT)
	{
	  printf("\n\r>A: VBUS rise failed"); 
	}
	
	if(event & OTG_A_B_HNP_REQ)
	{
	  printf("\n\r>A: OTG_A_B_HNP_REQ");
	  _usb_otg_set_a_bus_req( handle , FALSE); 
	 
	}
	
	if(event & OTG_A_IDLE)
	{
		printf("\n\r>A: OTG state change to A_IDLE");
		host_stack_active  = FALSE;
	  dev_stack_active = FALSE;
	  
	  dev_type = dev_a;             /* Device type: A */
	  sess_vld = FALSE;
	}
	
  if(event & OTG_A_WAIT_VRISE)
	{
	  printf("\n\r>A: OTG state change to A_WAIT_VRISE"); 
	}
	  
  if(event & OTG_A_WAIT_BCON)
	{
	  printf("\n\r>A: OTG state change to A_WAIT_BCON");
	  
	  sess_vld = TRUE; 
	}
	
	if(event & OTG_A_HOST)
	{
		printf("\n\r>A: OTG state change to OTG_A_HOST"); 
	  printf("\n\r>A: USB host stack initialized.");

	}
	if(event & OTG_A_HOST_LOAD_ERROR)
	{
   	printf("\n\r>A: OTG state change to OTG_A_HOST"); 
	  printf("\n\r>A: USB host stack initialization failed."); 
  }
	
  if(event & OTG_A_SUSPEND)
	{
 	  printf("\n\r>A: OTG state change to A_SUSPEND");
	}	

  if(event & OTG_A_PERIPHERAL)
	{ 	  
 	  printf("\n\r>A: OTG state change to A_PERIPHERAL	");
 	  printf("\n\r>A: USB peripheral stack initialized."); 
	}	
  
  if(event & OTG_A_PERIPHERAL_LOAD_ERROR)
	{
 	  printf("\n\r>A: USB peripheral stack initialization failed."); 
	  printf("\n\r>A: OTG state change to A_PERIPHERAL	");
	}	

  if(event & OTG_A_WAIT_VFALL)
	{
	  printf("\n\r>A: OTG state change to OTG_A_WAIT_VFALL"); 
	  
	  if(vbus_err == TRUE)
	  {
	    vbus_err = FALSE;
	  }
	}
	
	if(event & OTG_A_VBUS_ERR)
	{
	  printf("\n\r>A: VBUS falls below VBUS_Valid treshold"); 
	  printf("\n\r>A: OTG state change to A_VBUS_ERR");
	  
	  vbus_err = TRUE;
	}		
}