Esempio n. 1
0
static uint8_t  usbd_video_SOF (void *pdev)
{     

  if (play_status == 1)
  {
	  DCD_EP_Flush(pdev,USB_ENDPOINT_IN(1));
	  DCD_EP_Tx (pdev,USB_ENDPOINT_IN(1), (uint8_t*)0x0002, 2);//header
	  play_status = 2;
  }
  return USBD_OK;
}
Esempio n. 2
0
void USBDeviceClass::initEP(uint32_t ep, uint32_t config)
{
	if (config == (USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_IN(0)))
	{
		usbd.epBank1SetSize(ep, 64);
		usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[ep]);
		usbd.epBank1SetType(ep, 4); // INTERRUPT IN
	}
	else if (config == (USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_OUT(0)))
	{
		usbd.epBank0SetSize(ep, 64);
		usbd.epBank0SetAddress(ep, &udd_ep_out_cache_buffer[ep]);
		usbd.epBank0SetType(ep, 3); // BULK OUT

		// Release OUT EP
		usbd.epBank0SetMultiPacketSize(ep, 64);
		usbd.epBank0SetByteCount(ep, 0);
	}
	else if (config == (USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_IN(0)))
	{
		usbd.epBank1SetSize(ep, 64);
		usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[ep]);

		// NAK on endpoint IN, the bank is not yet filled in.
		usbd.epBank1ResetReady(ep);

		usbd.epBank1SetType(ep, 3); // BULK IN
	}
	else if (config == USB_ENDPOINT_TYPE_CONTROL)
	{
		// XXX: Needed?
// 		usbd.epBank0DisableAutoZLP(ep);
// 		usbd.epBank1DisableAutoZLP(ep);

		// Setup Control OUT
		usbd.epBank0SetSize(ep, 64);
		usbd.epBank0SetAddress(ep, &udd_ep_out_cache_buffer[ep]);
		usbd.epBank0SetType(ep, 1); // CONTROL OUT / SETUP

		// Setup Control IN
		usbd.epBank1SetSize(ep, 64);
		usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[0]);
		usbd.epBank1SetType(ep, 1); // CONTROL IN

		// Release OUT EP
		usbd.epBank0SetMultiPacketSize(ep, 64);
		usbd.epBank0SetByteCount(ep, 0);

		// NAK on endpoint OUT, the bank is full.
		usbd.epBank0SetReady(ep);
	}
}
Esempio n. 3
0
static uint8_t  usbd_video_DeInit (void  *pdev, 
                                   uint8_t cfgidx)
{ 
  DCD_EP_Close (pdev , USB_ENDPOINT_IN(1));
  
  /* DeInitialize the Audio output Hardware layer */

  return USBD_OK;
}
Esempio n. 4
0
int SingleAbsoluteMouse_::getInterface(uint8_t* interfaceCount)
{
	*interfaceCount += 1; // uses 1
	HIDDescriptor hidInterface = {
		D_INTERFACE(pluggedInterface, 1, USB_DEVICE_CLASS_HUMAN_INTERFACE, HID_SUBCLASS_NONE, HID_PROTOCOL_NONE),
		D_HIDREPORT(sizeof(_hidSingleReportDescriptorAbsoluteMouse)),
		D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01)
	};
	return USB_SendControl(0, &hidInterface, sizeof(hidInterface));
}
Esempio n. 5
0
/*
 *  USB Endpoint 1 Event Callback
 *   Called automatically on USB Endpoint 1 Event
 *    Parameter:       event
 */
void USB_EndPoint1(uint32_t event) {
	switch (event) {
	case USB_EVT_OUT:
		USB_ReadEP(USB_ENDPOINT_OUT(1), OUT1Packet);
		lasershark_process_command();
		USB_WriteEP(USB_ENDPOINT_IN(1), IN1Packet, 64);
		break;
	case USB_EVT_IN:
		break;
	}
}
Esempio n. 6
0
/*
 *  USB Endpoint 2 Event Callback
 *   Called automatically on USB Endpoint 2 Event
 *    Parameter:       event
 */
