www.pudn.com > USB_HID.rar > demo.c
/*---------------------------------------------------------------------------- * Name: DEMO.C * Purpose: USB HID Demo * Version: V1.03 *---------------------------------------------------------------------------- * This file is part of the uVision/ARM development tools. * Copyright (c) 2005 Keil Software. All rights reserved. *---------------------------------------------------------------------------*/ #include/* LPC214x definitions */ #include "type.h" #include "usb.h" #include "usbcfg.h" #include "usbhw.h" #include "usbcore.h" #include "demo.h" BYTE InReport; /* HID Input Report */ /* Bit0: Button */ /* Bit1..7: Reserved */ BYTE OutReport; /* HID Out Report */ /* Bit0..7: LEDs */ /* * Get HID Input Report -> InReport */ void GetInReport (void) { if ((IOPIN0 & PBINT) == 0) { /* Check if PBINT is pressed */ InReport = 0x01; } else { InReport = 0x00; } } /* * Set HID Output Report <- OutReport */ void SetOutReport (void) { IOPIN1 = (IOPIN1 & ~LEDMSK) | (OutReport << 16); } /* Main Program */ int main (void) { PINSEL1 = 0x40004000; /* Select USB Link, VBUS */ IODIR1 = LEDMSK; /* LED's defined as Outputs */ USB_Init(); /* USB Initialization */ USB_Connect(TRUE); /* USB Connect */ while (1); /* Loop forever */ }