void usb_msc_start (void) {

    debug("Initialising USB stack");

    // initialise stack
    USBInit();

    // enable bulk-in interrupts on NAKs
    // these are required to get the BOT protocol going again after a STALL
    USBHwNakIntEnable(INACK_BI);

    // register descriptors
    USBRegisterDescriptors(abDescriptors);

    // register class request handler
    USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

    // register endpoint handlers
    USBHwRegisterEPIntHandler(MSC_BULK_IN_EP, MSCBotBulkIn);
    USBHwRegisterEPIntHandler(MSC_BULK_OUT_EP, MSCBotBulkOut);

    debug("Starting USB communication");

    // connect to bus
    USBHwConnect(true);

    // call USB interrupt handler continuously
    while (1) {
        USBHwISR();
    }
}
Exemplo n.º 2
0
int ubertooth_usb_init(VendorRequestHandler *vendor_req_handler)
{
	// initialise stack
	USBInit();
	
	// register device descriptors
	USBRegisterDescriptors(abDescriptors);

	// Request handler 
	v_req_handler = vendor_req_handler;

	// override standard request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_VENDOR, usb_vendor_request_handler, abVendorReqData);

	// register endpoints
	//USBHwRegisterEPIntHandler(BULK_IN_EP, usb_bulk_in_handler);
	//USBHwRegisterEPIntHandler(BULK_OUT_EP, usb_bulk_out_handler);

	// enable USB interrupts
	//ISER0 = ISER0_ISE_USB;

	// connect to bus
	USBHwConnect(TRUE);

	return 0;
}
Exemplo n.º 3
0
/**
	Initialises the USB hardware and sets up the USB stack by
	installing default callbacks.
	
	@return TRUE if initialisation was successful
 */
BOOL USBInit(void)
{
	// init hardware
	USBHwInit();

	// Manual reset to workaround silicon bug
	USBHwReset();

	// Reset USB address
	USBHwSetAddress(0);
	
	// register device status interrupt handler
	USBHwRegisterDevIntHandler(HandleUsbDevStatus);
	
	// register control transfer handler on EP0
	USBHwRegisterEPIntHandler(0x00, USBHandleControlTransfer);
	USBHwRegisterEPIntHandler(0x80, USBHandleControlTransfer);
	
	// setup control endpoints
	USBHwEPConfig(0x00, MAX_PACKET_SIZE0);
	USBHwEPConfig(0x80, MAX_PACKET_SIZE0);
	
	// register standard request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_STANDARD, USBHandleStandardRequest, abStdReqData);

	return TRUE;
}
Exemplo n.º 4
0
Arquivo: usb.c Projeto: lwalkera/R2C2
void USBSerial_Init(void)
{
  // initialise stack
  USBInit();

  // register descriptors
  USBRegisterDescriptors(abDescriptors);

  // register class request handler
  USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

  // register endpoint handlers
  USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
  USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
  USBHwRegisterEPIntHandler(BULK_OUT_EP, BulkOut);

  // register frame handler
  USBHwRegisterFrameHandler(USBFrameHandler);

  // enable bulk-in interrupts on NAKs
  USBHwNakIntEnable(INACK_BI);

  // initialise VCOM
  serial_init();

  NVIC_EnableIRQ(USB_IRQn);

  // connect to bus
  USBHwConnect(TRUE);
}
Exemplo n.º 5
0
void init_usb_msc_device(void)
{
	DBG("Initialising USB stack\n");

	// initialise stack
	USBInit();

	// enable bulk-in interrupts on NAKs
	// these are required to get the BOT protocol going again after a STALL
	USBHwNakIntEnable(INACK_BI);

	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint handlers
	USBHwRegisterEPIntHandler(MSC_BULK_IN_EP, MSCBotBulkIn);
	USBHwRegisterEPIntHandler(MSC_BULK_OUT_EP, MSCBotBulkOut);

	DBG("Starting USB communication\n");

	// connect to bus
	USBHwConnect(TRUE);
}
Exemplo n.º 6
0
/*
 * main
 */