void USB_EndPoint2(uint32_t event) {
	switch (event) {
	case USB_EVT_OUT:
		USB_ReadEP(USB_ENDPOINT_OUT(2), OUT2Packet);
		lasershark_process_uart_bridge_command();
		USB_WriteEP(USB_ENDPOINT_IN(2), IN2Packet, 64);
		break;
	case USB_EVT_IN:
		break;
	}
}
Esempio n. 7
0
ErrorCode_t UsbdCdc_Bulk_IN_Hdlr(USBD_HANDLE_T hUsb, void* data, uint32_t event)
{
	uint8_t EpAdd = USB_ENDPOINT_IN(CALLBACK_UsbdCdc_Register_DataInEndpointNumber());
	
	if (event == USB_EVT_IN)
	{
		USBD_API->hw->WriteEP(UsbHandle, EpAdd, UsbdCdc_EPIN_buffer,UsbdCdc_EPIN_buffer_count);
		/* Clear EP buffer */
		UsbdCdc_EPIN_buffer_count = 0;
	}
	return LPC_OK;
}
/*
 *  USB Endpoint 1 Event Callback
 *   Called automatically on USB Endpoint 1 Event
 *    Parameter:       event
 */
ErrorCode_t USB_EndPoint1(USBD_HANDLE_T hUsb, void* data, uint32_t event) {
	switch (event) {
	case USB_EVT_OUT:
		pUsbApi->hw->ReadEP(hUsb, USB_ENDPOINT_OUT(1), OUT1Packet);
		lasershark_process_command();
		pUsbApi->hw->WriteEP(hUsb, USB_ENDPOINT_IN(1), IN1Packet, 64);
		break;
	case USB_EVT_IN:
		break;
	}

	return LPC_OK;
}
Esempio n. 9
0
// ---------------------------------------------------------------------------
static ErrorCode_t USB_Reset_Event_Handler(USBD_HANDLE_T hUsb)
{
    int core = USB_CORE(hUsb);
    USB_CONTROLLER_STATE *State = USB_STATE(core);

    // Clear all flags
    USB_ClearEvent(0, USB_EVENT_ALL);

    State->FirstGetDescriptor = TRUE;
    //State->Address = 0;
    //State->DeviceState = USB_DEVICE_STATE_DEFAULT;
    //USB_StateCallback(State);
    USB_FLAGS(core) = 0;

    // Reset endpoints
    USBD_ResetEP(hUsb, USB_ENDPOINT_IN(INT_IN_EP));
    USBD_ResetEP(hUsb, USB_ENDPOINT_IN(BULK_IN_EP));
    USBD_ResetEP(hUsb, USB_ENDPOINT_OUT(BULK_OUT_EP));
    ep_out_count[core] = 0;
    ep_in_count[core] = 0;

    return RET_OK;
}
Esempio n. 10
0
static uint8_t  usbd_video_Init (void  *pdev, 
                                 uint8_t cfgidx)
{  

    /* Open EP IN */
  DCD_EP_Open(pdev,
		      USB_ENDPOINT_IN(1),
		      VIDEO_PACKET_SIZE,
                      USB_OTG_EP_ISOC);

  /* Initialize the Video Hardware layer */
   
  return USBD_OK;
}
Esempio n. 11
0
// ---------------------------------------------------------------------------
// Transmit buffer when handling data endpoint IN event (Tx -> Host IN)
static ErrorCode_t USB_EP_In_Handler(USBD_HANDLE_T hUsb, void* data, UINT32 event)
{
    // Exit if not an IN event
    if (event != USB_EVT_IN) return RET_UNHANDLED;

    int epNum = (int)data;
    int core = USB_CORE(hUsb);

    // Exit if buffer empty
    if (ep_in_count[core] == 0) return RET_UNHANDLED;

    // Send buffer
    USBD_WriteEP(hUsb, USB_ENDPOINT_IN(epNum), ep_in_data[core], ep_in_count[core]);
    ep_in_count[core] = 0;

    return RET_OK;
}
Esempio n. 12
0
Config USB_ConfigDescriptor =
{
	D_CONFIG(sizeof(Config),INTERFACE_COUNT),

#ifdef CDC_ENABLED
	//	CDC
	{
		D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),

		//	CDC communication interface
		D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
		D_CDCCS(CDC_HEADER,0x10,0x01),								// Header (1.10 bcd)
		D_CDCCS(CDC_CALL_MANAGEMENT,1,1),							// Device handles call management
		D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,2),				// SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
		D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE),	// Communication interface is master, data interface is slave 0
		D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40),

		//	CDC data interface
		D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
		D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
		D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
	},
#endif
	// HID
	{
		D_INTERFACE(HID_INTERFACE,1,3,0,0),
		D_HIDREPORT(30),
		D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x40)
	}
};
Esempio n. 13
0
	0x09, 0x01,				// usage
	0x81, 0x02,				// Input (array)

	0x95, 64,				// report count RX
	0x09, 0x02,				// usage
	0x91, 0x02,				// Output (array)
	0xC0					// end collection
#endif
};

extern const HIDDescriptor _hidInterface PROGMEM;
const HIDDescriptor _hidInterface =
{
	D_INTERFACE(HID_INTERFACE,1,3,0,0),
	D_HIDREPORT(sizeof(_hidReportDescriptor)),
	D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
};

//================================================================================
//================================================================================
//	Driver

u8 _hid_protocol = 1;
u8 _hid_idle = 1;

#define WEAK __attribute__ ((weak))

int WEAK HID_GetInterface(u8* interfaceNum)
{
	interfaceNum[0] += 1;	// uses 1
	return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
Esempio n. 14
0
static uint8_t  usbd_video_Setup (void  *pdev, 
                                  USB_SETUP_REQ *req)
{
  uint16_t len;
  uint8_t  *pbuf;
  
  switch (req->bmRequest & USB_REQ_TYPE_MASK)
  {
  case USB_REQ_TYPE_CLASS :    
    switch (req->bRequest)
    {
    case GET_CUR:
    case GET_DEF:
    case GET_MIN:
    case GET_MAX:
      VIDEO_Req_GetCurrent(pdev, req);
      break;

    case SET_CUR:
    	VIDEO_Req_SetCurrent(pdev, req);
      break;

    default:
      USBD_CtlError (pdev, req);
      return USBD_FAIL;
    }
    break;

    
    /* Standard Requests -------------------------------*/
  case USB_REQ_TYPE_STANDARD:
    switch (req->bRequest)
    {
    case USB_REQ_GET_DESCRIPTOR: 
      if( (req->wValue >> 8) == CS_DEVICE)
      {
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
        pbuf = usbd_video_Desc;   
#else
        pbuf = usbd_video_CfgDesc + 18;
#endif 
        len = MIN(USB_VIDEO_DESC_SIZ , req->wLength);
      }
      
      USBD_CtlSendData (pdev, pbuf, len);
      break;
      
    case USB_REQ_GET_INTERFACE :
      USBD_CtlSendData (pdev, (uint8_t *)&usbd_video_AltSet, 1);
      break;
      
    case USB_REQ_SET_INTERFACE :
      if ((uint8_t)(req->wValue) < VIDEO_TOTAL_IF_NUM)
      {
        usbd_video_AltSet = (uint8_t)(req->wValue);

        if (usbd_video_AltSet == 1) {
        	STM_EVAL_LEDOn(LED5);
        	play_status = 1;
        } else {
        	STM_EVAL_LEDOff(LED5);
        	DCD_EP_Flush (pdev,USB_ENDPOINT_IN(1));
        	play_status = 0;
        }
      }
      else
      {
        /* Call the error management function (command will be nacked */
        USBD_CtlError (pdev, req);
      }
      break;
    }
  }
  return USBD_OK;
}
Esempio n. 15
0
//handle request from HOST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//send data to PC
static uint8_t  usbd_video_DataIn (void *pdev, uint8_t epnum)
{
  static uint16_t packets_cnt = 0xffff;
  static uint8_t header[2] = {2,0};//length + data
  uint16_t i;
  static uint32_t picture_pos;

  static uint16_t packets_in_frame = 1;
  static uint16_t last_packet_size = 0;
  
  uint8_t packet[VIDEO_PACKET_SIZE];

  static uint8_t tx_enable_flag = 0;//разрешение передачи

  DCD_EP_Flush(pdev,USB_ENDPOINT_IN(1));//very important

  if (tx_enable_flag) packets_cnt++;
  
  if (tx_enable_flag == 0)//если передача закончилась//if previous transmission ended
  {
    if (jpeg_encode_done)//если кодирование закончилось//if frame endoding ended
    {
      tx_enable_flag = 1;
      switch_buffers();//переключить буферы для двойной буферизации//switch double buffering buffers
      new_frame_cap_enabled = 1;//начать новый захват кадра//start new frame capture
      
      //start of new UVC frame
      //начало нового кадра UVC
      packets_cnt = 0;
      header[1]^= 1;//toggle bit0 every new frame
      picture_pos = 0;
      
      packets_in_frame = (last_jpeg_frame_size/ ((uint16_t)VIDEO_PACKET_SIZE -2))+1;//-2 - без учета заголовка
      last_packet_size = (last_jpeg_frame_size - ((packets_in_frame-1) * ((uint16_t)VIDEO_PACKET_SIZE-2)) + 2);//+2 - учитывая заголовок
    }
  }

  packet[0] = header[0];
  packet[1] = header[1];

  //fill payload buffer
  for (i=2;i<VIDEO_PACKET_SIZE;i++)
  {
    packet[i] = read_pointer[picture_pos];
    picture_pos++;
  }
  
  if (play_status == 2)
  {
    if (packets_cnt< (packets_in_frame - 1))
    {
      DCD_EP_Tx (pdev,USB_ENDPOINT_IN(1), (uint8_t*)&packet, (uint32_t)VIDEO_PACKET_SIZE);
    }
    else if (tx_enable_flag == 1)//только если передача разрешена//only if transmisson enabled
    {
      //last packet in UVC frame
      //последний пакет в кадре UVC
      DCD_EP_Tx (pdev,USB_ENDPOINT_IN(1), (uint8_t*)&packet, (uint32_t)last_packet_size);
      tx_enable_flag = 0;//stop TX data
    }
    else
    {
      DCD_EP_Tx (pdev,USB_ENDPOINT_IN(1), (uint8_t*)&header, 2);//header only
      picture_pos = 0;
    }
  }
  else
  {
    packets_cnt = 0xffff;
    picture_pos = 0;
  }
  
  
  //STM_EVAL_LEDToggle(LED6);
  return USBD_OK;
}
Esempio n. 16
0
ErrorCode_t EP0_hdlr(USBD_HANDLE_T hUsb, void* data, uint32_t event) {
	USB_CORE_CTRL_T* pCtrl = (USB_CORE_CTRL_T*)hUsb;
	static USB_SETUP_PACKET packet;
	pUsbApi->hw->ReadSetupPkt( hUsb, USB_ENDPOINT_OUT(0), (uint32_t *)&packet );

	switch (event) {
		case USB_EVT_SETUP:
			if (packet.bmRequestType.B == 0x80 // Setup Device to Host
					&& packet.bRequest == 0x06 // Get descriptor
					&& packet.wValue.WB.H == 0x06 // Get Device Qualifier Descriptor
				) {
				pUsbApi->hw->WriteEP(pUsbHandle, USB_ENDPOINT_IN(0), UPER_DeviceQualifierDescriptor, USB_DEVICE_QUALI_SIZE);
				return LPC_OK;
			}

			if (packet.bmRequestType.B == 0x80 // Setup Device to Host
					&& packet.bRequest == 0x06 // Get descriptor
					&& packet.wValue.WB.H == 0x03 // Get String Descriptor
					&& packet.wValue.WB.L == 3 // Serial number string
				) {

				uint32_t descSize = UPER_USBSerialStringDescriptor[0];
				if (descSize > packet.wLength)
					descSize = packet.wLength;

				pUsbApi->hw->WriteEP(pUsbHandle, USB_ENDPOINT_IN(0), UPER_USBSerialStringDescriptor, descSize);
				return LPC_OK;
			}

			pCtrl->EP0Data.Count = packet.wLength;   // Number of bytes to transfer

			if ( (packet.bmRequestType.B == REQ_TYPE(REQUEST_HOST_TO_DEVICE,REQUEST_CLASS,REQUEST_TO_INTERFACE) )
				  && (packet.bRequest    == 0x20 ) // SetLineCoding
				  && (packet.wValue.W    == 0 )    // Zero
				  && (packet.wIndex.W == USB_CDC_SFP_CIF_NUM) // Interface number
				) {

				pCtrl->EP0Data.pData = pCtrl->EP0Buf;
				pCtrl->EP0Data.Count = 7;
				//pUsbApi->core->DataOutStage( hUsb );
				pUsbApi->core->StatusInStage(hUsb);
				return LPC_OK;
			}

			if ( (packet.bmRequestType.B == REQ_TYPE(REQUEST_DEVICE_TO_HOST,REQUEST_CLASS,REQUEST_TO_INTERFACE) )
				  && (packet.bRequest    == 0x21 ) // GetLineCoding
				  && (packet.wValue.W    == 0 )  // Zero
				  && (packet.wIndex.W == USB_CDC_SFP_CIF_NUM) // Interface number
				) {
				uint8_t lcs[] = { 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }; // Default 9600 8n1

				pCtrl->EP0Data.Count = 7;
				pCtrl->EP0Data.pData = (uint8_t*)&lcs;
				pUsbApi->core->DataInStage(hUsb);

				return LPC_OK;
			}

			if ( (packet.bmRequestType.B == REQ_TYPE(REQUEST_HOST_TO_DEVICE,REQUEST_CLASS,REQUEST_TO_INTERFACE) )
				  && (packet.bRequest == 0x22 ) // SetControlLineState
				  && (packet.wIndex.W == USB_CDC_SFP_CIF_NUM) // Both interfaces
				) {
				pUsbApi->core->StatusInStage(hUsb);
				return LPC_OK;
			}

			break;
		case USB_EVT_OUT:
			if (pCtrl->EP0Data.Count > 0) {
				pUsbApi->core->DataOutStage(hUsb);
			} else {
				pUsbApi->core->StatusInStage(hUsb);
			}

			return LPC_OK;
			break;

		case USB_EVT_IN:
			/*if (pCtrl->EP0Data.Count > 0) {
				pUsbApi->core->DataInStage( hUsb );
				return LPC_OK;
			} else {
				pUsbApi->core->StatusOutStage( hUsb );
				return LPC_OK;
			}*/

			break;

		default:
			break;
	}

	return ERR_USBD_UNHANDLED;
}
Esempio n. 17
0
extern const MIDIDescriptor _midiInterface PROGMEM;
const MIDIDescriptor _midiInterface =
{
	D_INTERFACE(MIDI_INTERFACE,MIDI_ENDPOINT_COUNT,CLASS_AUDIO,SUBCLASS_MIDISTREAMING,0),
	{7, TYPE_CS_INTERFACE, SUBTYPE_HEADER, 0x0100, 34},
	{6, TYPE_CS_INTERFACE, SUBTYPE_MIDI_IN_JACK, JACK_EMBEDDED, JACK1, 0x00},
	{9, TYPE_CS_INTERFACE, SUBTYPE_MIDI_OUT_JACK, JACK_EMBEDDED, JACK2, 1, JACK3, 1, 0x00},
    {6, TYPE_CS_INTERFACE, SUBTYPE_MIDI_IN_JACK, JACK_EXTERNAL, JACK3, 0x00},
    {9, TYPE_CS_INTERFACE, SUBTYPE_MIDI_OUT_JACK, JACK_EXTERNAL, JACK4, 1, JACK1, 1, 0x00},
    {
        D_ENDPOINT(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT), USB_ENDPOINT_TYPE_BULK, 0x0040, 0x00),
        { 5, 0x25, 0x01, 0x01, JACK1 }
    },
    { 
        D_ENDPOINT(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN), USB_ENDPOINT_TYPE_BULK, 0x0040, 0x00),
        { 5, 0x25, 0x01, 0x01, JACK2 }
    }
};


int WEAK MIDI_GetInterface(u8* interfaceNum)
{
	interfaceNum[0] += 1;	// uses 1
	return USB_SendControl(TRANSFER_PGM,&_midiInterface,sizeof(_midiInterface));
}

bool WEAK MIDI_Setup(Setup& setup)
{
    u8 r = setup.bRequest;
    u8 requestType = setup.bmRequestType;
Esempio n. 18
0
 USB_UVC_VSIF_NUM,                          // bInterfaceNumber         1 index of this interface
 0x00,                                      // bAlternateSetting        0 index of this setting
 0x00,                                      // bNumEndpoints            0 no EP used
 CC_VIDEO,                                  // bInterfaceClass         14 Video
 SC_VIDEOSTREAMING,                         // bInterfaceSubClass       2 Video Streaming
 PC_PROTOCOL_UNDEFINED,                     // bInterfaceProtocol       0 (protocol undefined)
 0x00,                                      // iInterface               0 no description available
 
 
 /* Class-specific VS Header Descriptor (Input) */
 UVC_VS_INTERFACE_INPUT_HEADER_DESC_SIZE(1,1),// bLength               14 13 + (1*1) (no specific controls used)
 CS_INTERFACE,                              // bDescriptorType         36 (INTERFACE)
 VS_INPUT_HEADER,                           // bDescriptorSubtype       1 (INPUT_HEADER)
 0x01,                                      // bNumFormats              1 one format descriptor follows
 WBVAL(VC_HEADER_SIZ),
 USB_ENDPOINT_IN(1),                        // bEndPointAddress      0x83 EP 3 IN
 0x00,                                      // bmInfo                   0 no dynamic format change supported
 0x02,                                      // bTerminalLink            2 supplies terminal ID 2 (Output terminal)
 0x00,                                      // bStillCaptureMethod      0 NO supports still image capture
 0x01,                                      // bTriggerSupport          0 HW trigger supported for still image capture
 0x00,                                      // bTriggerUsage            0 HW trigger initiate a still image capture
 0x01,                                      // bControlSize             1 one byte bmaControls field size
 0x00,                                      // bmaControls(0)           0 no VS specific controls
 
 
 /* Class-specific VS Format Descriptor  */
 VS_FORMAT_UNCOMPRESSED_DESC_SIZE,     /* bLength 27*/
 CS_INTERFACE,                         /* bDescriptorType : CS_INTERFACE */
 VS_FORMAT_MJPEG,                      /* bDescriptorSubType : VS_FORMAT_MJPEG subtype */
 0x01,                                 /* bFormatIndex : First (and only) format descriptor */
 0x01,                                 /* bNumFrameDescriptors : One frame descriptor for this format follows. */
Esempio n. 19
0
  0x01,                              /* bDataInterface: CDC data IF ID */
/*Abstract Control Management Functional Descriptor*/
  0x04,                              /* bFunctionLength */
  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
  CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */
  0x02,                              /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
/*Union Functional Descriptor*/
  0x05,                              /* bFunctionLength */
  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
  CDC_UNION,                         /* bDescriptorSubtype: Union func desc */
  USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */
  USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */
/*Endpoint 1 Descriptor*/            /* event notification (optional) */
  USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_IN(1),                /* bEndpointAddress */
  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
  WBVAL(0x0010),                     /* wMaxPacketSize */
  0x02,          /* 2ms */           /* bInterval */
/* Interface 1, Alternate Setting 0, Data class interface descriptor*/
  USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */
  0x00,                              /* bAlternateSetting: no alternate setting */
  0x02,                              /* bNumEndpoints: two endpoints used */
  CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */
  0x00,                              /* bInterfaceSubClass: no subclass available */
  0x00,                              /* bInterfaceProtocol: no protocol used */
  0x5E,                              /* iInterface: */
/* Endpoint, EP3 Bulk Out */
  USB_ENDPOINT_DESC_SIZE,            /* bLength */
Esempio n. 20
0
#ifdef HID_SYSTEM_ENABLE
	HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL),
