本文整理汇总了C++中USBDeviceTasks函数的典型用法代码示例。如果您正苦于以下问题:C++ USBDeviceTasks函数的具体用法?C++ USBDeviceTasks怎么用?C++ USBDeviceTasks使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USBDeviceTasks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConsoleInit
void ConsoleInit(void)
{
#if defined(ENABLE_CONSOLE)
unsigned long i = 0;
// Don't attempt anything if not connected
if (!USB_BUS_SENSE) return;
USBInitializeSystem();
USBDeviceAttach();
// This will only work in an interrupt driven USB system - exits on button press, only exits after enumeration is usb is detected
while (USBDeviceState < CONFIGURED_STATE)
{
#ifndef USB_INTERRUPT
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
#endif
USBProcessIO();
Delay10us(1);
// Timed-out starting connection (perhaps a charger or disconnected?)
if (i++ >= 1000000ul)
{
// The USB connection has failed -- if we're not using the PLL when the radio is on, turn it off now
USBDeviceDetach();
return;
}
}
// Gives host time to assign CDC port
i = 0;
while (USBDeviceState >= CONFIGURED_STATE && i++ < 600000ul)
{
MRF_LED = 1;
#ifndef USB_INTERRUPT
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
#endif
USBProcessIO();
Delay10us(10);
if (usb_haschar())
{
break;
}
}
MRF_LED = 0;
#endif
return;
}
示例2: high_isr
void high_isr()
{
#if defined(USB_INTERRUPT)
USBDeviceTasks();
#endif
}
示例3: main
/******************************************************************************
* Function: void main(void)
*
* PreCondition: None
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Main program entry point.
*
* Note: None
*****************************************************************************/
int main(void)
{
InitializeSystem();
#if defined(USB_INTERRUPT)
USBDeviceAttach();
#endif
while(1)
{
#if defined(USB_POLLING)
// Check bus status and service USB interrupts.
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
// this function periodically. This function will take care
// of processing and responding to SETUP transactions
// (such as during the enumeration process when you first
// plug in). USB hosts require that USB devices should accept
// and process SETUP packets in a timely fashion. Therefore,
// when using polling, this function should be called
// regularly (such as once every 1.8ms or faster** [see
// inline code comments in usb_device.c for explanation when
// "or faster" applies]) In most cases, the USBDeviceTasks()
// function does not take very long to execute (ex: <100
// instruction cycles) before it returns.
#endif
// Application-specific tasks.
// Application related code may be added here, or in the ProcessIO() function.
ProcessIO();
}//end while
}//end main
示例4: ReadStringUART
BYTE ReadStringUART(BYTE *Dest, BYTE BufferLen)
{
BYTE c;
BYTE count = 0;
if(BufferLen == 0) return 0;
while(BufferLen--)
{
*Dest = '\0';
while(!usb_haschar())
{
#ifndef USB_INTERRUPT
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
#endif
USBProcessIO();
}
c = usb_getchar();
if(c == '\r' || c == '\n')
break;
count++;
*Dest++ = c;
}
return count;
}
示例5: main
int main(void) {
InitializeSystem();
initADCDMA();
#if defined(USB_INTERRUPT)
if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE))
{
USBDeviceAttach();
}
#endif
#if defined(USB_POLLING)
// Check bus status and service USB interrupts.
USBDeviceTasks();
#endif
while(1)
{
if (!ADC_DATA_READY)
continue;
ADC_DATA_READY = 0;
RunFFT();
putrsUSBUSART((char*)&fftOut[0].real);
ProcessIO();
}
return (EXIT_SUCCESS);
}
示例6: ISRCode
void interrupt ISRCode()
{
//if(RCIF)
if(IOCBF)
ResultRx();
//if(TMR0IF)
// WorkTick();
//if(RCIF)
// ResultRx();
//if(TMR1GIF)
// UpdateFanSpeed();
/*if(BCL1IF) {
BCL1IF = 0; I2CState.Next = 0;
}
if(SSP1IF) {
SSP1IF = 0;
if(I2CState.Slave)
I2CSlave();
else if(I2CState.Next < I2C_WRITE) // split because not enough contigous code space
I2CRead();
else
I2CWrite();
}*/
#if defined(USB_INTERRUPT)
USBDeviceTasks();
#endif
}
示例7: main
int main(void){
unsigned long timer;
#define longDelay(x) timer=x; while(timer--)
CLKDIV = 0x0000; // Set PLL prescaler (1:1)
init(); //setup the crystal, pins, hold the FPGA in reset
usbbufflush(); //setup the USB byte buffer
USBDeviceInit();//setup usb
while(1){
USBDeviceTasks();
if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) continue;
usbbufservice();//load any USB data into byte buffer
//send data from the FPGA receive buffer to USB
//if((mUSBUSARTIsTxTrfReady()) && (uartincnt > 0)){
// putUSBUSART(&buf[0], uartincnt);
//}
CDCTxService();
}//end while
}//end main
示例8: BinaryMemoryUpload
/*****************************************************************************
* void BinaryMemoryUpload(void)
*****************************************************************************/
void BinaryMemoryUpload(void)
{
#ifdef USE_COMM_PKT_MEDIA_USB
#if defined(USB_INTERRUPT)
USBDeviceAttach();
#endif
#endif
COMM_PKT_Init();
while(!BinaryHandlePacket())
{
COMM_PKT_Update(FLASH_PROGRAMMER_COMMUNICATION_MEDIUM);
#ifdef USE_COMM_PKT_MEDIA_USB
#if defined(USB_POLLING)
// Check bus status and service USB interrupts.
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
// this function periodically. This function will take care
// of processing and responding to SETUP transactions
// (such as during the enumeration process when you first
// plug in). USB hosts require that USB devices should accept
// and process SETUP packets in a timely fashion. Therefore,
// when using polling, this function should be called
// regularly (such as once every 1.8ms or faster** [see
// inline code comments in usb_device.c for explanation when
// "or faster" applies]) In most cases, the USBDeviceTasks()
// function does not take very long to execute (ex: <100
// instruction cycles) before it returns.
#endif
#endif
}
}
示例9: INTERRUPT_InterruptManager
void interrupt INTERRUPT_InterruptManager (void)
{
// interrupt handler
if(PIE1bits.TMR1IE == 1 && PIR1bits.TMR1IF == 1)
{
TMR1_ISR();
// Call Timer Handler
TMRapp_Tick(); // Handle Every mS
}
else if( (PIE1bits.RCIE == 1) && (PIR1bits.RCIF == 1) )
{
USBapp_setrxByteFlag();
EUSART_Receive_ISR();
}
else if( (PIE1bits.TXIE == 1) && (PIR1bits.TXIF == 1) )
{
EUSART_Transmit_ISR();
}
else if(PIE2bits.C1IE == 1 && PIR2bits.C1IF == 1)
{
CMP1_ISR();
}
else
{
//Unhandled Interrupt
USBDeviceTasks(); // USB things
}
}
示例10: highPrioISR
void highPrioISR(void)
{
#if defined(USB_INTERRUPT)
/* if (PIR2bits.USBIF) */
USBDeviceTasks();
#endif
} //This return will be a "retfie fast", since this is in a #pragma interrupt section
示例11: DelayMs
void DelayMs(uint16_t time)
{
uint16_t delay;
//Caller wants to block for a possibly very long time. If USB is enabled
//and operated in polling mode, we must call USBDeviceTasks() periodically
//so we can still process mandatory USB control transfer requests from the
//host within the time allowed by the USB specs.
#if defined(USB_POLLING)
if(U1CONbits.USBEN == 1)
{
while(time--)
{
for(delay=0; delay < 240u; delay++)
{
USBDeviceTasks(); //Assuming 50 inst cycles/call @ 12 MIPS = ~240 calls/ms
}
}
}
else
{
while(time--)
{
for(delay=0; delay<DELAY_1MS; delay++);
}
}
#else
while(time--)
{
for(delay=0; delay<DELAY_1MS; delay++);
}
#endif
}
示例12: main
// Main program entry point
void main(void)
{
// Initialise and configure the PIC ready to go
initialisePic();
// If we are running in interrupt mode attempt to attach the USB device
#if defined(USB_INTERRUPT)
USBDeviceAttach();
#endif
// Main processing loop
while(1)
{
#if defined(USB_POLLING)
// If we are in polling mode the USB device tasks must be processed here
// (otherwise the interrupt is performing this task)
USBDeviceTasks();
#endif
// Process USB Commands
processUsbCommands();
// Note: Other application specific actions can be placed here
}
}
示例13: main
/********************************************************************
* Function: void main(void)
*
* PreCondition: None
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Main program entry point.
*
* Note: None
*******************************************************************/
MAIN_RETURN main(void)
{
SYSTEM_Initialize(SYSTEM_STATE_USB_START);
USBDeviceInit();
USBDeviceAttach();
setup();
while(1)
{
SYSTEM_Tasks();
#if defined(USB_POLLING)
// Interrupt or polling method. If using polling, must call
// this function periodically. This function will take care
// of processing and responding to SETUP transactions
// (such as during the enumeration process when you first
// plug in). USB hosts require that USB devices should accept
// and process SETUP packets in a timely fashion. Therefore,
// when using polling, this function should be called
// regularly (such as once every 1.8ms or faster** [see
// inline code comments in usb_device.c for explanation when
// "or faster" applies]) In most cases, the USBDeviceTasks()
// function does not take very long to execute (ex: <100
// instruction cycles) before it returns.
USBDeviceTasks();
#endif
//Application specific tasks
APP_DeviceCDCBasicDemoTasks();
}//end while
}//end main
示例14: main
int main(void) {
InitializeSystem();
// Wait for reset button to be released
while (_PORT(PIO_BTN1) == HIGH) { }
//ADCInitialize();
PWMInitialize();
PWMEnable();
USBDeviceInit();
//ADCStartCapture();
_LAT(PIO_LED1) = HIGH;
ColourEngine::Initialize();
//ColourEngine::PowerOn(1000); // Fade in
ColourEngine::SetPower(power, 0);
//_LAT(PIO_LED2) = HIGH;
while (1) {
USBDeviceTasks();
USBUserProcess();
}
return 0;
}
示例15: main
int main(void)
#endif
{
InitializeSystem();
#if defined(USB_INTERRUPT)
USBDeviceAttach();
#endif
while(1)
{
#if defined(USB_POLLING)
// Check bus status and service USB interrupts.
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
// this function periodically. This function will take care
// of processing and responding to SETUP transactions
// (such as during the enumeration process when you first
// plug in). USB hosts require that USB devices should accept
// and process SETUP packets in a timely fashion. Therefore,
// when using polling, this function should be called
// frequently (such as once about every 100 microseconds) at any
// time that a SETUP packet might reasonably be expected to
// be sent by the host to your device. In most cases, the
// USBDeviceTasks() function does not take very long to
// execute (~50 instruction cycles) before it returns.
#endif
// Application-specific tasks.
// Application related code may be added here, or in the ProcessIO() function.
ProcessIO();
}//end while
}//end main