SIE USBDevIntClr

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SIE USBDevIntClr

3,000 Views
googcheng
Contributor I

i need to get device connect status. if i want to use USBDevIntClr variable in code with IAR , which file should i include ?

or could tell me how to build the example of the Read Current Frame Number command(lpc1343 user manual   page156)

Labels (3)
0 Kudos
Reply
14 Replies

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Before answering your question, I'd highly recommend you to explain the question in details.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

lpc1343 user manual   page156

 

USBDevIntClr = 0x30; // Clear both CCEMPTY & CDFULL
USBCmdCode = 0x00F50500; // CMD_CODE=0xF5, CMD_PHASE=0x05(Command)
while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.
USBDevIntClr = 0x10; // Clear CCEMPTY interrupt bit.
USBCmdCode = 0x00F50200; // CMD_CODE=0xF5, CMD_PHASE=0x02(Read)
while (!(USBDevIntSt & 0x20)); // Wait for CDFULL.
USBDevIntClr = 0x20; // Clear CDFULL.
CurFrameNum = USBCmdData; // Read Frame number LSB byte.
USBCmdCode = 0x00F50200; // CMD_CODE=0xF5, CMD_PHASE=0x02(Read)
while (!(USBDevIntSt & 0x20)); // Wait for CDFULL.
Temp = USBCmdData; // Read Frame number MSB byte
USBDevIntClr = 0x20; // Clear CDFULL interrupt bit.
CurFrameNum = CurFrameNum | (Temp << 8);

how to use the code snippet in a project 

0 Kudos
Reply

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thanks for your reply.

Please refer to USB demos in the sample code bundele and its downloading link is below.

Sample Code Bundle for LPC1311_13_42_43 Peripherals using Keil's MDK-ARM | www.LPCware.com
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

searching USBDevIntClr  against the entire workspace gets no result., so hope you could give me a hint.

im doing work related to dali  http://www.mouser.com/ds/2/302/nxp_OM13046_AN-795994.pdf   ,  it uses the rom_driver;

but different from usb_driver  in  LPC13xx_SampleSoftware.107   , i dont know how to call void WrCmd (uint32_t cmd) function in the dali project.     jeremyzhou     if possible, hope you could respond me in time because im in a little hurry

0 Kudos
Reply

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
It makes me a bit confused, what's exactly goal do you to achieve, please clarify it in details.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

how to detect the usb connect status at usb-hid mode for lpc1343 using usb rom driver?

0 Kudos
Reply

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi jay ch,
Unfortunately, the USB driver doesn't provide this kind of API, it needs you to add this feature by yourself.

Hope this is clear.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

how to do it , could you please give a hint about it ?  thanks

0 Kudos
Reply

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

In USBHid demo of Sample Code Bundle for LPC1311_13_42_43 Peripherals using Keil's MDK-ARM | www.LPCware.com, it has illustrated how to do read the status, please refer to it for details.

/*
 *  Read Command Data
 *    Parameters:      cmd:   Command
 *    Return Value:    Data Value
 */

uint32_t RdCmdDat (uint32_t cmd) {

  LPC_USB->DevIntClr = CCEMTY_INT | CDFULL_INT;
  LPC_USB->CmdCode = cmd;
  while ((LPC_USB->DevIntSt & CDFULL_INT) == 0);
  return (LPC_USB->CmdData);
}



#define CMD_SET_DEV_STAT    0x00FE0500
#define CMD_GET_DEV_STAT    0x00FE0500
#define DAT_GET_DEV_STAT    0x00FE0200
#define CMD_GET_ERR_CODE    0x00FF0500
#define DAT_GET_ERR_CODE    0x00FF0200‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

im new to lpc ,  and   where is the LPC_USB?  include the USBDriver directory into my dali project then ok ?

0 Kudos
Reply

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
The LPC_USB is a structure which enables to user to read or write the register in USB module.

#define LPC_USB               ((LPC_USB_TypeDef    *) LPC_USB_BASE   )



/*------------- Universal Serial Bus (USB) -----------------------------------*/
/** @addtogroup LPC13xx_USB LPC13xx Universal Serial Bus 
  @{
*/
typedef struct
{
  __I  uint32_t DevIntSt;               /*!< Offset: 0x000 (R/ )  USB Device Interrupt Status Register */
  __IO uint32_t DevIntEn;               /*!< Offset: 0x004 (R/W)  USB Device Interrupt Enable Register */
  __O  uint32_t DevIntClr;              /*!< Offset: 0x008 ( /W)  USB Device Interrupt Clear Register */
  __O  uint32_t DevIntSet;              /*!< Offset: 0x00C ( /W)  USB Device Interrupt Set Register */

  __O  uint32_t CmdCode;                /*!< Offset: 0x010 ( /W)  USB Command Code Register */
  __I  uint32_t CmdData;                /*!< Offset: 0x014 (R/ )  USB Command Data Register */

  __I  uint32_t RxData;                 /*!< Offset: 0x018 (R/ )  USB Receive Data Register */
  __O  uint32_t TxData;                 /*!< Offset: 0x01C ( /W)  USB Transmit Data Register */
  __I  uint32_t RxPLen;                 /*!< Offset: 0x020 (R/ )  USB Receive Packet Length Register */
  __O  uint32_t TxPLen;                 /*!< Offset: 0x024 ( /W)  USB Transmit Packet Length Register */
  __IO uint32_t Ctrl;                   /*!< Offset: 0x028 (R/ )  USB Control Register */
  __O  uint32_t DevFIQSel;              /*!< Offset: 0x02C ( /W)  USB Device FIQ select Register */
} LPC_USB_TypeDef;
/*@}*/ /* end of group LPC13xx_USB */



#define LPC_USB_BASE          (LPC_APB0_BASE + 0x20000)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

Thanks a lot!

i have this code:

//#define CCEMTY_INT (0x1<<10)
//#define CDFULL_INT (0x1<<11)

#define DEV_STAT_CLR (0x1<<9)
#define CMD_GET_DEV_STAT 0x00FE0500
#define DAT_GET_DEV_STAT 0x00FE0200
uint32_t cmdcode = 0x00FE0500;


LPC_USB->DevIntClr = CCEMTY_INT | CDFULL_INT | DEV_STAT_CLR;
LPC_USB->CmdCode = cmdcode;
while ((LPC_USB->DevIntSt & CCEMTY_INT) == 0);
LPC_USB->DevIntClr = CCEMTY_INT;


cmdcode = 0x00FE0200;
LPC_USB->CmdCode = cmdcode;
while ((LPC_USB->DevIntSt & CDFULL_INT) == 0);

//LPC_USB->DevIntClr = CDFULL_INT;
uint32_t data = LPC_USB->CmdData;

i run above code in a loop within main function,   

but code waits here "while ((LPC_USB->DevIntSt & CDFULL_INT) == 0);" when pluging in the USB wire

should i put it   into   use interrupt handler?

0 Kudos
Reply

1,966 Views
jeremyzhou
NXP Employee
NXP Employee

Hi jay ch,
Actually, I don't think the interrupt way is the solution of the issue, maybe you need to dig much deeper into it
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,966 Views
googcheng
Contributor I

what are posssible causes? does it matter the hardware?

in USBDevIntEn CC_EMPTY_EN and CD_FULL_EN are 0s

this is the current USB setup:

void USB_Setup(void (*InReport)(), void (*OutReport)())
{
volatile int n;

HidDevInfo.idVendor = USB_VENDOR_ID;
HidDevInfo.idProduct = USB_PROD_ID;
HidDevInfo.bcdDevice = USB_DEVICE;
HidDevInfo.StrDescPtr = (uint32_t)&USB_StringDescriptor[0];
HidDevInfo.InReportCount = 2;
HidDevInfo.OutReportCount = 2;
HidDevInfo.SampleInterval = 0x20;
HidDevInfo.InReport = InReport;
HidDevInfo.OutReport = OutReport;

DeviceInfo.DevType = USB_DEVICE_CLASS_HUMAN_INTERFACE;
DeviceInfo.DevDetailPtr = (uint32_t)&HidDevInfo;

/* Use pll and pin init function in rom */
(*rom)->pUSBD->init_clk_pins();

/* insert a delay between clk init and usb init */
for (n = 0; n < 75; n++) {}

(*rom)->pUSBD->init(&DeviceInfo); /* USB Initialization */

(*rom)->pUSBD->connect(true); /* USB Connect */
}

LPC_SYSCON->SYSAHBCLKCTRL |= (EN_GPIO |
EN_TIMER32_0 |
EN_TIMER32_1 |
EN_USBREG |
EN_IOCON |
EN_UART);

0 Kudos
Reply