This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:projects:crazy_mouse [2010/03/14 14:41] – mikk.leini | en:projects:crazy_mouse [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 95: | Line 95: | ||
unsigned long ulAngle = 0; | unsigned long ulAngle = 0; | ||
char cDeltaX = 0, cDeltaY = 0; | char cDeltaX = 0, cDeltaY = 0; | ||
+ | |||
// | // | ||
- | | + | // Set the clocking to run from the PLL at 50MHz |
- | // | + | // |
- | SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | | + | SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | |
- | | + | SYSCTL_XTAL_8MHZ); |
- | + | ||
// | // | ||
// Drivers configuring. | // Drivers configuring. | ||
// | // | ||
DeviceConfigure(); | DeviceConfigure(); | ||
+ | |||
// | // | ||
- | | + | // Pass the USB library our device information, |
- | // controller and connect the device to the bus. | + | // controller and connect the device to the bus. |
- | // | + | |
- | USBDHIDMouseInit(0, | + | |
// | // | ||
- | // Enable processor interrupts. | + | USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)& |
- | // | + | |
- | IntMasterEnable(); | + | |
- | | + | // |
- | // Loop forever. | + | // Enable processor interrupts. |
- | // | + | // |
- | while (true) | + | IntMasterEnable(); |
- | { | + | |
+ | // | ||
+ | // Loop forever. | ||
+ | // | ||
+ | while (true) | ||
+ | { | ||
// | // | ||
// Device connected and ready ? | // Device connected and ready ? | ||
Line 132: | Line 132: | ||
// | // | ||
ulAngle += 0x1000000; | ulAngle += 0x1000000; | ||
+ | |||
// | // | ||
// Calculate X and Y movement. | // Calculate X and Y movement. | ||
Line 139: | Line 139: | ||
cDeltaX = sine(ulAngle) >> 14; | cDeltaX = sine(ulAngle) >> 14; | ||
cDeltaY = sine(ulAngle - 0x40000000) >> 14; | cDeltaY = sine(ulAngle - 0x40000000) >> 14; | ||
+ | |||
// | // | ||
// Keep a small break. | // Keep a small break. | ||
// | // | ||
DelayMS(5); | DelayMS(5); | ||
+ | |||
// | // | ||
// Update mouse state. | // Update mouse state. | ||
Line 150: | Line 150: | ||
USBDHIDMouseStateChange((void *)& | USBDHIDMouseStateChange((void *)& | ||
cDeltaX, | cDeltaX, | ||
- | (ButtonIsPressed() ? MOUSE_REPORT_BUTTON_1 : 0)); | + | (ButtonIsPressed() ? MOUSE_REPORT_BUTTON_1 : 0)); |
} | } | ||
- | | + | } |
} | } | ||
</ | </ |