User manual

LPCXpresso Experiment Kit - User’s Guide
Page 127
Copyright 2013 © Embedded Artists AB
if (i == 4 || i == 5) LPC_GPIO2->FIOPIN &= ~led_mask[i];
else LPC_GPIO0->FIOPIN &= ~led_mask[i];
} else {
if (i == 4 || i == 5) LPC_GPIO2->FIOPIN |= led_mask[i];
else LPC_GPIO0->FIOPIN |= led_mask[i];
}
}
}
Modify the program to use the 7-segment display to show the hexadecimal value from the PC
application. Modify the program to read the state of the quadrature encoder to change the value sent to
the PC instead of using buttons.
7.18.2 Lab 17b: USB Device Mouse HID
This experiment uses the USB HID class but this time the USB device will act as a computer mouse.
The buttons on the experiment board will control the mouse pointer on the PC.
This experiment is based on the code examples that are delivered with the LPCXpresso IDE. The code
is structured very differently (none of the code from the previous exercises is used). You have to create
a new workspace in LPCXpresso and then import the projects from Lab17b.zip.
When using the USB Device interface a USB B to USB A cable is needed (not included in the kit).
Connect it to the J9 connector on the experiment board and to the PC.
Compile and run the program. Your board should appear as a HID-compatible mouse on the PC when
the driver installation has completed.
Use the buttons on the experiment board to move the mouse pointer. The middle button (SW3) acts as
a left-click on the mouse.
As seen it is not possible to select text or to move the mouse pointer diagonally. This is because the
following code in main_mouse.c only allows one button at a time.
The reading/writing of values are done in these two functions in main_mouse.c:
if(i_JoystickState & JOYSTICK_UP) {
MouseInputReport.bY = -10;
MouseInputReport.bX = 0;
MouseInputReport.bmButtons = 0;
}
else if((i_JoystickState & JOYSTICK_DOWN)) {
MouseInputReport.bY = 10;
MouseInputReport.bX = 0;
MouseInputReport.bmButtons = 0;
}
else if((i_JoystickState & JOYSTICK_LEFT)) {
MouseInputReport.bX = -10;
MouseInputReport.bY = 0;
MouseInputReport.bmButtons = 0;
}
else if((i_JoystickState & JOYSTICK_RIGHT)) {
MouseInputReport.bX = 10;
MouseInputReport.bY = 0;
MouseInputReport.bmButtons = 0;
}
else if((i_JoystickState & JOYSTICK_CLICK)) {
MouseInputReport.bX = 0;
MouseInputReport.bY = 0;
MouseInputReport.bmButtons = 1;
}
else {
MouseInputReport.bX = 0;
MouseInputReport.bY = 0;
MouseInputReport.bmButtons = 0;
}
Fix the code and verify that the mouse pointer can be moved diagonally and that text selection works.