⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hid_usb_config.c

📁 freescale badge board 开发板测试 源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
 * HID reset event handler. 
 ****************************************************************************/
void got_usb_reset(void)
{
  /* empty */
}

/*****************************************************************************
 * Return the HID descriptor for the selected device.
 ****************************************************************************/
descriptor_info_t *get_hid_descriptor(void)
{
  switch(device_mode)
  {
  case dm_kbd:
    di.start_addr=(void *)(kbd_config_descriptor+9+3+9);
    di.size=9;    
    break;
  case dm_mouse:
    di.start_addr=(void *)(mou_config_descriptor+9+3+9);
    di.size=9;    
    break;  
  case dm_generic:
    di.start_addr=(void *)(geh_config_descriptor+9+3+9);
    di.size=9;    
    break;  
  }
  return(&di);
}

/*****************************************************************************
 * Return the report descriptor for the selected device.
 ****************************************************************************/
descriptor_info_t *get_report_descriptor(void)
{
  switch(device_mode)
  {
  case dm_kbd:
    di.start_addr=(void *)kbd_report_descriptor;
    di.size=sizeof(kbd_report_descriptor);
    break;
  case dm_mouse:
    di.start_addr=(void *)mou_report_descriptor;
    di.size=sizeof(mou_report_descriptor);    
    break;  
  case dm_generic:
    di.start_addr=(void *)geh_report_descriptor;
    di.size=sizeof(geh_report_descriptor);
    break;  
  }        
  return(&di);
}

/*****************************************************************************
 * Return the physical descriptor for the selected device.
 ****************************************************************************/
descriptor_info_t *get_physical_descriptor(hcc_u8 id)
{
  switch(device_mode)
  {
  case dm_kbd:
  case dm_mouse:
  case dm_generic:
    return(0);
  }    
  /* Can newer get here. Line added to avoid compiler warnings. */
  return((void*)(id ? 0 : 0));
}


/*****************************************************************************
 * Return the USB device descriptor.
 ****************************************************************************/
void* get_device_descriptor(void)
{
  switch(device_mode)
  {
  case dm_kbd:
    return((void *)kbd_device_descriptor);
    break;
  case dm_mouse:
    return((void *)mou_device_descriptor);
    break;  
  case dm_generic:
    return((void *)geh_device_descriptor);
    break;  
  }
  return(0);
}

/*****************************************************************************
 * Return !=0 if the specified index is the index of a configuration.
 ****************************************************************************/
hcc_u8 is_cfgd_index(hcc_u16 cndx)
{
  switch(device_mode)
  {
  case dm_kbd:
  case dm_mouse:
  case dm_generic:
    return((hcc_u8)(cndx < 2 ? 1u : 0u));
    break;  
  }    
  /* Can newer get here. Line added to avoid compiler warnings. */
  return(0);
}

/*****************************************************************************
 * Return the selected configuration descriptor.
 ****************************************************************************/
void *get_cfg_descriptor(hcc_u8 cndx)
{
  switch(device_mode)
  {
  case dm_kbd:
    return((void *)kbd_config_descriptor);
    break;
  case dm_mouse:
    return((void *)mou_config_descriptor);
    break;  
  case dm_generic:
    return((void *)geh_config_descriptor);
    break;  
  }
  /* Can newer get here. Line added to avoid compiler warnings. */
  return((void*)(cndx ? 0 : 0));
}

/*****************************************************************************
 * Return !=0 if a string descriptor exist whit the specified index.
 ****************************************************************************/
hcc_u8 is_str_index(hcc_u8 sndx)
{
  switch(device_mode)
  {
  case dm_kbd:
    return ((hcc_u8)(sndx < sizeof(kbd_string_descriptors)/sizeof(kbd_string_descriptors[0]) 
             ? 1u : 0u));
    break;
  case dm_mouse:
    return ((hcc_u8)(sndx < sizeof(mou_string_descriptors)/sizeof(mou_string_descriptors[0])
             ? 1u : 0u));
    break;  
  case dm_generic:
    return ((hcc_u8)(sndx < sizeof(geh_string_descriptors)/sizeof(geh_string_descriptors[0])
             ? 1u : 0u));
    break;
  }        
  return(0);
}

/*****************************************************************************
 * Get the specified string descriptor.
 ****************************************************************************/
void *get_str_descriptor(hcc_u8 sndx)
{
  switch(device_mode)
  {
  case dm_kbd:
    return((void*)kbd_string_descriptors[sndx]);
  case dm_mouse:
    return ((void*)mou_string_descriptors[sndx]);
  case dm_generic:
    return ((void*)geh_string_descriptors[sndx]);
  }            
  /* Can newer get here. Line added to avoid compiler warnings. */  
  return(0);
}

/*****************************************************************************
 * Return !=0 if the secified interface exist.
 ****************************************************************************/
hcc_u8 is_ifc_ndx(hcc_u8 cndx, hcc_u8 indx, hcc_u8 iset)
{ 
  switch(device_mode)
  {
  case dm_kbd:
  case dm_mouse:
  case dm_generic:
    if (cndx != 1 || iset !=0)
    {
      return(0); 
    }
    return((hcc_u8)(indx < 1 ? 1 : 0));
  }        
  return(0);
}

/*****************************************************************************
 * Return !=0 if the specified endpoint exist.
 ****************************************************************************/
hcc_u8 is_ep_ndx(hcc_u8 cndx, hcc_u8 indx, hcc_u8 iset, hcc_u8 endx)
{
  switch(device_mode)
  {
  case dm_kbd:
  case dm_mouse:
  case dm_generic:
    if (cndx != 1 || indx !=0  || iset !=0)
    {
      return(0); 
    }
    return((hcc_u8)(endx < 1 ? 1 : 0));
  }  
  return(0);
}

/*****************************************************************************
 * Return the endpoint descriptor of the specified endpoint.
 ****************************************************************************/
void *get_ep_descriptor(hcc_u8 cndx, hcc_u8 indx, hcc_u8 iset, hcc_u8 endx)
{
  switch(device_mode)
  {
  case dm_kbd:
    return((void*) (kbd_config_descriptor+9+3+9+9) );
  case dm_mouse:
    return((void*) (mou_config_descriptor+9+3+9+9));
  case dm_generic:
    return((void*) (geh_config_descriptor+9+3+9+9) );
  }
  /* Can newer get here. Line added to avoid compiler warnings. */
  return((void*)(cndx+indx+iset+endx ? 0 : 0));
}

/*****************************************************************************
 * Return packet buffer of the specified endpoint.
 ****************************************************************************/
void *get_ep_rx_buffer(hcc_u8 ep, hcc_u8 buf)
{
  switch(ep)
  {
  case 0:
    if (!buf)
    {
      return(buf_ep00);
    }
    else
    {
      return(buf_ep01);    
    }
    break;
  }
  return(0);
}

#ifdef ON_THE_GO
callback_state_t usb_ep0_callback(void)
{
  callback_state_t r;   
  r=usb_ep0_hid_callback();
  if (r==clbst_error)
  {
    r=usb_ep0_otg_callback();
  }
  return(r);
}
#else
callback_state_t usb_ep0_callback(void)
{
  return(usb_ep0_hid_callback());
}
#endif
/****************************** END OF FILE **********************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -