Hello
pls find below the USB ISR and the Init functions.
Let me know if i have to do any further initializations for getting the
Reset and the Endpoint0 interrupts
_attribute__ ((interrupt ("IRQ"))) LPC_USB_ISR(void){
UINT32 uiInterrupt = 0;
UINT32 uiInterruptval = 0;
uart0Puts ("\rEntered ISR\n");
/* set the uiInterrupt to the Device Interrupt Status Register */
uiInterrupt = DEV_INT_STAT;
if (uiInterrupt & DEV_STAT_INT)
{
DEV_INT_CLR = uiInterrupt;
VICVectAddr = 0;
WrCmd(CMD_GET_DEV_STAT);
uiInterruptval = RdCmdDat(DAT_GET_DEV_STAT);
/* If the Reset bit is set,then invoke ResetUSB() to reset the USB Device
*/
if (uiInterruptval & DEV_RST)
{
uart0Puts ("\rReset Interrupt\n");
ResetUSB();
goto ISREnd;
}
if (uiInterruptval & DEV_SUS_CH)
{
if (uiInterruptval & DEV_SUS)
{
}
else
{
}
goto ISREnd;
} /* End of if (val & DEV_SUS_CH) */
/* If the Connection Status is changed */
if (uiInterruptval & DEV_CON_CH)
{
uart0Puts ("\rConnection Change Interrupt\n");
/* Clear the and acknowledge the interrupt received */
goto ISREnd;
}
} /* End of if (uiInterrupt & DEV_STAT_INT) */
/*
*If the interrupt received is Endpoint's Slow Interrupt on the Control
* EndPoint
*/
if (uiInterrupt & EP_SLOW_INT)
{
uart0Puts ("\r EP Slow Interrupt\n");
while (EP_INT_STAT)
{
/* Clear the Endpoint Interrupt */
EP_INT_CLR = 1;
while ((DEV_INT_STAT & CDFULL_INT) == 0);
uiInterruptval = CMD_DATA;
if (uiInterruptval & EP_SEL_STP)
{
/*
* Invoke USB_Enumeration () of the USB protocol Module to
* parse and process the Setup Packet received
*/
USB_Enumeration ();
goto ISREnd;
}
} /* End of while (EP_INT_STAT) */
} /* End of if (uiInterrupt & EP_SLOW_INT) */
ISREnd:
uart0Puts ("\r Reached ISR End \n");
DEV_INT_CLR = uiInterrupt;
VICVectAddr = 0;
} /* End of LPC_USB_ISR () */
----------------------------------------------------------------------------
-------------------------
UINT32
InitializeUSB (UINT32 uiType, UINT32 uiTimeoutvalue)
{
/* Select the USB Link */
PINSEL1 &= ~0xC000C000;
PINSEL1 |= 0x40004000;
/* Turn On USB PCLK */
PCONP |= 0x80000000;
/* Configure the 48MHz USB Clock and the Fosc */
PLL48CFG = 0x23;
PLL48CON = PLLCON_PLLE;
PLL48FEED = 0xAA;
PLL48FEED = 0x55;
/* Wait for PLL Lock */
while ((PLL48STAT & PLLSTAT_PLOCK) == 0);
/* Enable & Connect the PLL */
PLL48CON = PLLCON_PLLE | PLLCON_PLLC;
PLL48FEED = 0xAA;
PLL48FEED = 0x55;
/* Set the USB ISR, the IRQ Slot and Enable the USB Interrupt */
VICVectAddr0 = (unsigned int)LPC_USB_ISR;
VICVectCntl0 = 0x20 | 22;
VICIntEnable = 1 << 22;
/* Enable the Device Status Interrupt */
DEV_INT_EN = DEV_STAT_INT;
/*Reset USB*/
/* Load endpoint index Register with physical endpoint no.*/
EP_INDEX = 0;
/* Load the max packet size Register */
MAXPACKET_SIZE = USB_MAX_PACKET0;
EP_INDEX = 1;
MAXPACKET_SIZE = USB_MAX_PACKET0;
/* Wait till endpoint realization is complete */
while ((DEV_INT_STAT & EP_RLZED_INT) == 0);
/* Clear all the Endpoint interrupts */
EP_INT_CLR = INT_CLEAR;
/* Enable the Control Endpoint Interrupt */
EP_INT_EN = CNTRL_EP_ENABLE;
/* Clear the Device interrupts */
DEV_INT_CLR = INT_CLEAR;
/* Enable the Devcie Interrupts */
DEV_INT_EN = DEV_STAT_INT | EP_SLOW_INT;
/* set the default address */
WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | 0));
WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | 0));
/* make the softconnect active *./
WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
return uiErrorCode;
} /* End of InitializeUSB () */
-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf Of
Joel Winarske
Sent: Thursday, March 30, 2006 1:16 AM
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Not getting the Reset and Endpoint0 Interrupts
Hi Sarita,
> We are developing USB HID and Core Driver on Olimex LPC2148 board.
>
> The USB _ISR is getting invoked when the USB Cable is plugged out and
the
> interrupt DEV_STAT_INT is getting invoked.
>
> But when i connect the USB Cable, the Reset interrupt is not getting
> generated.
Reset triggers DEV_STAT_INT. You then need to query engine with
CMD_USB_GET_DEV_STAT cmd, as below:
// Device Status interrupt
if(UsbDevIntrSt.Status)
{
// Clear Device status interrupt
DEVINTCLR = bmUSB_DevStatusInterrupt;
// Get device status
USB_DevStatus.Data = USB_Cmd(CMD_USB_GET_DEV_STAT,0);
// Device connection status
if(USB_DevStatus.ConnectChange)
{
if(UsbUserFun[UsbConnectEvent] != NULL)
{
UsbUserFun[UsbConnectEvent]((void *)USB_DevStatus.Connect);
}
}
// Device suspend status
if(USB_DevStatus.SuspendChange)
{
if(UsbUserFun[UsbSuspendEvent] != NULL)
{
UsbUserFun[UsbSuspendEvent]((void *)USB_DevStatus.Suspend);
}
}
// Device reset
if(USB_DevStatus.Reset)
{
USB_HwReset();
if(UsbUserFun[UsbResetEvent] != NULL)
{
UsbUserFun[UsbResetEvent](NULL);
}
}
}
SPONSORED LINKS Microcontrollers Microprocessor Intel microprocessors
----------------------------------------------------------------------------
--
YAHOO! GROUPS LINKS
a.. Visit your group "lpc2000" on the web.
b.. To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
----------------------------------------------------------------------------
--
----------
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s)and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender or administrator@...
[Non-text portions of this message have been removed]Message
RE: [lpc2000] Not getting the Reset and Endpoint0 Interrupts
2006-03-30 by Saritha S
Attachments
- No local attachments were found for this message.