int main(void) {

    FIO_ENABLE;
    pllstart_seventytwomhz() ;
    mam_enable();
    uart0_init_115200() ;

    DBG(UART0,"Initialising USB stack\n");

    // initialise stack
    USBInit();

    // register descriptors
    USBRegisterDescriptors(abDescriptors);

    // register class request handler
    USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

    // register endpoint handlers
    USBHwRegisterEPIntHandler(INT_IN_EP, NULL);

    // register frame handler
    USBHwRegisterFrameHandler(USBFrameHandler);

    // register device event handler
    USBHwRegisterDevIntHandler(USBDevIntHandler);

    inputIsocDataBuffer[0] = 0;

    DBG(UART0,"Starting USB isoc datatpath test\n");

    VICVectPriority22 = 0x01;
    VICVectAddr22     = (int) USBIntHandler;

    // set up USB interrupt
    VICIntSelect      &= ~(1<<22);     // select IRQ for USB
    VICIntEnable      |= (1<<22);

    vic_enableIRQ();

    // connect to bus
    USBHwConnect(TRUE);

    stream_task();

    return 0;
}
Exemplo n.º 7
0
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
	// PLL and MAM
	Initialize();

	// init DBG
	ConsoleInit(60000000 / (16 * BAUD_RATE));

	// initialise the SD card
	BlockDevInit();

	DBG("Initialising USB stack\n");

	// initialise stack
	USBInit();
	
	// enable bulk-in interrupts on NAKs
	// these are required to get the BOT protocol going again after a STALL
	USBHwNakIntEnable(INACK_BI);

	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);
	
	// register endpoint handlers
	USBHwRegisterEPIntHandler(MSC_BULK_IN_EP, MSCBotBulkIn);
	USBHwRegisterEPIntHandler(MSC_BULK_OUT_EP, MSCBotBulkOut);

	DBG("Starting USB communication\n");

	// connect to bus
	USBHwConnect(TRUE);

	// call USB interrupt handler continuously
	while (1) {
		USBHwISR();
	}
	
	return 0;
}
Exemplo n.º 8
0
/*************************************************************************
	USBInit
	=======
		Initialises the USB hardware and sets up the USB stack by
		installing default callbacks.

**************************************************************************/
BOOL USBInit(void)
{
	// init hardware
	USBHwInit();

	// register bus reset handler
	USBHwRegisterDevIntHandler(HandleUsbReset);

	// register control transfer handler on EP0
	USBHwRegisterEPIntHandler(0x00, MAX_PACKET_SIZE0, USBHandleControlTransfer);
	USBHwRegisterEPIntHandler(0x80, MAX_PACKET_SIZE0, USBHandleControlTransfer);

	// register standard request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_STANDARD, USBHandleStandardRequest);

	// register
	USBRegisterDescriptorHandler(USBHandleDescriptor);

	return TRUE;
}
Exemplo n.º 9
0
/**
	Initialises the USB hardware and sets up the USB stack by
	installing default callbacks.

	@return TRUE if initialisation was successful
 */
BOOL USBInit(void)
{
	// init hardware
	USBHwInit();

	// register bus reset handler
	USBHwRegisterDevIntHandler(HandleUsbReset);

	// register control transfer handler on EP0
	USBHwRegisterEPIntHandler(0x00, USBHandleControlTransfer);
	USBHwRegisterEPIntHandler(0x80, USBHandleControlTransfer);

	// setup control endpoints
	USBHwEPConfig(0x00, MAX_PACKET_SIZE0);
	USBHwEPConfig(0x80, MAX_PACKET_SIZE0);

	// register standard request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_STANDARD, USBHandleStandardRequest, abStdReqData);

	return TRUE;
}
Exemplo n.º 10
0
/*************************************************************************
  main
  ====
**************************************************************************/
int main_mass_storage(void)
{
  unsigned cpsr;

  // disable global interrupts, do it polling
  cpsr = disableIRQ();

  // initialise the SD card
  BlockDevInit();

  // initialise stack
  USBInit();

  // enable bulk-in interrupts on NAKs
  // these are required to get the BOT protocol going again after a STALL
  USBHwNakIntEnable(INACK_BI);

  // register descriptors
  USBRegisterDescriptors(abDescriptors);

  // register class request handler
  USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

  // register endpoint handlers
  USBHwRegisterEPIntHandler(MSC_BULK_IN_EP, MSCBotBulkIn);
  USBHwRegisterEPIntHandler(MSC_BULK_OUT_EP, MSCBotBulkOut);

  // connect to bus
  USBHwConnect(TRUE);

  // call USB interrupt handler continuously
  while (1) {
    USBHwISR();
  }

  // possibly restore global interrupts (never happens)
  restoreIRQ(cpsr);

  return 0;
}
Exemplo n.º 11
0
void platform_setup_usb_cdc(void)
{
	int c;

	printf("Initialising USB stack\n");

	// initialise stack
	USBInit();

	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint handlers
	USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
	USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
	USBHwRegisterEPIntHandler(BULK_OUT_EP, BulkOut);

	// register frame handler
	USBHwRegisterFrameHandler(USBFrameHandler);

	// enable bulk-in interrupts on NAKs
	USBHwNakIntEnable(INACK_BI);

	// initialise VCOM
	VCOM_init();
	printf("Starting USB communication\n");

	// enable IRQ
	NVIC_EnableIRQ(USB_IRQn);

	// connect to bus

	printf("Connecting to USB bus\n");
	USBHwConnect(TRUE);
}
Exemplo n.º 12
0
USBSerialStream::USBSerialStream(Stream *echoStream) :  m_infifo(512), m_outfifo(512), m_bTransferInProgress(false), m_bDontStartNew(false),
	m_bConnected(false)
{

	// initialise stack
	USBInit();

	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint handlers
	USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
	USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
	USBHwRegisterEPIntHandler(BULK_OUT_EP, BulkOut);

	USBHwRegisterDevIntHandler(DevIntHandler);
	USBHwRegisterFrameHandler(FrameHandler);

	// enable bulk-in interrupts on NAKs
	//USBHwNakIntEnable(INACK_BI);

	// set up USB interrupt
	VICIntSelect &= ~(1<<22);               // select IRQ for USB
	VICIntEnable |= (1<<22);

	(*(&VICVectCntl0+INT_VECT_NUM)) = 0x20 | 22; // choose highest priority ISR slot 	
	(*(&VICVectAddr0+INT_VECT_NUM)) = (int)USBHandlerSerial;

	UART_puts("Connecting USB\n\r");

	// connect to bus
	USBHwConnect(TRUE);

}
Exemplo n.º 13
0
void vUSBTask( void *pvParameters )
{
    int c;

    /* Just to prevent compiler warnings about the unused parameter. */
    ( void ) pvParameters;
    DBG("Initialising USB stack\n");

    xRxedChars = xQueueCreate( usbBUFFER_LEN, sizeof( char ) );
    xCharsForTx = xQueueCreate( usbBUFFER_LEN, sizeof( char ) );

    if( ( xRxedChars == NULL ) || ( xCharsForTx == NULL ) )
    {
        /* Not enough heap available to create the buffer queues, can't do
        anything so just delete ourselves. */
        vTaskDelete( NULL );
    }


    // initialise stack
    USBInit();

    // register descriptors
    USBRegisterDescriptors(abDescriptors);

    // register class request handler
    USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

    // register endpoint handlers
    USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
    USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
    USBHwRegisterEPIntHandler(BULK_OUT_EP, BulkOut);

    // register frame handler
    USBHwRegisterFrameHandler(USBFrameHandler);

    // enable bulk-in interrupts on NAKs
    USBHwNakIntEnable(INACK_BI);

    DBG("Starting USB communication\n");

    NVIC_SetPriority( USB_IRQn, configUSB_INTERRUPT_PRIORITY );
    NVIC_EnableIRQ( USB_IRQn );

    // connect to bus

    DBG("Connecting to USB bus\n");
    USBHwConnect(TRUE);

    // echo any character received (do USB stuff in interrupt)
    for( ;; )
    {
        c = VCOM_getchar();
        if (c != EOF)
        {
            // Echo character back with INCREMENT_ECHO_BY offset, so for example if
            // INCREMENT_ECHO_BY is 1 and 'A' is received, 'B' will be echoed back.
            VCOM_putchar(c + INCREMENT_ECHO_BY );
        }
    }
}
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
	int c, i;
	
	IODIR0 |= (1<<10);
	
	
	// PLL and MAM
	HalSysInit();

#ifdef LPC214x
	// init DBG
	ConsoleInit(60000000 / (16 * BAUD_RATE));
#else
	// init DBG
	ConsoleInit(72000000 / (16 * BAUD_RATE));
#endif

	DBG("Initialising USB stack\n");

	// initialise stack
	USBInit();

	configureADCPort(AD0_3);
	
	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint handlers
	USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
		
	// register frame handler
	USBHwRegisterFrameHandler(USBFrameHandler);
	
	// register device event handler
	USBHwRegisterDevIntHandler(USBDevIntHandler);
	
	
	char ch = 'a';
	for (i = 0; i < BYTES_PER_ISOC_FRAME; i++) {
		inputIsocDataBuffer[i] = ch;
		ch = (ch == 'z' ? 'a' : (ch + 1));
	}
	
	DBG("Starting USB communication\n");

#ifdef LPC214x
	(*(&VICVectCntl0+INT_VECT_NUM)) = 0x20 | 22; // choose highest priority ISR slot 	
	(*(&VICVectAddr0+INT_VECT_NUM)) = (int)USBIntHandler;
#else
  VICVectCntl22 = 0x01;
  VICVectAddr22 = (int)USBIntHandler;
#endif
  
	// set up USB interrupt
	VICIntSelect &= ~(1<<22);               // select IRQ for USB
	VICIntEnable |= (1<<22);
	
	enableIRQ();

	// connect to bus
	USBHwConnect(TRUE);
	
	int x = 0;
		
	const int interval = 100000;
	// echo any character received (do USB stuff in interrupt)
	
	for(;;) {
		x++;
		U32 temp = cADC_Result(AD0_3);
		if( temp >= 0 && temp <= 1024 )
			inputIsocDataBuffer[ADC_INPUT_INDEX] = temp;
		
		
		inputIsocDataBuffer[BUTTON1_INPUT_INDEX] = ((IOPIN0 & (1<<15)) ? 1 : 0);
		inputIsocDataBuffer[BUTTON2_INPUT_INDEX] = ((IOPIN0 & (1<<16)) ? 1 : 0);
		
		if (x == interval) {
			
			IOSET0 = (1<<11);
			//turn on led	
		    
		} else if (x >= (interval*2)) {
			IOCLR0 = (1<<11);
			//turn off led
			x = 0;
		}
	}

	return 0;
}
Exemplo n.º 15
0
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
    int x = 0;

    const int interval = 200000;

    FIO_ENABLE;

    vic_disableIRQ();

    pllstart_seventytwomhz() ;
    // pllstart_sixtymhz() ;
    //   pllstart_fourtyeightmhz() ;

    mam_enable();

    info_init();

    uart0_init_115200() ;

    uart0_putstring("\n***Starting gfe color led test***\n\n");
    uart0_putstring("\n***Board is defined as: ");

    uart0_putstring( infoquery_gfe_boardtag() );

    uart0_putstring(" ***\n");

    init_color_led();

    RED_LED_OFF;
    BLUE_LED_OFF;
    GREEN_LED_OFF;

    printf_lpc(UART0,"5 FAST flashes...red, blue then green\n");
    color_led_flash(5, RED_LED, FLASH_FAST ) ;
    RED_LED_OFF;
    color_led_flash(5, BLUE_LED,  FLASH_FAST ) ;
    BLUE_LED_OFF;
    color_led_flash(5, GREEN_LED, FLASH_FAST ) ;
    GREEN_LED_OFF;
    uart0_putstring(" ** END OF TEST ""\n");

    printf_lpc(UART0, "Initialising USB stack\n");

    // initialize stack
    USBInit();

    // register descriptors
    USBRegisterDescriptors(abDescriptors);

    // register class request handler
    USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

    // register endpoint handlers
    USBHwRegisterEPIntHandler(INT_IN_EP, NULL);

    // register frame handler
    USBHwRegisterFrameHandler(USBFrameHandler);

    // register device event handler
    USBHwRegisterDevIntHandler(USBDevIntHandler);

    inputIsocDataBuffer[0] = 0;

    printf_lpc(UART0, "Starting USB communication\n");

    VICVectPriority22  = 0x01;         // 0x0 is highest priority, 0xF is lowest
    VICVectAddr22      = (unsigned int)USBIntHandler;
    VICAddress         = 0x0;

    printf_lpc(UART0, "addresses entered\n");

    ENABLE_USB_IRQ;

    printf_lpc(UART0, "USB IRQ Enabled\n");

    vic_enableIRQ();

    printf_lpc(UART0, "vic_enable\n");

    ENABLE_USB_INT;

    printf_lpc(UART0, "USB INT Enabled\n");



    //printf_lpc(UART0, "connect to bus\n");
