?? uvcdemo.c
字號(hào):
/*----------------------------------------------------------------------------
* Name: UVCDEMO.C
* Purpose: USB Video Class Demo
* Version: V1.10
*----------------------------------------------------------------------------
* This software is supplied "AS IS" without any warranties, express,
* implied or statutory, including but not limited to the implied
* warranties of fitness for purpose, satisfactory quality and
* noninfringement. Keil extends you a royalty-free right to reproduce
* and distribute executable files created using this software for use
* on NXP LPC microcontroller devices only. Nothing else gives you
* the right to use this software.
*
* Copyright (c) 2005-2006 Keil Software.
*---------------------------------------------------------------------------*/
#include "lpc288x.h" /* LPC288x definitions */
#include "type.h"
#include "irq.h"
#include "target.h"
#include "usb.h"
#include "usbcfg.h"
#include "usbhw.h"
#include "usbcore.h"
#include "uvc.h"
#include "uvcuser.h"
#include "uvcdemo.h"
extern WORD USB_DeviceStatus;
volatile DWORD USBWakeupFlag = 0;
/*****************************************************************************
** Function name: EVT3_ISR
**
** Descriptions: Interrupt handler for event router group 3
**
** parameters: None
** Returned value: None
**
*****************************************************************************/
void EVT3_ISR(void)
{
if ( USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP )
{
USBMode |= (0x1<<6); // Resume
USBMode &= ~(0x1<<6);
USB_WakeUpCfg( TRUE );
}
else
{
USB_WakeUpCfg( FALSE );
}
EVECLR3 = ((0x1<<4)|(0x1<<5));
return;
}
/*****************************************************************************
** Function name: EventRouter3Init
**
** Descriptions:
**
** parameters: None
** Returned value: None
**
*****************************************************************************/
void EventRouter3Init( void )
{
/* Configure Interrupt Controller */
/* Set event router to IRQ1 for GPIO3 and GPIO2 */
EVIOMS13 |= ((0x1<<4)|(0x1<<5)); /* GPIO 2 and 3 interrupt are enabled. */
EVAPR3 = ((0x1<<4)|(0x1<<5)); /* rising edge */
EVATR3 = ((0x1<<4)|(0x1<<5)); /* edge trigger */
if ( install_IRQ(2, 1, EVT3_ISR ) == FALSE )
{
while ( 1 ); /* Fatal error due to ISR installation failure */
}
INT_REQ2=(1<<28)|(1<<27)|(1<<26)|(1<<16)|0x1;
INT_VECTOR0=IRQ_TABLE_BASE & MASK_INDEX;
return;
}
/* Main Program */
int main (void) {
DWORD DisconnectFlag = 0;
TargetResetInit();
if ( install_IRQ(26, 1, USB_ISR ) == FALSE )
{
while ( 1 ); /* Fatal error due to ISR installation failure */
}
INT_REQ26=(1<<28)|(1<<27)|(1<<26)|(1<<16)|0x1;
INT_VECTOR0=IRQ_TABLE_BASE & MASK_INDEX;
/* Check VBUS signal, make it input */
MODE1_7 &= ~(1<<0);
MODE0_7 &= ~(1<<0);
/* Make both MODE1(p2.2) and MODE2(p2.3) input */
MODE1_2 &= ~((1<<2)|(1<<3));
MODE0_2 &= ~((1<<2)|(1<<3));
/* Check remote wake up signal */
/* if either button, GPIO2, GPIO3, is pressed, set remote wake up */
EventRouter3Init();
while (1)
{
/* No need to initialize USB until VBus is sensed.
DisconnectFlag is a one time event. It will be set after
connected and cleared after disconnected. */
if ( (PINS_7 & (0x1<<0)) && !DisconnectFlag )
{
USB_Init(); /* USB Initialization */
USB_Connect(TRUE); /* USB Connect */
if ( !(PINS_7 & (0x1<<0)) )
{
/* Disconnected, reset flag */
DisconnectFlag = 0;
/* if connected, disconnect */
if ( USBMode & (1<<0) )
{
USB_Connect(FALSE);
}
}
else
{
/* Still connected, set flag, no need to go to Init() and
Connect() again */
DisconnectFlag = 1;
}
}
else if ( !(PINS_7 & (0x1<<0)) )
{
/* Disconnected, reset flag */
DisconnectFlag = 0;
/* if connected, disconnect */
if ( USBMode & (1<<0) )
{
USB_Connect(FALSE);
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -