コード例 #1
0
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();
    }
}
コード例 #2
0
ファイル: isoc_io_dma_sample.c プロジェクト: promovicz/lpcusb
/**
	Interrupt handler

	Simply calls the USB ISR, then signals end of interrupt to VIC
 */
void USBIntHandler(void)
{
    ISR_ENTRY();
    USBHwISR();

    VICVectAddr = 0x00;    // dummy write to VIC to signal end of ISR
    ISR_EXIT();
}
コード例 #3
0
ファイル: isoc_ep.c プロジェクト: psas/node-usb
/**
	Interrupt handler
	
	Simply calls the USB ISR, then signals end of interrupt to VIC
 */
void USBIntHandler(void) 
{
    // do we really need this entry/exit stuff?
	 ISR_ENTRY(); 
	USBHwISR();
	
	VICVectAddr = 0x00;    // dummy write to VIC to signal end of ISR
	ISR_EXIT();
}
コード例 #4
0
void usb_msc_start (void)
{
	init_usb_msc_device();

  // call USB interrupt handler continuously
  while (1) {
    USBHwISR();
  }
}
コード例 #5
0
ファイル: multiEp.c プロジェクト: psas/node-usb
/**
   Interrupt handler
        
   Simply calls the USB ISR, then signals end of interrupt to VIC
*/
void USBIntHandler(void) 
{
    ISR_ENTRY(); 
    //DBG("Z");
    USBHwISR();
    //DBG("z");
    VICVectAddr = 0x00;    // dummy write to VIC to signal end of ISR
    //DBG("Exit int\n");
    ISR_EXIT();
}
コード例 #6
0
ファイル: ubertooth_usb.c プロジェクト: phar/ubertooth-fork
void handle_usb(u32 clkn)
{
	u8 epstat;

	/* write queued packets to USB if possible */
	epstat = USBHwEPGetStatus(BULK_IN_EP);
	if (!(epstat & EPSTAT_B1FULL)) {
		dequeue_send(clkn);
	}
	if (!(epstat & EPSTAT_B2FULL)) {
		dequeue_send(clkn);
	}

	/* polled "interrupt" */
	USBHwISR();
}
コード例 #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;
}
コード例 #8
0
ファイル: usb_msc_hw.c プロジェクト: 2seasuav/paparuzzi
/*************************************************************************
  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;
}
コード例 #9
0
void USBHandlerSerial(void)
{
	USBHwISR();
	VICVectAddr = 0x00;    // dummy write to VIC to signal end of ISR 	
}
コード例 #10
0
ファイル: USB_CDC.c プロジェクト: yhfudev/FreeRTOS
//void USBIntHandler(void)
void USB_IRQHandler(void)
{
    USBHwISR();
}
コード例 #11
0
ファイル: usb.c プロジェクト: ggaavv/R2C2_Firmware
/**
    Interrupt handler

    Simply calls the USB ISR
 */
void USB_IRQHandler(void)
{
	LPC_GPIO1->FIOPIN ^= 1 << 23; // Toggle P1.29
  USBHwISR();
}
コード例 #12
0
/**
	Interrupt handler

	Simply calls the USB ISR, then signals end of interrupt to VIC
 */
static void USBIntHandler(void)
{
	USBHwISR();
	VICVectAddr = 0x00;    // dummy write to VIC to signal end of ISR
}
コード例 #13
0
ファイル: usblibs.c プロジェクト: strahlex/LPC_Ethernet
/*
	Interrupt handler
	Simply calls the USB ISR
*/
void USB_IRQHandler(void)
{
	USBHwISR();
	CSP_IntClr(CSP_INT_CTRL_NBR_MAIN, CSP_INT_SRC_NBR_USB_00);
	CPU_IntSrcEn(CPU_INT_SYSTICK);                              /* Enable the SYSTICK interrupt. Resume OS operation.   */
}
コード例 #14
0
ファイル: main.c プロジェクト: lwalkera/R2C2
int main() {
	// DeInit NVIC and SCBNVIC
	NVIC_DeInit();
	NVIC_SCBDeInit();

	/* Configure the NVIC Preemption Priority Bits:
	 * two (2) bits of preemption priority, six (6) bits of sub-priority.
	 * Since the Number of Bits used for Priority Levels is five (5), so the
	 * actual bit number of sub-priority is three (3)
	 */
	NVIC_SetPriorityGrouping(0x05);

	NVIC_SetVTOR(0x00000000);

	#ifdef	UARTDEBUG
		uart_init();
	#endif

	BlockDevInit();

#ifdef	UARTDEBUG
	if (1) {
		U32 size;
		BlockDevGetSize(&size);
		DBG("Found SD card of size %d", size);
		BlockDevGetBlockLength(&size);
		DBG("block length %d", size);
	}
#endif

	if (bootloader_button_pressed() || (user_code_present() == 0)) {
		DBG("entering bootloader");
		init_usb_msc_device();

		for (;usb_msc_not_ejected();)
			USBHwISR();

		DBG("usb ejected, rebooting");

		USBHwConnect(FALSE);
		spi_close();
	}
	else {
		if ((r = f_mount(0, &fatfs)) == FR_OK) {
			if ((r = f_open(&f, "/firmware.bin", FA_READ | FA_OPEN_EXISTING)) == FR_OK) {
				unsigned int fs = f_size(&f);
				DBG("found firmware.bin with %u bytes", fs);
				if ((fs > 0) && (fs <= USER_FLASH_SIZE)) {
					U8 buffer[FLASH_BUF_SIZE];
					for (unsigned int i = 0; i < fs; i += FLASH_BUF_SIZE) {
						unsigned int j = FLASH_BUF_SIZE;
						if (i + j > fs)
							j = fs - i;
						DBG("writing %d-%d", i, i+j);
						if ((r = f_read(&f, buffer, j, &j)) == FR_OK) {
							// pad last block to a full sector size
							while (j < FLASH_BUF_SIZE) {
								buffer[j++] = 0xFF;
							}
							write_flash((unsigned int *) (USER_FLASH_START + i), (char *) &buffer, j);
						}
						else {
							DBG("read failed: %d", r);
							i = fs;
						}
					}
					r = f_close(&f);
					r = f_unlink("/firmware.bck");
					r = f_rename("/firmware.bin", "/firmware.bck");
				}
			}
			else {
				DBG("open \"/firmware.bin\" failed: %d", r);
			}
			#ifdef	GENERATE_FIRMWARE_CUR
				if (f_open(&f, "/firmware.bck", FA_READ | FA_OPEN_EXISTING)) {
					f_close(&f);
				}
				else {
					// no firmware.bck, generate one!
					if (f_open(&f, "/firmware.bck", FA_WRITE | FA_CREATE_NEW) == FR_OK) {
						U8 *flash = (U8 *) USER_FLASH_START;

						f_close(&f);
					}
				}
			#endif
			// elm-chan's fatfs doesn't have an unmount function
			// f_umount(&fatfs);
		}
		else {
			DBG("mount failed: %d", r);
		}
		spi_close();

		if (user_code_present()) {
			DBG("starting user code...");
			execute_user_code();
		}
		else {
			DBG("user code invalid, rebooting");
		}
	}
	NVIC_SystemReset();
}
コード例 #15
0
ファイル: bootloader.c プロジェクト: 0lri/paparazzi
/*************************************************************************
    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;
}
コード例 #16
0
ファイル: main_kbd.c プロジェクト: glocklueng/rc5-2-usb-v2
/*************************************************************************
	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;
}