Beispiel #1
0
/*
 * 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;
}
Beispiel #2
0
/*
 * 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:
    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, USB_CDC_DATA_REQUEST_EP, &ep1config);
    usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &ep2config);

    /* Resetting the state of the CDC subsystem.*/
    sduConfigureHookI(usbp);

    chSysUnlockFromIsr();
    return;
  case USB_EVENT_SUSPEND:
    return;
  case USB_EVENT_WAKEUP:
    return;
  case USB_EVENT_STALLED:
    return;
  }
  return;
}
Beispiel #3
0
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
}
Beispiel #4
0
/*
 * 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;
}
Beispiel #5
0
/*
 * 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;
}
Beispiel #6
0
/*
 * Handles the USB driver global events.
 */
static void usb_event(USBDriver *usbp, usbevent_t event) {
  extern SerialUSBDriver SDU1;

  switch (event) {
  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, USBD_DATA_REQUEST_EP, &ep1config);
    usbInitEndpointI(usbp, USBD_DATA_AVAILABLE_EP, &ep2config);
    usbInitEndpointI(usbp, USBD_INTERRUPT_REQUEST_EP, &ep3config);

    /* Resetting the state of the CDC subsystem.*/
    sduConfigureHookI(&SDU1);

    chSysUnlockFromISR();
    return;
  case USB_EVENT_RESET:
    /* Falls into.*/
  case USB_EVENT_UNCONFIGURED:
    /* Falls into.*/
  case USB_EVENT_SUSPEND:
    chSysLockFromISR();

    /* Disconnection event on suspend.*/
    sduSuspendHookI(&SDU1);

    chSysUnlockFromISR();
    return;
  case USB_EVENT_WAKEUP:
    chSysLockFromISR();

    /* Disconnection event on suspend.*/
    sduWakeupHookI(&SDU1);

    chSysUnlockFromISR();
    return;
  case USB_EVENT_STALLED:
    return;
  }
  return;
}
Beispiel #7
0
/*
 * 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;
}
Beispiel #8
0
/*
 * 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;
}