#endif
#ifdef HID_GAMEPAD_ENABLE
	HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD),
#endif
#endif
};

extern const HIDDescriptor _hidInterface PROGMEM;
const HIDDescriptor _hidInterface =
{
	D_INTERFACE(HID_INTERFACE, 1, 3, 0, 0),
	D_HIDREPORT(sizeof(_hidReportDescriptor)),
	// edit by NicoHood
	D_ENDPOINT(USB_ENDPOINT_IN(HID_ENDPOINT_INT), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01)
};

#if defined(HID_KEYBOARD_LEDS_ENABLED)
volatile uint8_t hid_keyboard_leds = 0;
#endif

//================================================================================
//================================================================================
//	Driver

u8 _hid_protocol = 1;
u8 _hid_idle = 1;

int WEAK HID_GetInterface(u8* interfaceNum)
{
Esempio n. 21
0
static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };

#define WEAK __attribute__ ((weak))

extern const CDCDescriptor _cdcInterface PROGMEM;
const CDCDescriptor _cdcInterface =
{
	D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),

	//	CDC communication interface
	D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
	D_CDCCS(CDC_HEADER,0x10,0x01),								// Header (1.10 bcd)
	D_CDCCS(CDC_CALL_MANAGEMENT,1,1),							// Device handles call management (not)
	D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6),				// SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
	D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE),	// Communication interface is master, data interface is slave 0
	D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40),

	//	CDC data interface
	D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
	D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0),
	D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0)
};

