當前位置: 首頁>>代碼示例>>C++>>正文


C++ Endpoint_Write_8函數代碼示例

本文整理匯總了C++中Endpoint_Write_8函數的典型用法代碼示例。如果您正苦於以下問題:C++ Endpoint_Write_8函數的具體用法?C++ Endpoint_Write_8怎麽用?C++ Endpoint_Write_8使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Endpoint_Write_8函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: V2Protocol_GetSetParam

/** Handler for the CMD_SET_PARAMETER and CMD_GET_PARAMETER commands from the host, setting or
 *  getting a device parameter's value from the parameter table.
 *
 *  \param[in] V2Command  Issued V2 Protocol command byte from the host
 */
static void V2Protocol_GetSetParam(const uint8_t V2Command)
{
	uint8_t ParamID = Endpoint_Read_8();
	uint8_t ParamValue;

	if (V2Command == CMD_SET_PARAMETER)
	  ParamValue = Endpoint_Read_8();

	Endpoint_ClearOUT();
	Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
	Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

	Endpoint_Write_8(V2Command);

	uint8_t ParamPrivs = V2Params_GetParameterPrivileges(ParamID);

	if ((V2Command == CMD_SET_PARAMETER) && (ParamPrivs & PARAM_PRIV_WRITE))
	{
		Endpoint_Write_8(STATUS_CMD_OK);
		V2Params_SetParameterValue(ParamID, ParamValue);
	}
	else if ((V2Command == CMD_GET_PARAMETER) && (ParamPrivs & PARAM_PRIV_READ))
	{
		Endpoint_Write_8(STATUS_CMD_OK);
		Endpoint_Write_8(V2Params_GetParameterValue(ParamID));
	}
	else
	{
		Endpoint_Write_8(STATUS_CMD_FAILED);
	}

	Endpoint_ClearIN();
}
開發者ID:Codingboy,項目名稱:ucuni,代碼行數:38,代碼來源:V2Protocol.c

示例2: usbGetButtons

void usbGetButtons()
{
	Endpoint_ClearSETUP();//ack setup packet
	u8 sendData = 0;
	while (sendData < 3)
	{
		while (!Endpoint_IsINReady())
		{
			//wait until host is ready
		}
		u8 state = stateButton(but1);;
		Endpoint_Write_8(state);
		sendData++;
		state = stateButton(but2);;
		Endpoint_Write_8(state);
		sendData++;
		state = stateButton(but3);;
		Endpoint_Write_8(state);
		sendData++;
		Endpoint_ClearIN();
	}
	//while (!Endpoint_IsOUTReceived())
	{
		//wait for host to send status
	}
	//Endpoint_ClearOUT();//send message
	//Endpoint_ClearStatusStage();//success :D
}
開發者ID:Codingboy,項目名稱:ucuni,代碼行數:28,代碼來源:usb.c

示例3: ISPProtocol_LeaveISPMode

/** Handler for the CMD_LEAVE_ISP command, which releases the target from programming mode. */
void ISPProtocol_LeaveISPMode(void)
{
    struct
    {
        uint8_t PreDelayMS;
        uint8_t PostDelayMS;
    } Leave_ISP_Params;

    Endpoint_Read_Stream_LE(&Leave_ISP_Params, sizeof(Leave_ISP_Params), NULL);

    Endpoint_ClearOUT();
    Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPADDR);
    Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

    /* Perform pre-exit delay, release the target /RESET, disable the SPI bus and perform the post-exit delay */
    ISPProtocol_DelayMS(Leave_ISP_Params.PreDelayMS);
    ISPTarget_ChangeTargetResetLine(false);
    ISPTarget_DisableTargetISP();
    ISPProtocol_DelayMS(Leave_ISP_Params.PostDelayMS);

    Endpoint_Write_8(CMD_LEAVE_PROGMODE_ISP);
    Endpoint_Write_8(STATUS_CMD_OK);
    Endpoint_ClearIN();

    ISPActive = false;
}
開發者ID:pbrook,項目名稱:minimizer,代碼行數:27,代碼來源:ISPProtocol.c

示例4: V2Protocol_ResetProtection

