/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { switch (event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ chSysLockFromIsr(); usbInitEndpointI(usbp, USB_CDC_DATA_REQUEST_EP, &ep1config); usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &ep2config); usbInitEndpointI(usbp, USB_CDC_DATA_AVAILABLE_EP, &ep3config); chSysUnlockFromIsr(); return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { extern SerialUSBDriver SDU1; switch (event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: chSysLockFromISR(); /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ usbInitEndpointI(usbp, USBD1_DATA_REQUEST_EP, &ep1config); usbInitEndpointI(usbp, USBD1_INTERRUPT_REQUEST_EP, &ep2config); /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(&SDU1); chSysUnlockFromISR(); return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
static void usb_event(USBDriver *usbp, usbevent_t event) { switch (event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: chSysLockFromISR(); /* Enable the endpoints specified in the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ usbInitEndpointI(usbp, USBD2_DATA_IN_EP, &ep1config); usbInitEndpointI(usbp, USBD2_INTERRUPT_REQUEST_EP, &ep2config); sduConfigureHookI(&UsbCDC.SDU2); // Resetting the state of the CDC subsystem App.SignalEvtI(EVTMSK_USB_READY); chSysUnlockFromISR(); return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } // switch }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { (void) usbp; switch (event) { case USB_EVENT_RESET: palTogglePad(GPIOD, GPIOD_LED6); return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ chSysLockFromIsr(); usbInitEndpointI(usbp, 1, &ep1config); usbInitEndpointI(usbp, 2, &ep2config); chSysUnlockFromIsr(); //allow the main thread to init the transfers initUSB =1; return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } palTogglePad(GPIOD, GPIOD_LED5); return; }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { // (void)usbp; #if defined(DEBUG_USB) usb_debug_putX(' '); #endif /* DEBUG_USB */ switch (event) { case USB_EVENT_RESET: #if defined(DEBUG_USB) usb_debug_putX('\n'); usb_debug_putX('\r'); #endif /* DEBUG_USB */ return; case USB_EVENT_ADDRESS: #if defined(DEBUG_USB) usb_debug_putX('V'); #endif /* DEBUG_USB */ return; case USB_EVENT_CONFIGURED: #if defined(DEBUG_USB) usb_debug_putX('W'); #endif /* DEBUG_USB */ chSysLockFromISR(); /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ usbInitEndpointI(usbp, USBD1_DATA_REQUEST_EP, &ep1config); usbInitEndpointI(usbp, USBD1_INTERRUPT_REQUEST_EP, &ep2config); /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(&SDU1); chSysUnlockFromISR(); return; case USB_EVENT_SUSPEND: #if defined(DEBUG_USB) usb_debug_putX('X'); #endif /* DEBUG_USB */ return; case USB_EVENT_WAKEUP: #if defined(DEBUG_USB) usb_debug_putX('Y'); #endif /* DEBUG_USB */ return; case USB_EVENT_STALLED: #if defined(DEBUG_USB) usb_debug_putX('Z'); #endif /* DEBUG_USB */ return; } return; }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { extern SerialUSBDriver SDU1; extern SerialUSBDriver SDU2; switch (event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: chSysLockFromISR(); if (usbp->state == USB_ACTIVE) { /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_A, &ep1config); usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_A, &ep2config); usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_B, &ep3config); usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_B, &ep4config); /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(&SDU1); sduConfigureHookI(&SDU2); } else if (usbp->state == USB_SELECTED) { usbDisableEndpointsI(usbp); } chSysUnlockFromISR(); return; case USB_EVENT_UNCONFIGURED: return; case USB_EVENT_SUSPEND: chSysLockFromISR(); /* Disconnection event on suspend.*/ sduDisconnectI(&SDU1); sduDisconnectI(&SDU2); chSysUnlockFromISR(); return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
/* Handles the USB driver global events */ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { switch(event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: osalSysLockFromISR(); /* Enable the endpoints specified into the configuration. */ usbInitEndpointI(usbp, DEBUG_TX_ENDPOINT, &hid_debug_ep_config); hidDebugConfigureHookI(&HIDD); osalSysUnlockFromISR(); return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { uint8_t ep; switch (event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: chSysLockFromIsr(); for (ep = 1; ep < 10; ep++) { // Make sure the endpoint are initialized from 1 to 9 if (ep == CDC1_NOTIFICATION_EPADDR) usbInitEndpointI(usbp, CDC1_NOTIFICATION_EPADDR, &cdc1_ep_int_config); if (ep == CDC1_TX_EPADDR) usbInitEndpointI(usbp, CDC1_TX_EPADDR, &cdc1_ep_in_config); if (ep == CDC1_RX_EPADDR) usbInitEndpointI(usbp, CDC1_RX_EPADDR, &cdc1_ep_out_config); if (ep == CDC2_NOTIFICATION_EPADDR) usbInitEndpointI(usbp, CDC2_NOTIFICATION_EPADDR, &cdc2_ep_int_config); if (ep == CDC2_TX_EPADDR) usbInitEndpointI(usbp, CDC2_TX_EPADDR, &cdc2_ep_in_config); if (ep == CDC2_RX_EPADDR) usbInitEndpointI(usbp, CDC2_RX_EPADDR, &cdc2_ep_out_config); #if HAL_USE_MSD if (ep == MASS_STORAGE_IN_EPADDR) usbInitEndpointI(usbp, MASS_STORAGE_IN_EPADDR, &ms_ep_in_config); if (ep == MASS_STORAGE_OUT_EPADDR) usbInitEndpointI(usbp, MASS_STORAGE_OUT_EPADDR, &ms_ep_out_config); #endif } /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(usbp); #if HAL_USE_MSD msdConfigureHookI(usbp); #endif chSysUnlockFromIsr(); return; case USB_EVENT_SUSPEND: #if HAL_USE_MSD msdSuspendHookI(usbp); #endif return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
/* * Handles the USB driver global events. * These events are triggered by the USB driver. */ static void usb_event(USBDriver *usbp, usbevent_t event) { (void) usbp; switch (event) { case USB_EVENT_RESET: /* Signals when a USB reset event has occurred. * Typically this will happen at startup and when the cable * is connected or disconnected. * After a reset, the usb system will not be operational * until it is configured. */ chSysLockFromIsr(); chEvtBroadcastFlagsI(&esUsbReset, (flagsmask_t)0); chSysUnlockFromIsr(); return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: /* Enables the endpoints specified into the configuration. * Note, this callback is invoked from an ISR so I-Class functions * must be used. */ chSysLockFromIsr(); usbInitEndpointI(usbp, 1, &ep1config); usbInitEndpointI(usbp, 2, &ep2config); /* Signals that the configuration is complete, and the USB system * is ready to be used. */ chEvtBroadcastFlagsI(&esUsbConfigured, (flagsmask_t)0); chSysUnlockFromIsr(); return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { extern SerialUSBDriver SDU2; switch (event) { case USB_EVENT_RESET: return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: chSysLockFromISR(); /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ usbInitEndpointI(usbp, USBD2_DATA_REQUEST_EP, &ep1config); usbInitEndpointI(usbp, USBD2_INTERRUPT_REQUEST_EP, &ep2config); /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(&SDU2); chSysUnlockFromISR(); return; case USB_EVENT_SUSPEND: if (usbp->state == USB_ACTIVE) { // USB cable unplugged chSysLockFromISR(); _usb_reset(usbp); // Reset queues and unlock waiting threads chIQResetI(&SDU2.iqueue); chOQResetI(&SDU2.oqueue); chSysUnlockFromISR(); } return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
/* * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { USBMassStorageDriver *msdp = (USBMassStorageDriver *)usbp->USBD_PARAM_NAME; switch (event) { case USB_EVENT_RESET: msdp->reconfigured_or_reset_event = TRUE; return; case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: chSysLockFromIsr(); msdp->reconfigured_or_reset_event = TRUE; usbInitEndpointI(usbp, msdp->ms_ep_number, &epDataConfig); /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ usbInitEndpointI(usbp, USB_CDC_DATA_REQUEST_EP, &epCDC1config); usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &epCDC2config); /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(usbp); /* Initialize the thread */ chBSemSignalI(&msdp->bsem); /* signal that the device is connected */ chEvtBroadcastI(&msdp->evt_connected); chSysUnlockFromIsr(); return; case USB_EVENT_SUSPEND: return; case USB_EVENT_WAKEUP: return; case USB_EVENT_STALLED: return; } return; }
/* Handles the USB driver global events * TODO: maybe disable some things when connection is lost? */ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { switch(event) { case USB_EVENT_ADDRESS: return; case USB_EVENT_CONFIGURED: osalSysLockFromISR(); /* Enable the endpoints specified into the configuration. */ usbInitEndpointI(usbp, KEYBOARD_IN_EPNUM, &kbd_ep_config); #ifdef MOUSE_ENABLE usbInitEndpointI(usbp, MOUSE_IN_EPNUM, &mouse_ep_config); #endif /* MOUSE_ENABLE */ #ifdef EXTRAKEY_ENABLE usbInitEndpointI(usbp, EXTRAKEY_IN_EPNUM, &extra_ep_config); #endif /* EXTRAKEY_ENABLE */ #ifdef NKRO_ENABLE usbInitEndpointI(usbp, NKRO_IN_EPNUM, &nkro_ep_config); #endif /* NKRO_ENABLE */ for (int i=0;i<NUM_USB_DRIVERS;i++) { usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].in_ep_config); usbInitEndpointI(usbp, drivers.array[i].config.bulk_out, &drivers.array[i].out_ep_config); if (drivers.array[i].config.int_in) { usbInitEndpointI(usbp, drivers.array[i].config.int_in, &drivers.array[i].int_ep_config); } qmkusbConfigureHookI(&drivers.array[i].driver); } osalSysUnlockFromISR(); return; case USB_EVENT_SUSPEND: #ifdef SLEEP_LED_ENABLE sleep_led_enable(); #endif /* SLEEP_LED_ENABLE */ /* Falls into.*/ case USB_EVENT_UNCONFIGURED: /* Falls into.*/ case USB_EVENT_RESET: for (int i=0;i<NUM_USB_DRIVERS;i++) { chSysLockFromISR(); /* Disconnection event on suspend.*/ qmkusbSuspendHookI(&drivers.array[i].driver); chSysUnlockFromISR(); } return; case USB_EVENT_WAKEUP: //TODO: from ISR! print("[W]"); for (int i=0;i<NUM_USB_DRIVERS;i++) { chSysLockFromISR(); /* Disconnection event on suspend.*/ qmkusbWakeupHookI(&drivers.array[i].driver); chSysUnlockFromISR(); } suspend_wakeup_init(); #ifdef SLEEP_LED_ENABLE sleep_led_disable(); // NOTE: converters may not accept this led_set(host_keyboard_leds()); #endif /* SLEEP_LED_ENABLE */ return; case USB_EVENT_STALLED: return; } }