int WEAK CDC_GetInterface(u8* interfaceNum)
{
	interfaceNum[0] += 2;	// uses 2
	return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface));
}

bool WEAK CDC_Setup(Setup& setup)
{
Esempio n. 22
0
/* Configuration Descriptor tree for a CDC.*/
static const uint8_t vcom_configuration_descriptor_data[] = {
  /* Configuration Descriptor.*/
  USB_DESC_CONFIGURATION(
    USB_DESC_CONFIGURATION_SIZE +
    (IAD_CDC_IF_DESC_SET_SIZE * 2),         /* wTotalLength.                */
    USB_NUM_INTERFACES,                     /* bNumInterfaces.              */
    0x01,                                   /* bConfigurationValue.         */
    0,                                      /* iConfiguration.              */
    0xC0,                                   /* bmAttributes (self powered). */
    50                                      /* bMaxPower (100mA).           */
  ),
  IAD_CDC_IF_DESC_SET(
    USB_CDC_CIF_NUM0,
    USB_CDC_DIF_NUM0,
    USB_ENDPOINT_IN(USB_INTERRUPT_REQUEST_EP_A),
    USB_ENDPOINT_OUT(USB_DATA_AVAILABLE_EP_A),
    USB_ENDPOINT_IN(USB_DATA_REQUEST_EP_A)
  ),
  IAD_CDC_IF_DESC_SET(
    USB_CDC_CIF_NUM1,
    USB_CDC_DIF_NUM1,
    USB_ENDPOINT_IN(USB_INTERRUPT_REQUEST_EP_B),
    USB_ENDPOINT_OUT(USB_DATA_AVAILABLE_EP_B),
    USB_ENDPOINT_IN(USB_DATA_REQUEST_EP_B)
  ),
};

/*
 * Configuration Descriptor wrapper.
 */
{
  //  FIRST INTERFACE
  //  CDC communication interface (endpoint 0)
  D_INTERFACE(CDC_ACM_INTERFACE,                            // 'n'
              1,                                            // number of endpoints
              CDC_COMMUNICATION_INTERFACE_CLASS,            // interface class
              CDC_ABSTRACT_CONTROL_MODEL,                   // interface sub-class
              0),                                           // protocol

  // these headers describe the supported interfaces
  D_CDCCS(CDC_HEADER,0x10,0x01),                            // CDCCS InterfaceDescriptor Header (1.10 bcd) - version 1.10?
//  D_CDCCS(CDC_CALL_MANAGEMENT,1,1),                         // Device handles call management (seems to be optional)
  D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6),              // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
  D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE),  // Communication interface is master, data interface is slave 0 (?)

  D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),            // IN endpoint for CDC_ENDPOINT_ACM
             USB_ENDPOINT_TYPE_INTERRUPT,                   // INTERRUPT type
             0x10,                                          // max packet size 16
             0x40),                                         // interval 64 frames i.e. 64 msec (see USB spec table 9-13)

  //  SECOND INTERFACE
  //  CDC data interface (endpoints 1, 2)
  D_INTERFACE(CDC_DATA_INTERFACE,                           // 'n'
              2,                                            // number of endpoints
              CDC_DATA_INTERFACE_CLASS,                     // interface class
              0,                                            // interface sub-class
              0),                                           // protocol

  D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),            // OUT endpoint, index 'CDC_ENDPOINT_OUT'
             USB_ENDPOINT_TYPE_BULK,                        // BULK data transfers
             0x40,                                          // max packet size 64
