#include "config.h"#include "conf_usb.h"#include "host_hid_task.h"#include "modules/usb/host_chap9/usb_host_task.h"#include "modules/usb/host_chap9/usb_host_enum.h"#include "lib_mcu/usb/usb_drv.h"
Go to the source code of this file.
Defines | |
| #define | LOG_STR_CODE(str) |
Functions | |
| void | host_hid_task_init (void) |
| This function initializes the host generic HID application. | |
| void | host_hid_task (void) |
Variables | |
| U8 | hid_connected |
| S8 | hid_temperature = 0 |
| U8 | hid_potentiometer = 0 |
| U8 | hid_enter_dfu |
| static U8 | pipe_hid_in |
| static U8 | pipe_hid_out |
Definition in file host_hid_task.c.
| #define LOG_STR_CODE | ( | str | ) |
Definition at line 60 of file host_hid_task.c.
| void host_hid_task_init | ( | void | ) |
This function initializes the host generic HID application.
| none |
Definition at line 84 of file host_hid_task.c.
References hid_connected, and hid_enter_dfu.
00085 { 00086 hid_enter_dfu=0; 00087 hid_connected=0; 00088 }
| void host_hid_task | ( | void | ) |
This function manages the host generic HID application
| none |
Definition at line 95 of file host_hid_task.c.
References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, FALSE, Get_class, Get_ep_addr, Get_nb_supported_interface, Get_protocol, Get_subclass, HID_CLASS, hid_connected, hid_enter_dfu, hid_potentiometer, hid_temperature, Host_ack_in_received, Host_continuous_in_mode, host_get_hwd_pipe_nb(), Host_select_pipe, host_send_control(), host_send_data(), Host_send_in, Host_unfreeze_pipe, i, Is_device_disconnection_event, Is_ep_addr_in, Is_host_in_received, Is_host_ready, Is_host_stall, Is_new_device_connection_event, Leds_off, LOG_STR_CODE, NO_PROTOCOL, NO_SUBCLASS, PIPE_HID_IN, PIPE_HID_OUT, REPORT_TYPE_FEATURE, SETUP_HID_SET_REPORT, TRUE, S_usb_setup_data::uncomplete_read, Usb_read_byte, usb_request, USB_SETUP_SET_CLASS_INTER, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
00096 { 00097 U8 i; 00098 U8 buf_hid[8]; 00099 00100 // Test HID device connection 00101 if(Is_host_ready()) 00102 { 00103 if(Is_new_device_connection_event()) //Device connection 00104 { 00105 hid_connected=0; 00106 hid_enter_dfu=0; 00107 for(i=0;i<Get_nb_supported_interface();i++) 00108 { 00109 if(Get_class(i)==HID_CLASS && Get_subclass(i)==NO_SUBCLASS && Get_protocol(i)==NO_PROTOCOL) 00110 { 00111 LOG_STR_CODE(log_hid_connect); 00112 hid_connected=1; 00113 if(Is_ep_addr_in(Get_ep_addr(i,0))) 00114 { 00115 PIPE_HID_IN=host_get_hwd_pipe_nb(Get_ep_addr(i,0)); 00116 PIPE_HID_OUT=host_get_hwd_pipe_nb(Get_ep_addr(i,1)); 00117 } 00118 else 00119 { 00120 PIPE_HID_IN=host_get_hwd_pipe_nb(Get_ep_addr(i,1)); 00121 PIPE_HID_OUT=host_get_hwd_pipe_nb(Get_ep_addr(i,0)); 00122 } 00123 Host_select_pipe(PIPE_HID_IN); 00124 Host_continuous_in_mode(); 00125 Host_unfreeze_pipe(); 00126 break; 00127 } 00128 } 00129 } 00130 if(hid_connected) 00131 { 00132 Host_select_pipe(PIPE_HID_IN); 00133 if(Is_host_in_received()) 00134 { 00135 if(Is_host_stall()==FALSE) 00136 { 00137 #if( HID_GENERIC_DEMO_FULL == ENABLE ) 00138 i=Usb_read_byte(); // Leds 00139 i=Usb_read_byte(); // Joystick 00140 hid_potentiometer=Usb_read_byte(); // Potentiometer 00141 hid_temperature=Usb_read_byte(); // Temperature 00142 #else 00143 i=Usb_read_byte(); // Joystick 00144 #endif 00145 } 00146 Host_ack_in_received(); Host_send_in(); 00147 } 00148 if(hid_enter_dfu==TRUE) 00149 { 00150 LOG_STR_CODE(log_enter_boot); 00151 #if( HID_GENERIC_DEMO_FULL == ENABLE ) 00152 buf_hid[3]=0x55; 00153 buf_hid[4]=0xAA; 00154 host_send_data(PIPE_HID_OUT, 8, buf_hid); 00155 #else 00156 buf_hid[0]=0x55; 00157 buf_hid[1]=0xAA; 00158 buf_hid[2]=0x55; 00159 buf_hid[3]=0xAA; 00160 usb_request.bmRequestType = USB_SETUP_SET_CLASS_INTER; 00161 usb_request.bRequest = SETUP_HID_SET_REPORT; 00162 usb_request.wValue = (REPORT_TYPE_FEATURE<<8); 00163 usb_request.wIndex = 0; 00164 usb_request.wLength = 4; 00165 usb_request.uncomplete_read = FALSE; 00166 host_send_control(buf_hid); 00167 #endif 00168 } 00169 } 00170 } 00171 //Device disconnection... 00172 if(Is_device_disconnection_event()) 00173 { 00174 Leds_off(); 00175 hid_connected=0; 00176 hid_enter_dfu=0; 00177 } 00178 }
| S8 hid_temperature = 0 |
| U8 hid_potentiometer = 0 |
Definition at line 73 of file host_hid_task.c.
Referenced by host_hid_task(), and host_hid_task_init().
U8 pipe_hid_in [static] |
Definition at line 74 of file host_hid_task.c.
U8 pipe_hid_out [static] |
Definition at line 75 of file host_hid_task.c.
1.5.3