/** Handler for the CMD_RESET_PROTECTION command, implemented as a dummy ACK function as
 *  no target short-circuit protection is currently implemented.
 */
static void V2Protocol_ResetProtection(void)
{
	Endpoint_ClearOUT();
	Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
	Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

	Endpoint_Write_8(CMD_RESET_PROTECTION);
	Endpoint_Write_8(STATUS_CMD_OK);
	Endpoint_ClearIN();
}
開發者ID:Codingboy,項目名稱:ucuni,代碼行數:13,代碼來源:V2Protocol.c

示例5: XPROGProtocol_ReadCRC

/** Handler for the XPROG CRC command to read a specific memory space's CRC value for comparison between the
 *  attached device's memory and a data set on the host.
 */
static void XPROGProtocol_ReadCRC(void)
{
	uint8_t ReturnStatus = XPROG_ERR_OK;

	struct
	{
		uint8_t CRCType;
	} ReadCRC_XPROG_Params;

	Endpoint_Read_Stream_LE(&ReadCRC_XPROG_Params, sizeof(ReadCRC_XPROG_Params), NULL);

	Endpoint_ClearOUT();
	Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPADDR);
	Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

	uint32_t MemoryCRC;

	if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
	{
		uint8_t CRCCommand;

		/* Determine which NVM command to send to the device depending on the memory to CRC */
		switch (ReadCRC_XPROG_Params.CRCType)
		{
			case XPROG_CRC_APP:
				CRCCommand = XMEGA_NVM_CMD_APPCRC;
				break;
			case XPROG_CRC_BOOT:
				CRCCommand = XMEGA_NVM_CMD_BOOTCRC;
				break;
			default:
				CRCCommand = XMEGA_NVM_CMD_FLASHCRC;
				break;
		}

		/* Perform and retrieve the memory CRC, indicate timeout if occurred */
		if (!(XMEGANVM_GetMemoryCRC(CRCCommand, &MemoryCRC)))
		  ReturnStatus = XPROG_ERR_TIMEOUT;
	}
	else
	{
		/* TPI does not support memory CRC */
		ReturnStatus = XPROG_ERR_FAILED;
	}

	Endpoint_Write_8(CMD_XPROG);
	Endpoint_Write_8(XPROG_CMD_CRC);
	Endpoint_Write_8(ReturnStatus);

	if (ReturnStatus == XPROG_ERR_OK)
	{
		Endpoint_Write_8(MemoryCRC >> 16);
		Endpoint_Write_16_LE(MemoryCRC & 0xFFFF);
	}
開發者ID:Steffen-Engel,項目名稱:lufa,代碼行數:57,代碼來源:XPROGProtocol.c

示例6: V2Protocol_SignOn

/** Handler for the CMD_SIGN_ON command, returning the programmer ID string to the host. */
static void V2Protocol_SignOn(void)
{
	Endpoint_ClearOUT();
	Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
	Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

	Endpoint_Write_8(CMD_SIGN_ON);
	Endpoint_Write_8(STATUS_CMD_OK);
	Endpoint_Write_8(sizeof(PROGRAMMER_ID) - 1);
	Endpoint_Write_Stream_LE(PROGRAMMER_ID, (sizeof(PROGRAMMER_ID) - 1), NULL);
	Endpoint_ClearIN();
}
開發者ID:Codingboy,項目名稱:ucuni,代碼行數:13,代碼來源:V2Protocol.c

示例7: SCSI_Command_ModeSense_6

/** Command processing for an issued SCSI MODE SENSE (6) command. This command returns various informational pages about
 *  the SCSI device, as well as the device's Write Protect status.
 *
 *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
 *
 *  \return Boolean true if the command completed successfully, false otherwise.
 */
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
	/* Send an empty header response with the Write Protect flag status */
	Endpoint_Write_8(0x00);
	Endpoint_Write_8(0x00);
	Endpoint_Write_8(DISK_READ_ONLY ? 0x80 : 0x00);
	Endpoint_Write_8(0x00);
	Endpoint_ClearIN();

	/* Update the bytes transferred counter and succeed the command */
	MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 4;

	return true;
}
開發者ID:DynamicPerception,項目名稱:ArduinoAT90USB,代碼行數:21,代碼來源:SCSI.c

