Functions | |
void | usb_device_task_init (void) |
void | usb_start_device (void) |
void | usb_device_task (void) |
Variables | |
bit | usb_suspended |
Public : (bit) usb_suspended usb_suspended is set to TRUE when USB is in suspend mode usb_suspended is set to FALSE otherwise /. | |
bit | usb_connected |
Public : (bit) usb_connected usb_connected is set to TRUE when VBUS has been detected usb_connected is set to FALSE otherwise /. |
void usb_device_task_init | ( | void | ) |
This function initializes the USB device controller.
This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager.
none |
none |
Definition at line 106 of file usb_device_task.c.
References Usb_disable, Usb_enable, and Usb_vbus_sense_init.
00107 { 00108 Usb_disable(); 00109 Usb_enable(); 00110 #if (VBUS_SENSING_IO == ENABLED) 00111 Usb_vbus_sense_init(); // init. the I/O used for Vbus sensing 00112 #endif 00113 }
void usb_start_device | ( | void | ) |
This function initializes the USB device controller This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager. Start device function is executed once VBUS connection has been detected either by the VBUS change interrupt either by the VBUS high level
none |
Definition at line 128 of file usb_device_task.c.
References Usb_attach, Usb_enable_reset_interrupt, Usb_enable_suspend_interrupt, Usb_freeze_clock, usb_init_device(), Usb_reset_all_system, Usb_reset_macro_only, Usb_unfreeze_clock, and Wait_pll_ready.
00129 { 00130 Usb_freeze_clock(); 00131 #ifndef USE_USB_AUTOBAUD 00132 Pll_start_auto(); 00133 #else 00134 usb_autobaud(); 00135 #endif 00136 Wait_pll_ready(); 00137 Disable_interrupt(); 00138 Usb_unfreeze_clock(); 00139 Usb_attach(); 00140 #if (USB_RESET_CPU == ENABLED) 00141 Usb_reset_all_system(); 00142 #else 00143 Usb_reset_macro_only(); 00144 #endif 00145 usb_init_device(); // configure the USB controller EP0 00146 Usb_enable_suspend_interrupt(); 00147 Usb_enable_reset_interrupt(); 00148 Enable_interrupt(); 00149 }
void usb_device_task | ( | void | ) |
Entry point of the USB device mamagement This function is the entry point of the USB management. Each USB event is checked here in order to launch the appropriate action. If a Setup request occurs on the Default Control Endpoint, the usb_process_request() function is call in the usb_standard_request.c file
none |
Definition at line 161 of file usb_device_task.c.
References EP_CONTROL, EVT_USB_RESET, FALSE, Is_usb_event, Is_usb_receive_setup, Is_usb_vbus_off, Is_usb_vbus_on, Stop_pll, TRUE, Usb_ack_event, usb_configuration_nb, usb_connected, Usb_detach, Usb_disable, Usb_enable, usb_process_request(), Usb_reset_endpoint, Usb_select_endpoint, usb_start_device(), and Usb_vbus_on_action.
00162 { 00163 if (usb_connected == FALSE) 00164 { 00165 #if (VBUS_SENSING_IO == ENABLED) 00166 if (Is_usb_vbus_on()) // check if Vbus ON to attach 00167 { 00168 Usb_enable(); 00169 usb_connected = TRUE; 00170 usb_start_device(); 00171 Usb_vbus_on_action(); 00172 } 00173 #else 00174 usb_connected = TRUE; // attach if application is not self-powered 00175 usb_start_device(); 00176 Usb_vbus_on_action(); 00177 #endif 00178 } 00179 00180 #if (VBUS_SENSING_IO == ENABLED) 00181 if ((usb_connected == TRUE) && Is_usb_vbus_off()) // check if Vbus OFF to detach 00182 { 00183 Usb_detach(); 00184 Usb_disable(); 00185 Stop_pll(); 00186 usb_connected = FALSE; 00187 usb_configuration_nb=0; 00188 } 00189 #endif 00190 00191 if(Is_usb_event(EVT_USB_RESET)) 00192 { 00193 Usb_ack_event(EVT_USB_RESET); 00194 Usb_reset_endpoint(0); 00195 usb_configuration_nb=0; 00196 } 00197 00198 // Here connection to the device enumeration process 00199 Usb_select_endpoint(EP_CONTROL); 00200 if (Is_usb_receive_setup()) 00201 { 00202 usb_process_request(); 00203 } 00204 }
bit usb_suspended |
Public : (bit) usb_suspended usb_suspended is set to TRUE when USB is in suspend mode usb_suspended is set to FALSE otherwise /.
Definition at line 79 of file usb_device_task.c.
bit usb_connected |
Public : (bit) usb_connected usb_connected is set to TRUE when VBUS has been detected usb_connected is set to FALSE otherwise /.
Definition at line 72 of file usb_device_task.c.