📄 usbdmain.c
字号:
/*****************************************************************************
* usbmain.c: main C entry file for NXP LPC23xx/24xx Family Microprocessors
*
* Copyright(C) 2006, NXP Semiconductor
* All rights reserved.
*
* History
* 2006.07.20 ver 1.00 Prelimnary version, first Release
*
******************************************************************************/
#include "LPC23xx.h" /* LPC23xx/24xx definitions */
#include "type.h"
#include "irq.h"
#include "target.h"
#include "timer.h"
#include "lcd.h"
#include "usb.h"
#include "usbcfg.h"
#include "usbhw.h"
#include "usbcore.h"
#include "hiduser.h"
extern volatile DWORD SuspendFlag;
extern volatile DWORD timer_counter;
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 ( FIO2PIN & (1 << 10) ) { /* Check if push button, EXTINT0, is pressed */
InReport = 0x00;
} else {
InReport = 0x01;
}
}
/*
* Set HID Output Report <- OutReport
*/
void SetOutReport (void) {
FIO2CLR = 0x00FF;
FIO2SET = OutReport;
}
/*****************************************************************************
** Main Function main()
******************************************************************************/
int main (void)
{
int i;
#if POWERDOWN_MODE_USB_WAKEUP
DWORD WakeupFlag = 0;
init_timer(TIME_INTERVAL); /* the timer is for USB suspend and resume */
#endif
USB_Init(); /* USB Initialization */
USB_Connect(TRUE); /* USB Connect */
FIO2DIR |= 0x000000FF; /* LEDs, port 2, bit 0~7 output only */
#if POWERDOWN_MODE_USB_WAKEUP
INTWAKE |= (1 << 5); /* Wake up from USB activities */
#endif
lcd_init();
lcd_clear();
lcd_print (" LPC2378-EK ");
set_cursor (0, 1);
lcd_print (" www.po-star.com");
//================================
for (i = 0; i < 20000000; i++); /* Wait for initial display */
//================================
lcd_init();
lcd_clear();
lcd_print (" LPC2378-EK ");
set_cursor (0, 1);
lcd_print (" USBHID DEMO ");
/********* The main Function is an endless loop ***********/
while( 1 )
{
#if POWERDOWN_MODE_USB_WAKEUP
if ( WakeupFlag == 1 )
{
WakeupFlag = 0;
ConfigurePLL();
USB_Init(); /* USB Initialization */
USB_Connect(TRUE); /* USB Connect */
}
/* bit 8 is USB NeedClk bit. */
// if ( (SuspendFlag == 1 ) && (USB_INT_STAT & (1 << 8)) == 0x0 )
if ( SuspendFlag == 1 )
{
if ( timer_counter > 200 )
{
HC_CMD_STAT |= 0x01;
OTG_CLK_CTRL = 0x00;
while ( USB_INT_STAT & (1 << 8) );
WakeupFlag = 1;
PCON = 0x2;
}
}
#endif
}
return 0;
}
/******************************************************************************
** End Of File
******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -