Functions | |
void | usb_device_task_init (void) |
This function initializes the USB device controller. | |
void | usb_start_device (void) |
This function initializes the USB device controller. | |
void | usb_device_task (void) |
Entry point of the USB device mamagement. | |
void | usb_autobaud (void) |
USB based autobaud function. | |
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 /. |
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 |
Definition at line 103 of file usb_device_task.c.
References Usb_disable, Usb_enable, and Usb_vbus_sense_init.
Referenced by usb_task_init().
00104 { 00105 Usb_disable(); 00106 Usb_enable(); 00107 #if (VBUS_SENSING_IO == ENABLED) 00108 Usb_vbus_sense_init(); // init. the I/O used for Vbus sensing 00109 #endif 00110 }
Here is the caller graph for this function:
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 125 of file usb_device_task.c.
References Usb_attach, usb_autobaud(), 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.
Referenced by usb_device_task().
00126 { 00127 Usb_freeze_clock(); 00128 #ifdef BYPASS_USB_AUTOBAUD 00129 Pll_start_auto(); 00130 #else 00131 usb_autobaud(); 00132 #endif 00133 Wait_pll_ready(); 00134 Usb_unfreeze_clock(); 00135 Usb_attach(); 00136 #if (USB_RESET_CPU == ENABLED) 00137 Usb_reset_all_system(); 00138 #else 00139 Usb_reset_macro_only(); 00140 #endif 00141 Usb_enable_suspend_interrupt(); 00142 Usb_enable_reset_interrupt(); 00143 Enable_interrupt(); 00144 usb_init_device(); // configure the USB controller EP0 00145 }
Here is the call graph for this function:
Here is the caller graph for this function:
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 157 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.
Referenced by usb_task().
00158 { 00159 if (usb_connected == FALSE) 00160 { 00161 #if (VBUS_SENSING_IO == ENABLED) 00162 if (Is_usb_vbus_on()) // check if Vbus ON to attach 00163 { 00164 Usb_enable(); 00165 usb_connected = TRUE; 00166 usb_start_device(); 00167 Usb_vbus_on_action(); 00168 } 00169 #else 00170 usb_connected = TRUE; // attach if application is not self-powered 00171 usb_start_device(); 00172 Usb_vbus_on_action(); 00173 #endif 00174 } 00175 00176 #if (VBUS_SENSING_IO == ENABLED) 00177 if ((usb_connected == TRUE) && Is_usb_vbus_off()) // check if Vbus OFF to detach 00178 { 00179 Usb_detach(); 00180 Usb_disable(); 00181 Stop_pll(); 00182 usb_connected = FALSE; 00183 usb_configuration_nb=0; 00184 } 00185 #endif 00186 00187 if(Is_usb_event(EVT_USB_RESET)) 00188 { 00189 Usb_ack_event(EVT_USB_RESET); 00190 Usb_reset_endpoint(0); 00191 usb_configuration_nb=0; 00192 } 00193 00194 // Here connection to the device enumeration process 00195 Usb_select_endpoint(EP_CONTROL); 00196 if (Is_usb_receive_setup()) 00197 { 00198 usb_process_request(); 00199 } 00200 }
Here is the call graph for this function:
Here is the caller graph for this function:
void usb_autobaud | ( | void | ) |
USB based autobaud function.
This function performs an autobaud configuration for the USB interface. the autobaud function performs the configuration of the PLL dedicated to the USB interface. The autobaud algorithm consists in trying each USB PLL until the correct detection of Start of Frame (USB SOF).
none |
Clear TOV2 flag and counter value
Clear TOV2 flag and counter value
FOSC 16MHz
FOSC 8MHz
Definition at line 216 of file usb_device_task.c.
References Is_not_wdt_early_warning, PLLx03, PLLx06, Start_pll, Wdt_change_interrupt_16ms, and Wdt_off.
Referenced by usb_start_device().
00217 { 00218 00219 U16 count_rc=0; 00220 00221 volatile U16 tempo; 00222 00223 Wdt_change_interrupt_16ms(); 00224 TCCR1B=0x00; TCCR1A=0x00; 00225 TCNT1=0x00; TIFR1=0x01; 00226 00227 TCCR1B|=(1<<CS01) |(1<<CS00); // ClkIO/64, with prescaler /2 -> XTAL/128 00228 WDTCKD|=(1<<WDEWIE); 00229 while(Is_not_wdt_early_warning()); 00230 TCCR1B=0; 00231 Wdt_off(); 00232 WDTCKD|=(1<<WDEWIF); // Clear early warning flag 00233 WDTCKD=0; // Clear early warning flag 00234 00235 count_rc=TCNT1; 00236 TCCR1B=0x00; TCCR1A=0x00; 00237 TCNT1=0x00; TIFR1=0x01; 00238 if(count_rc>1500) // 16MHz/128 with 16ms watchdog gives 2000 ticks 00239 { 00240 Start_pll(PLLx03); 00241 } 00242 else 00243 { 00244 Start_pll(PLLx06); 00245 } 00246 00247 }
Here is the caller graph for this function:
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 76 of file usb_device_task.c.
Referenced by usb_general_interrupt().