[ARM] LPC1343 USB HID Example automatically sends data to PC?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hello!! Everyone
I am new in the filed of Cortex-M3 and using LPC1343 micro-controller for my project, which also requires a USB HID.
I found USB HID demo in Keil Example folders and by using the USB Stack i created my project, which is exactly similar to example project provided by Keil.

I have to send some data from LPC1343 to PC and from PC to LPC1343, for Sending data from LPC1343->PC In Endpoints are used and for PC->LPC1343 OUT Endpoints are used.

The main Code is as follow:-

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// HID Input Report
u8_t InReport;
// HID Output Report
u8_t OutReport;
 
 // Get HID Input Report -> InReport
void GetInReport (void)
{
  InReport = 0x01;
        return;
}
 
 
// Set HID Output Report <- OutReport
void SetOutReport (void)
{
  if(OutReport == 0x01)
        {
                LPC_GPIO1->DATA &= ~(1<<GreenLED);
        }
        else if(OutReport == 0x02)
        {
                LPC_GPIO1->DATA &= ~(1<<BlueLED);
        }
        else
        {
                LPC_GPIO1->DATA |= (1<<GreenLED);
                LPC_GPIO1->DATA |= (1<<BlueLED);
        }
  return;
}
 
int main()
{
        InitializeSystem();
        USBIOClkConfig();
        // GPIO's Power is enabled by default
        // Set Pins as Output pins.
        LPC_GPIO1->DIR |= (1<<GreenLED);
        LPC_GPIO1->DIR |= (1<<BlueLED);
        // USB Initialzation
        USB_Init();
        // USB Connect
        USB_Connect(TRUE);
        while(1)
        {
    // Do Nothing
        }
}



But as per this code, LPC1343 is sending data continuously to PC, i tried to find the reason behind this, and i found this code in usbuser.c file

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 *  USB Endpoint 1 Event Callback
 *   Called automatically on USB Endpoint 1 Event
 *    Parameter:       event
 */
 
void USB_EndPoint1 (uint32_t event) {
 
  switch (event) {
    case USB_EVT_IN:
      GetInReport();
      USB_WriteEP(HID_EP_IN, &InReport, sizeof(InReport));
      break;
  }
}



I think this code is automatically called after some time and due to this i am getting data on PC
Can any one tell me, how can i send data to PC only at specific changes, not continuously.

Call this function, whenever i need to send some data will do my work ( my assumption, haven't tried this), is it right method to do so
USB_WriteEP(HID_EP_IN, &InReport, sizeof(InReport));
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…