本文整理匯總了C++中Endpoint_SelectEndpoint函數的典型用法代碼示例。如果您正苦於以下問題:C++ Endpoint_SelectEndpoint函數的具體用法?C++ Endpoint_SelectEndpoint怎麽用?C++ Endpoint_SelectEndpoint使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Endpoint_SelectEndpoint函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: RNDIS_Task
void RNDIS_Task(void)
{
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPADDR);
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
HandleUSB();
}
示例2: CDC_Device_SendString
uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
const char* const String)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return ENDPOINT_RWSTREAM_DeviceDisconnected;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
return Endpoint_Write_Stream_LE(String, strlen(String), NULL);
}
示例3: main
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
*/
int main(void)
{
SetupHardware();
GlobalInterruptEnable();
uint8_t sending = 0;
for (;;) {
while (1) {
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
if (ReceivedByte < 0)
break;
if (!configured) continue;
if (!sending) {
PORTC.OUTSET = PIN1_bm;
sending = 1;
}
PORTD.OUTTGL = PIN5_bm;
while(!USART_IsTXDataRegisterEmpty(&USART));
USART_PutChar(&USART, ReceivedByte & 0xff);
}
if (sending) {
USART_ClearTXComplete(&USART);
while(!USART_IsTXComplete(&USART));
PORTC.OUTCLR = PIN1_bm;
sending = 0;
}
Endpoint_SelectEndpoint(VirtualSerial_CDC_Interface.Config.DataINEndpoint.Address);
/* Check if a packet is already enqueued to the host - if so, we shouldn't try to send more data
* until it completes as there is a chance nothing is listening and a lengthy timeout could occur */
if (configured && Endpoint_IsINReady()) {
uint8_t maxbytes = CDC_TXRX_EPSIZE;
while (USART_RXBufferData_Available(&USART_data) && maxbytes-->0) {
uint8_t b = USART_RXBuffer_GetByte(&USART_data);
CDC_Device_SendByte(&VirtualSerial_CDC_Interface, b);
PORTD.OUTTGL = PIN5_bm;
}
}
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
USB_USBTask();
if (loop++) continue;
if (!configured) continue;
PORTD.OUTTGL = PIN5_bm;
}
}
示例4: uart_isdata
uint8_t uart_isdata(void) {
if (usb_rxpacket_leftb) {
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
return usb_rxpacket_leftb;
}
usb_process();
usb_rxpacket_leftb = CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface);
return usb_rxpacket_leftb;
}
示例5: Endpoint_StallTransaction
void Endpoint_StallTransaction(void)
{
USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc)
{
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint ^ ENDPOINT_DIR_IN);
USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
}
}
示例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();
if ( use_libusb == true ) {
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM__LIBUSB);
} else {
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM__DEFAULT);
}
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();
}
示例7: PRNT_Device_SendData
uint8_t PRNT_Device_SendData(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo,
const void* const Buffer,
const uint16_t Length)
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return ENDPOINT_RWSTREAM_DeviceDisconnected;
Endpoint_SelectEndpoint(PRNTInterfaceInfo->Config.DataINEndpoint.Address);
return Endpoint_Write_Stream_LE(Buffer, Length, NULL);
}
示例8: ISR
ISR(USB_COM_vect, ISR_BLOCK)
{
uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();
USB_USBTask();
USB_INT_Clear(USB_INT_ENDPOINT_SETUP);
Endpoint_SelectEndpoint(PrevSelectedEndpoint);
}
示例9: MS_Device_USBTask
void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);
if (Endpoint_IsOUTReceived())
{
if (MS_Device_ReadInCommandBlock(MSInterfaceInfo))
{
if (MSInterfaceInfo->State.CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);
bool SCSICommandResult = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo);
MSInterfaceInfo->State.CommandStatus.Status = (SCSICommandResult) ? MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail;
MSInterfaceInfo->State.CommandStatus.Signature = CPU_TO_LE32(MS_CSW_SIGNATURE);
MSInterfaceInfo->State.CommandStatus.Tag = MSInterfaceInfo->State.CommandBlock.Tag;
MSInterfaceInfo->State.CommandStatus.DataTransferResidue = MSInterfaceInfo->State.CommandBlock.DataTransferLength;
if (!(SCSICommandResult) && (le32_to_cpu(MSInterfaceInfo->State.CommandStatus.DataTransferResidue)))
Endpoint_StallTransaction();
MS_Device_ReturnCommandStatus(MSInterfaceInfo);
}
}
if (MSInterfaceInfo->State.IsMassStoreReset)
{
Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);
Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);
Endpoint_ClearStall();
Endpoint_ResetDataToggle();
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);
Endpoint_ClearStall();
Endpoint_ResetDataToggle();
MSInterfaceInfo->State.IsMassStoreReset = false;
}
}
示例10: 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_Byte(CMD_RESET_PROTECTION);
Endpoint_Write_Byte(STATUS_CMD_OK);
Endpoint_ClearIN();
}
示例11: CDC_Device_SendData_P
uint8_t CDC_Device_SendData_P(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
const void* const Buffer,
const uint16_t Length)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return ENDPOINT_RWSTREAM_DeviceDisconnected;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address);
return Endpoint_Write_PStream_LE(Buffer, Length, NULL);
}
示例12: MS_Device_ReadInCommandBlock
static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
uint16_t BytesProcessed;
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.PortNumber, MSInterfaceInfo->Config.DataOUTEndpointNumber);
BytesProcessed = 0;
while (Endpoint_Read_Stream_LE(MSInterfaceInfo->Config.PortNumber,
&MSInterfaceInfo->State.CommandBlock,
(sizeof(MS_CommandBlockWrapper_t) - 16), &BytesProcessed) ==
ENDPOINT_RWSTREAM_IncompleteTransfer)
{
if (MSInterfaceInfo->State.IsMassStoreReset)
return false;
}
if ((MSInterfaceInfo->State.CommandBlock.Signature != CPU_TO_LE32(MS_CBW_SIGNATURE)) ||
(MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) ||
(MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) ||
(MSInterfaceInfo->State.CommandBlock.SCSICommandLength == 0) ||
(MSInterfaceInfo->State.CommandBlock.SCSICommandLength > 16))
{
Endpoint_StallTransaction(MSInterfaceInfo->Config.PortNumber);
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.PortNumber, MSInterfaceInfo->Config.DataINEndpointNumber);
Endpoint_StallTransaction(MSInterfaceInfo->Config.PortNumber);
return false;
}
BytesProcessed = 0;
while (Endpoint_Read_Stream_LE(MSInterfaceInfo->Config.PortNumber,
&MSInterfaceInfo->State.CommandBlock.SCSICommandData,
MSInterfaceInfo->State.CommandBlock.SCSICommandLength, &BytesProcessed) ==
ENDPOINT_RWSTREAM_IncompleteTransfer)
{
if (MSInterfaceInfo->State.IsMassStoreReset)
return false;
}
// Endpoint_ClearOUT();
return true;
}
示例13: CDC_Device_SendString
uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
const char* const Data,
const uint16_t Length)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return ENDPOINT_RWSTREAM_DeviceDisconnected;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
return Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
}
示例14: ReceiveNextReport
/** Reads the next OUT report from the host from the OUT endpoint, if one has been sent. */
void ReceiveNextReport(void)
{
static struct
{
struct
{
unsigned char type;
unsigned char length;
} header;
unsigned char buffer[EPSIZE];
} packet = { .header.type = BYTE_OUT_REPORT };
uint16_t length = 0;
/* Select the OUT Report Endpoint */
Endpoint_SelectEndpoint(OUT_EPNUM);
/* Check if OUT Endpoint contains a packet */
if (Endpoint_IsOUTReceived())
{
/* Check to see if the packet contains data */
if (Endpoint_IsReadWriteAllowed())
{
/* Read OUT Report Data */
uint8_t ErrorCode = Endpoint_Read_Stream_LE(packet.buffer, sizeof(packet.buffer), &length);
if(ErrorCode == ENDPOINT_RWSTREAM_NoError)
{
length = sizeof(packet.buffer);
}
}
/* Handshake the OUT Endpoint - clear endpoint and ready for next report */
Endpoint_ClearOUT();
if(length)
{
packet.header.length = length & 0xFF;
Serial_SendData(&packet, sizeof(packet.header) + packet.header.length);
}
}
}
/** Function to manage HID report generation and transmission to the host, when in report mode. */
void HID_Task(void)
{
/* Device must be connected and configured for the task to run */
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
/* Send the next keypress report to the host */
SendNextReport();
/* Process the LED report sent from the host */
ReceiveNextReport();
}
示例15: TEMPLATE_FUNC_NAME
uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer,
uint16_t Length)
{
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
bool LastPacketFull = false;
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
if (Length > USB_ControlRequest.wLength)
Length = USB_ControlRequest.wLength;
else if (!(Length))
Endpoint_ClearIN();
while (Length || LastPacketFull)
{
uint8_t USB_DeviceState_LCL = USB_DeviceState;
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
else if (Endpoint_IsSETUPReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
else if (Endpoint_IsOUTReceived())
break;
if (Endpoint_IsINReady())
{
uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();
while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize))
{
TEMPLATE_TRANSFER_BYTE(DataStream);
TEMPLATE_BUFFER_MOVE(DataStream, 1);
Length--;
BytesInEndpoint++;
}
LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize);
Endpoint_ClearIN();
}
}
while (!(Endpoint_IsOUTReceived()))
{
uint8_t USB_DeviceState_LCL = USB_DeviceState;
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
}
return ENDPOINT_RWCSTREAM_NoError;
}