//
//	// connect to bus
    USBHwConnect(TRUE);
//

    for(;;) {
        x++;

        if (x == interval) {
            RED_LED_ON;
        } else if (x >= (interval*2)) {
            x = 0;
            RED_LED_OFF;
        }
    }

    return 0;
}
Exemplo n.º 16
0
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
	int c, i;
	
	// PLL and MAM
	HalSysInit();

#ifdef LPC214x
	// init DBG
	ConsoleInit(60000000 / (16 * BAUD_RATE));
#else
	// init DBG
	ConsoleInit(72000000 / (16 * BAUD_RATE));
#endif

	configureADCPort(AD0_3);

	
	DBG("Initialising USB stack\n");

	// initialise stack
	USBInit();

	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint handlers
	USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
		
	// register frame handler
	USBHwRegisterFrameHandler(USBFrameHandler);
	
	// register device event handler
	USBHwRegisterDevIntHandler(USBDevIntHandler);
	
	USBInitializeUSBDMA(udcaHeadArray);
	USBEnableDMAForEndpoint(ISOC_IN_EP);
	
	DBG("Starting USB communication\n");

#ifdef LPC214x
	(*(&VICVectCntl0+INT_VECT_NUM)) = 0x20 | 22; // choose highest priority ISR slot 	
	(*(&VICVectAddr0+INT_VECT_NUM)) = (int)USBIntHandler;
#else
  VICVectCntl22 = 0x01;
  VICVectAddr22 = (int)USBIntHandler;
#endif
  
	// set up USB interrupt
	VICIntSelect &= ~(1<<22);               // select IRQ for USB
	VICIntEnable |= (1<<22);
	
	enableIRQ();

	// connect to bus
	USBHwConnect(TRUE);
	
	int x = 0;
	c = EOF;
	
	
	//populate source data with all 'B's
	for(i = 0; i < ISOC_INPUT_DATA_BUFFER_SIZE; i++ ) {
		inputIsocDataBuffer[i] = 'B';
	}

	
	int cnt = 0;
	const int interval = 100000;
	// echo any character received (do USB stuff in interrupt)
	
	for(;;) {
		x++;
		U32 temp = cADC_Result(AD0_3);
		if( temp >= 0 && temp <= 1024 )
			currentADCReadValue = temp;
		
		if (x == interval) {
			qq++;
			
			IOSET0 = (1<<11);
			//turn on led	
		    
		} else if (x >= (interval*2)) {
			IOCLR0 = (1<<11);
			//turn off led
			x = 0;
		}
	}

	return 0;
}
Exemplo n.º 17
0
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
	// USB: Init
	// CAS -> Initialization of KbdInputReport to initial values (0,0,0,0,..)
	HIDDKbdInputReport_Initialize (&KbdInputReport);

	// CAS -> Variable used to simulate the pressing of Letter A (0x04)
	int i;

	DBG("Initialising USB stack\n");
	
	// CAS -> Variable used to simulate the pressing of Letter A (0x04)
	// 	USBInit()
	//		USBHwInit()										HW Init
	//			-> Set Pins for USB, AHBClock, ACK generate interrupts
	//		USBHwRegisterDevIntHandler(HandleUsbReset)
	//			-> Define un handler (HandleUsbReset).
	//
	// initialize stack
	USBInit();
	
	// register device descriptors
	USBRegisterDescriptors(abDescriptors);

	// register HID standard request handler
	USBRegisterCustomReqHandler(HIDHandleStdReq);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint (2?). Interrupt In Endpoint
	USBHwRegisterEPIntHandler(INTR_IN_EP, NULL);

	// register frame handler
	USBHwRegisterFrameHandler(HandleFrame);
	
	DBG("Starting USB communication\n");


	// connect to bus
	USBHwConnect(TRUE);

	//RC5: Init
	GPIO_SetDir(0,1<<4,1);
	GPIO_SetDir(0,1<<5,1);

	GPIO_SetValue(0,1<<5);
	GPIO_SetValue(0,1<<4);


	RC5_Init();

	// main() Loop:


	// call USB interrupt handler continuously
	
	// CodeRed - either read mouse, or provide "fake mouse readings"
	while (1)
	{

		for (i=0; i<10;  i++) {


			// RC5
		    if (RC5_flag)                      // wait for RC5 code
		    	    {

		      if((RC5_System==0)&&(RC5_Command==1)){
		      GPIO_ClearValue(0,1<<4);
		      for(i=0;i<1000000;i++);
		      GPIO_SetValue(0,1<<4);
		      for(i=0;i<1000000;i++);
		      }

		      if((RC5_System==0)&&(RC5_Command==5)){
		      GPIO_ClearValue(0,1<<5);
		      for(i=0;i<1000000;i++);
		      GPIO_SetValue(0,1<<5);
		      for(i=0;i<1000000;i++);
		      }

		      RC5_flag = 0;
		      printf( "RC5 =  %d   %d\n", RC5_System, RC5_Command);
		    }
		    // RC5

		  USBHwISR();
		  if (i < 5) {
			  KbdInputReport.Key_1 = 0x04;
		  }
		  else {
			  KbdInputReport.Key_1 = 0x00;
		  }
		}
		
	}
	
	return 0;
}
Exemplo n.º 18
0
/*************************************************************************
	main
	====
**************************************************************************/
bool  USBStart(void)
{
	int c;
	


	// initialise stack
	USBInit();

	// register descriptors
	USBRegisterDescriptors(abDescriptors);

	// register class request handler
	USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

	// register endpoint handlers
	USBHwRegisterEPIntHandler(INT_IN_EP, NULL);
	USBHwRegisterEPIntHandler(BULK_IN_EP, BulkIn);
	USBHwRegisterEPIntHandler(BULK_OUT_EP, BulkOut);
	
	// register frame handler
	USBHwRegisterFrameHandler(USBFrameHandler);
	
	// register device event handler
	USBHwRegisterDevIntHandler(USBDevIntHandler);

	// initialise VCOM
	VCOM_init();



      VICVectCntl22 = 0x01;
      VICVectAddr22 = (int)USBIntHandler;

  
	// set up USB interrupt
	VICIntSelect &= ~(1<<22);               // select IRQ for USB
	VICIntEnable |= (1<<22);
	

	// connect to bus
	USBHwConnect(TRUE);

#if TCM
	// echo any character received (do USB stuff in interrupt)
	while (1) {
		c = VCOM_getchar();
		if (c != EOF) {
			// show on console
			if ((c == 9) || (c == 10) || (c == 13) || ((c >= 32) && (c <= 126))) {
				DBG("%c", c);
			}
			else {
				DBG(".");
			}
			VCOM_putchar(c);
		}
	}

	return 0;
#endif
 return true;
}
Exemplo n.º 19
0
/*************************************************************************
    main
    ====
**************************************************************************/
int main(void)
{
    GO go_entry;

    // PLL and MAM
    Initialize();

    // init DBG
    ConsoleInit(CCLK / (16 * BAUD_RATE));

    DBG("Initialising USB stack\n");

    write_ram_len=0;
    read_mem_len=0;
    unlocked=0;
    bEcho=1;

    // initialise stack
    USBInit();

    // register descriptors
    USBRegisterDescriptors(abDescriptors);

    // register vendor request handler
    USBRegisterRequestHandler(REQTYPE_TYPE_VENDOR, HandleVendorRequest);

    // register pre request handler
    USBRegisterPreRequestHandler(PreHandleRequest);

    DBG("Starting USB communication\n");

    // connect to bus
    USBHwConnect(TRUE);

    start_app = 0;

    // call USB interrupt handler continuously
    while (1)
    {
        USBHwISR();

        if (start_app == 1)
        {
            volatile unsigned int count;

            // wait some time until response is sent
            for (count=0;count<10000;count++) USBHwISR();

            // disconnect from bus
            USBHwConnect(FALSE);

            // wait some ms so that called app might safely re-connect usb
            for (count=0;count<300000;count++) count=count;

            go_entry = (GO) (start_adr);
            go_entry();
        }
    }

    return 0;
}
Exemplo n.º 20
0
/*************************************************************************
	main
	====
**************************************************************************/
int main(void)
{
    IODIR0 |= (1<<10);//Debug LED on the olimex 2148 dev board set to output mode
    IODIR0 |= (1<<11);//Debug LED on the olimex 2148 dev board set to output mode

    // PLL and MAM
    HalSysInit();

#ifdef LPC214x
    // init DBG
    ConsoleInit(60000000 / (16 * BAUD_RATE));
#else
    // init DBG
    ConsoleInit(72000000 / (16 * BAUD_RATE));
#endif

    DBG("Initialising USB stack\n");

    // initialise stack
    USBInit();

    // register descriptors
    USBRegisterDescriptors(abDescriptors);

    // register class request handler
    USBRegisterRequestHandler(REQTYPE_TYPE_CLASS, HandleClassRequest, abClassReqData);

    // register endpoint handlers
    USBHwRegisterEPIntHandler(INT_IN_EP, NULL);

    // register frame handler
    USBHwRegisterFrameHandler(USBFrameHandler);

    // register device event handler
    USBHwRegisterDevIntHandler(USBDevIntHandler);

    inputIsocDataBuffer[0] = 0;

    USBInitializeUSBDMA(udcaHeadArray);
    USBEnableDMAForEndpoint(ISOC_IN_EP);

    DBG("Starting USB communication\n");

#ifdef LPC214x
    (*(&VICVectCntl0+INT_VECT_NUM)) = 0x20 | 22; // choose highest priority ISR slot
    (*(&VICVectAddr0+INT_VECT_NUM)) = (int)USBIntHandler;
#else
    VICVectCntl22 = 0x01;
    VICVectAddr22 = (int)USBIntHandler;
#endif

    // set up USB interrupt
    VICIntSelect &= ~(1<<22);               // select IRQ for USB
    VICIntEnable |= (1<<22);

    enableIRQ();

    // connect to bus
    USBHwConnect(TRUE);

    int x = 0;

    const int interval = 200000;
    // echo any character received (do USB stuff in interrupt)

    for(;;) {
        x++;

        if (x == interval) {
            IOSET0 = (1<<11);//turn on led on olimex dev board
        } else if (x >= (interval*2)) {
            IOCLR0 = (1<<11);//turn off led on olimex dev board
            x = 0;
        }
    }

    return 0;
}