#include "usb.h"
#include "usbcfg.h"
#include "usbhw.h"
#include "usbcore.h"
#include "usbuser.h"

extern BYTE b_Mode,Data;
int InEP_empty = TRUE;
int OutEP_loaded = FALSE;

#if USB_POWER_EVENT
void USB_Power_Event (BOOL  power) {
}
#endif

#if USB_RESET_EVENT
void USB_Reset_Event (void) {
  USB_ResetCore();
}
#endif

#if USB_SUSPEND_EVENT
void USB_Suspend_Event (void) {
}
#endif

#if USB_RESUME_EVENT
void USB_Resume_Event (void) {
}
#endif

#if USB_WAKEUP_EVENT
void USB_WakeUp_Event (void) {
}
#endif

#if USB_SOF_EVENT
void USB_SOF_Event (void) {
}
#endif

#if USB_ERROR_EVENT
void USB_Error_Event (DWORD error) {
}
#endif

#if USB_CONFIGURE_EVENT
void USB_Configure_Event (void) {
  if (USB_Configuration) {                  /* Check if USB is configured */
    GetInReport();
//    USB_WriteEP(0x81, &b_UsbIn, sizeof(b_UsbIn));
//USB_WriteEP(0x81, &InReport[0], sizeof(InReport));
  }
}
#endif

#if USB_INTERFACE_EVENT
void USB_Interface_Event (void) {
}
#endif

#if USB_FEATURE_EVENT
void USB_Feature_Event (void) {
}
#endif


#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : 0)

/* USB Endpoint Events Callback Pointers */
void (* const USB_P_EP[16]) (DWORD event) = {P_EP(0), P_EP(1), P_EP(2), P_EP(3), P_EP(4), P_EP(5),
  P_EP(6), P_EP(7), P_EP(8), P_EP(9), P_EP(10), P_EP(11), P_EP(12), P_EP(13), P_EP(14), P_EP(15),};

void USB_EndPoint1 (DWORD event) {
//	GetInReport();
//	USB_WriteEP(0x81, &InReport[0], sizeof(InReport));
	switch (event) {
    case USB_EVT_IN:
      GetInReport(); //Ausgang zum PC
//      USB_WriteEP(0x81, &InReport[0], sizeof(InReport));
      break;

    case USB_EVT_OUT:
      USB_ReadEP(0x01, &OutReport[0]);
      SetOutReport();
      break;

  }
}

void USB_EndPoint2 (DWORD event) {
	switch (event) {
    case USB_EVT_IN:
      GetInReport(); //Ausgang zum PC
//      USB_WriteEP(0x81, &InReport[0], sizeof(InReport));
      break;

    case USB_EVT_OUT:
      USB_ReadEP(0x01, &OutReport[0]);
      SetOutReport();
      break;

  }
}
void USB_EndPoint3 (DWORD event) {}
void USB_EndPoint4 (DWORD event) {}
void USB_EndPoint5 (DWORD event) {}
void USB_EndPoint6 (DWORD event) {}
void USB_EndPoint7 (DWORD event) {}
void USB_EndPoint8 (DWORD event) {}
void USB_EndPoint9 (DWORD event) {}
void USB_EndPoint10 (DWORD event) {}
void USB_EndPoint11 (DWORD event) {}
void USB_EndPoint12 (DWORD event) {}
void USB_EndPoint13 (DWORD event) {}
void USB_EndPoint14 (DWORD event) {}
void USB_EndPoint15 (DWORD event) {}