Esempio n. 24
0
	bool ret = PluggableUSB().setup(setup);
	if ( ret == false) {
		sendZlp(0);
	}
	return ret;
	#endif

	return false;
}

uint32_t EndPoints[] =
{
	USB_ENDPOINT_TYPE_CONTROL,

#ifdef CDC_ENABLED
	USB_ENDPOINT_TYPE_INTERRUPT | USB_ENDPOINT_IN(0),           // CDC_ENDPOINT_ACM
	USB_ENDPOINT_TYPE_BULK      | USB_ENDPOINT_OUT(0),               // CDC_ENDPOINT_OUT
	USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_IN(0),                // CDC_ENDPOINT_IN
#endif

#ifdef PLUGGABLE_USB_ENABLED
	//allocate 6 endpoints and remove const so they can be changed by the user
	0,
	0,
	0,
	0,
	0,
	0,
#endif
};
Esempio n. 25
0
/*USB_CONFIG_REMOTE_WAKEUP*/,
  USB_CONFIG_POWER_MA(100),          /* bMaxPower */
/* Interface 0, Alternate Setting 0, MSC Class */
  USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  0x00,                              /* bInterfaceNumber */
  0x00,                              /* bAlternateSetting */
  0x02,                              /* bNumEndpoints */
  USB_DEVICE_CLASS_STORAGE,          /* bInterfaceClass */
  MSC_SUBCLASS_SCSI,                 /* bInterfaceSubClass */
  MSC_PROTOCOL_BULK_ONLY,            /* bInterfaceProtocol */
  0x62,                              /* iInterface */