示例8: SCSI_Command_ModeSense_6

/** Command processing for an issued SCSI MODE SENSE (6) command. This command returns various informational pages about
 *  the SCSI device, as well as the device's Write Protect status.
 *
 *  \return Boolean true if the command completed successfully, false otherwise.
 */
static bool SCSI_Command_ModeSense_6(void)
{
	/* Send an empty header response with the Write Protect flag status */
	Endpoint_Write_8(0x00);
	Endpoint_Write_8(0x00);
	Endpoint_Write_8(DISK_READ_ONLY ? 0x80 : 0x00);
	Endpoint_Write_8(0x00);
	Endpoint_ClearIN();

	/* Update the bytes transferred counter and succeed the command */
	CommandBlock.DataTransferLength -= 4;

	return true;
}
開發者ID:Armadill0,項目名稱:CANBus-Triple_Genesis-Connect,代碼行數:19,代碼來源:SCSI.c

示例9: V2Protocol_LoadAddress

/** Handler for the CMD_LOAD_ADDRESS command, loading the given device address into a
 *  global storage variable for later use, and issuing LOAD EXTENDED ADDRESS commands
 *  to the attached device as required.
 */
static void V2Protocol_LoadAddress(void)
{
	Endpoint_Read_Stream_BE(&CurrentAddress, sizeof(CurrentAddress), NULL);

	Endpoint_ClearOUT();
	Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
	Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

	if (CurrentAddress & (1UL << 31))
	  MustLoadExtendedAddress = true;

	Endpoint_Write_8(CMD_LOAD_ADDRESS);
	Endpoint_Write_8(STATUS_CMD_OK);
	Endpoint_ClearIN();
}
開發者ID:Codingboy,項目名稱:ucuni,代碼行數:19,代碼來源:V2Protocol.c

示例10: EVENT_USB_Device_ControlRequest

/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
 *  the device from the USB host before passing along unhandled control requests to the library for processing
 *  internally.
 */
void EVENT_USB_Device_ControlRequest(void)
{
    /* Process UFI specific control requests */
    switch (USB_ControlRequest.bRequest)
    {
    case MS_REQ_MassStorageReset:
        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
        {
            Endpoint_ClearSETUP();
            Endpoint_ClearStatusStage();

            /* Indicate that the current transfer should be aborted */
            IsMassStoreReset = true;
        }

        break;
    case MS_REQ_GetMaxLUN:
        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
        {
            Endpoint_ClearSETUP();

            /* Indicate to the host the number of supported LUNs (virtual disks) on the device */
            Endpoint_Write_8(TOTAL_LUNS - 1);

            Endpoint_ClearIN();
            Endpoint_ClearStatusStage();
        }

        break;
    }
}
開發者ID:ASHOK1991,項目名稱:lb-Arduino-Code,代碼行數:35,代碼來源:MassStorage.c

示例11: CDC_Device_SendByte

uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
                            const uint8_t Data)
{
	uint8_t status = 0;
	if ((USB_DeviceState == DEVICE_STATE_Configured) &&	(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS != 0))
	{

		Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address);

		if (Endpoint_IsReadWriteAllowed())
		{
			Endpoint_Write_8(Data);
			status = ENDPOINT_READYWAIT_NoError;
		}
		else
		{
			Endpoint_ClearIN();
			status = Endpoint_WaitUntilReady();
		}
	}
	else
	{
		status = ENDPOINT_RWSTREAM_DeviceDisconnected;
	}

	return status;

}
開發者ID:ManagementCenterInnsbruck,項目名稱:InfineonMulticopter_LARIX,代碼行數:28,代碼來源:cdc_class_device.c

示例12: usbGetTemperature

void usbGetTemperature()
{
	Endpoint_ClearSETUP();//ack setup packet
	u8 sendData = 0;
	measureTemperature();
	while (sendData < 2)
	{
		while (!Endpoint_IsINReady())
		{
			//wait until host is ready
		}
		u16 value = measureTemperature();
		Endpoint_Write_8(value>>8);
		sendData++;
		Endpoint_Write_8(value & 0xff);
		sendData++;
		Endpoint_ClearIN();
	}
	//while (!Endpoint_IsOUTReceived())
	{
		//wait for host to send status
	}
	//Endpoint_ClearOUT();//send message
	//Endpoint_ClearStatusStage();//success :D

}
開發者ID:Codingboy,項目名稱:ucuni,代碼行數:26,代碼來源:usb.c