/* Bulk In Endpoint */
  USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_IN(2),                /* bEndpointAddress */
  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
  WBVAL(0x0040),                     /* wMaxPacketSize */
  0,                                 /* bInterval */
/* Bulk Out Endpoint */
  USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
  WBVAL(0x0040),                     /* wMaxPacketSize */
  0,                                 /* bInterval */
/* Terminator */
  0                                  /* bLength */
};

/* USB String Descriptor (optional) */
Esempio n. 26
0
        USB_INTERFACE_DESCRIPTOR_SIZE,      /* bLength */
        USB_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
        0,                        			/* bInterfaceNumber */
        0x00,                               /* bAlternateSetting */
        EP_NUM,                     		/* bNumEndpoints */
        USB_INTERFACE_CLASS_STORAGE, 		/* bInterfaceClass: Storage Interface Class */
        0x06,               				/* bInterfaceSubClass: SCSI Transparent */
        0x50,                    			/* bInterfaceProtocol:  */
        4,                                  /* iInterface: Index of string descriptor */

/********************************************************************************
 Endpoint 1, Mass Storage Bulk In
*********************************************************************************/
        USB_ENDPOINT_DESCRIPTOR_SIZE,       /* bLength */
        USB_ENDPOINT_DESCRIPTOR_TYPE,       /* bDescriptorType */
        USB_ENDPOINT_IN(MASS_STORAGE_READ_EP_NUM),  /* bEndpointAddress */
        USB_ENDPOINT_TYPE_BULK,        		/* bmAttributes */
        WBVAL(MASS_STORAGE_MAX_PACKET_SIZE),/* wMaxPacketSize */
        0x0,                                /* bInterval  */

/********************************************************************************
 Endpoint 2, Mass Storage Bulk Out
*********************************************************************************/
        USB_ENDPOINT_DESCRIPTOR_SIZE,       /* bLength */
        USB_ENDPOINT_DESCRIPTOR_TYPE,       /* bDescriptorType */
        USB_ENDPOINT_OUT(MASS_STORAGE_WRITE_EP_NUM),    /* bEndpointAddress */
        USB_ENDPOINT_TYPE_BULK,             /* bmAttributes */
        WBVAL(MASS_STORAGE_MAX_PACKET_SIZE), /* wMaxPacketSize */
        0x00,                               /* bInterval: Ignore bulk transfer  */

};