示例13: open

size_t USBSerial::write(uint8_t c)
{
        /* only try to send bytes if the high-level CDC connection itself 
         is open (not just the pipe) - the OS should set lineState when the port
         is opened and clear lineState when the port is closed.
         bytes sent before the user opens the connection or after
         the connection is closed are lost - just like with a UART. */
        
        // TODO - ZE - check behavior on different OSes and test what happens if an
        // open connection isn't broken cleanly (cable is yanked out, host dies
        // or locks up, or host virtual serial port hangs)
        if (LineState > 0) {
                Endpoint_SelectEndpoint(CDC_TX_EPADDR);
                
                if (!Endpoint_IsReadWriteAllowed()) {
                        Endpoint_ClearIN();
                        while (!Endpoint_IsINReady() && USB_DeviceState == DEVICE_STATE_Configured) {
                                USB_USBTask();
                        }
                }
                
                set_blink_LED();
                Endpoint_Write_8(c);
                
                return 1;
        } else {
                setWriteError();
                return 0;
        }
}
開發者ID:Industruino,項目名稱:boarddefinitions,代碼行數:30,代碼來源:usb_api.cpp

示例14: MS_Device_ProcessControlRequest

void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
	if (!(Endpoint_IsSETUPReceived()))
	  return;

	if (USB_ControlRequest.wIndex != MSInterfaceInfo->Config.InterfaceNumber)
	  return;

	switch (USB_ControlRequest.bRequest)
	{
		case MS_REQ_MassStorageReset:
			if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
			{
				Endpoint_ClearSETUP();
				Endpoint_ClearStatusStage();

				MSInterfaceInfo->State.IsMassStoreReset = true;
			}

			break;
		case MS_REQ_GetMaxLUN:
			if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
			{
				Endpoint_ClearSETUP();
				while (!(Endpoint_IsINReady()));
				Endpoint_Write_8(MSInterfaceInfo->Config.TotalLUNs - 1);
				Endpoint_ClearIN();
				Endpoint_ClearStatusStage();
			}

			break;
	}
}
開發者ID:40000ft,項目名稱:lufa,代碼行數:33,代碼來源:MassStorageClassDevice.c

示例15: cdc_send_USB_data

void cdc_send_USB_data( USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo ){
    
	// process outgoing USB data
	Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); // select IN endpoint to restore its registers
	if ( UEINTX & (1<<TXINI) ){ // if we can write on the outgoing data bank
		uint8_t BufferCount = RingBuffer_GetCount(&ToUSB_Buffer);
		
		if (BufferCount) {
			uint8_t bank_size = CDCInterfaceInfo->Config.DataINEndpoint.Size;
	
			// if there are more bytes in the buffer than what can be put in the data bank OR there are a few bytes and they have been waiting for too long
			if ( BufferCount >= bank_size || (TIFR0 & (1 << TOV0)) ){
				// Clear flush timer expiry flag
			    TIFR0 |= (1 << TOV0);
				
				// load the IN data bank until full or until we loaded all the bytes we know we have
				uint8_t nb_to_write = min(BufferCount, bank_size );					
				while (nb_to_write--){
                	uint8_t Data = RingBuffer_Remove(&ToUSB_Buffer);
					Endpoint_Write_8(Data);
				}
				
				// if the bank is full (== we can't write to it anymore), we might need an empty packet after this one
				needEmptyPacket = ! Endpoint_IsReadWriteAllowed();
				
				Endpoint_ClearIN(); // allow the hardware to send the content of the bank
			}
		} else if (needEmptyPacket) {
			// send an empty packet to end the transfer
			needEmptyPacket = false;
			Endpoint_ClearIN(); // allow the hardware to send the content of the bank
		}
		
	}
}
開發者ID:A-toft,項目名稱:usb2ax,代碼行數:35,代碼來源:USB2AX_Serial.c


注:本文中的Endpoint_Write_8函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。