projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ooops - TeensyHID bootloader makefile should use a 16MHz FCPU, not 8MHz.
[pub/USBasp.git]
/
Demos
/
Device
/
LowLevel
/
Mouse
/
Mouse.c
diff --git
a/Demos/Device/LowLevel/Mouse/Mouse.c
b/Demos/Device/LowLevel/Mouse/Mouse.c
index
d15f688
..
ff54c65
100644
(file)
--- a/
Demos/Device/LowLevel/Mouse/Mouse.c
+++ b/
Demos/Device/LowLevel/Mouse/Mouse.c
@@
-36,7
+36,6
@@
\r
#include "Mouse.h"
\r
\r
\r
#include "Mouse.h"
\r
\r
-/* Global Variables */
\r
/** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
\r
* protocol reporting mode.
\r
*/
\r
/** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
\r
* protocol reporting mode.
\r
*/
\r
@@
-55,7
+54,7
@@
uint16_t IdleMSRemaining = 0;
\r
\r
/** Main program entry point. This routine configures the hardware required by the application, then
\r
\r
\r
/** Main program entry point. This routine configures the hardware required by the application, then
\r
- *
starts the scheduler to run the application tasks
.
\r
+ *
enters a loop to run the application tasks in sequence
.
\r
*/
\r
int main(void)
\r
{
\r
*/
\r
int main(void)
\r
{
\r
@@
-85,18
+84,12
@@
void SetupHardware(void)
LEDs_Init();
\r
Buttons_Init();
\r
USB_Init();
\r
LEDs_Init();
\r
Buttons_Init();
\r
USB_Init();
\r
-
\r
- /* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */
\r
- OCR0A = 0x7D;
\r
- TCCR0A = (1 << WGM01);
\r
- TCCR0B = ((1 << CS01) | (1 << CS00));
\r
- TIMSK0 = (1 << OCIE0A);
\r
}
\r
\r
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and
\r
* starts the library USB task to begin the enumeration and USB management process.
\r
*/
\r
}
\r
\r
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and
\r
* starts the library USB task to begin the enumeration and USB management process.
\r
*/
\r
-void EVENT_USB_Connect(void)
\r
+void EVENT_USB_
Device_
Connect(void)
\r
{
\r
/* Indicate USB enumerating */
\r
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
\r
{
\r
/* Indicate USB enumerating */
\r
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
\r
@@
-108,7
+101,7
@@
void EVENT_USB_Connect(void)
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
\r
* the status LEDs and stops the USB management and Mouse reporting tasks.
\r
*/
\r
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
\r
* the status LEDs and stops the USB management and Mouse reporting tasks.
\r
*/
\r
-void EVENT_USB_Disconnect(void)
\r
+void EVENT_USB_D
evice_D
isconnect(void)
\r
{
\r
/* Indicate USB not ready */
\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
\r
{
\r
/* Indicate USB not ready */
\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
\r
@@
-117,7
+110,7
@@
void EVENT_USB_Disconnect(void)
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration
\r
* of the USB device after enumeration - the device endpoints are configured and the mouse reporting task started.
\r
*/
\r
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration
\r
* of the USB device after enumeration - the device endpoints are configured and the mouse reporting task started.
\r
*/
\r
-void EVENT_USB_ConfigurationChanged(void)
\r
+void EVENT_USB_
Device_
ConfigurationChanged(void)
\r
{
\r
/* Indicate USB connected and ready */
\r
LEDs_SetAllLEDs(LEDMASK_USB_READY);
\r
{
\r
/* Indicate USB connected and ready */
\r
LEDs_SetAllLEDs(LEDMASK_USB_READY);
\r
@@
-129,13
+122,15
@@
void EVENT_USB_ConfigurationChanged(void)
{
\r
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
\r
}
\r
{
\r
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
\r
}
\r
+
\r
+ USB_Device_EnableSOFEvents();
\r
}
\r
\r
}
\r
\r
-/** Event handler for the USB_UnhandledControl
Packe
t event. This is used to catch standard and class specific
\r
+/** Event handler for the USB_UnhandledControl
Reques
t event. This is used to catch standard and class specific
\r
* control requests that are not handled internally by the USB library (including the HID commands, which are
\r
* all issued via the control endpoint), so that they can be handled appropriately for the application.
\r
*/
\r
* control requests that are not handled internally by the USB library (including the HID commands, which are
\r
* all issued via the control endpoint), so that they can be handled appropriately for the application.
\r
*/
\r
-void EVENT_USB_
UnhandledControlPacke
t(void)
\r
+void EVENT_USB_
Device_UnhandledControlReques
t(void)
\r
{
\r
/* Handle HID Class specific requests */
\r
switch (USB_ControlRequest.bRequest)
\r
{
\r
/* Handle HID Class specific requests */
\r
switch (USB_ControlRequest.bRequest)
\r
@@
-218,10
+213,8
@@
void EVENT_USB_UnhandledControlPacket(void)
}
\r
}
\r
\r
}
\r
}
\r
\r
-/** ISR for the timer 0 compare vector. This ISR fires once each millisecond, and increments the
\r
- * scheduler elapsed idle period counter when the host has set an idle period.
\r
- */
\r
-ISR(TIMER0_COMPA_vect, ISR_BLOCK)
\r
+/** Event handler for the USB device Start Of Frame event. */
\r
+void EVENT_USB_Device_StartOfFrame(void)
\r
{
\r
/* One millisecond has elapsed, decrement the idle time remaining counter if it has not already elapsed */
\r
if (IdleMSRemaining)
\r
{
\r
/* One millisecond has elapsed, decrement the idle time remaining counter if it has not already elapsed */
\r
if (IdleMSRemaining)
\r
@@
-245,10
+238,10
@@
void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
else if (JoyStatus_LCL & JOY_DOWN)
\r
ReportData->Y = 1;
\r
\r
else if (JoyStatus_LCL & JOY_DOWN)
\r
ReportData->Y = 1;
\r
\r
- if (JoyStatus_LCL & JOY_RIGHT)
\r
- ReportData->X = 1;
\r
- else if (JoyStatus_LCL & JOY_LEFT)
\r
+ if (JoyStatus_LCL & JOY_LEFT)
\r
ReportData->X = -1;
\r
ReportData->X = -1;
\r
+ else if (JoyStatus_LCL & JOY_RIGHT)
\r
+ ReportData->X = 1;
\r
\r
if (JoyStatus_LCL & JOY_PRESS)
\r
ReportData->Button = (1 << 0);
\r
\r
if (JoyStatus_LCL & JOY_PRESS)
\r
ReportData->Button = (1 << 0);
\r
@@
-275,9
+268,6
@@
void SendNextReport(void)
if ((MouseReportData.Y != 0) || (MouseReportData.X != 0))
\r
SendReport = true;
\r
\r
if ((MouseReportData.Y != 0) || (MouseReportData.X != 0))
\r
SendReport = true;
\r
\r
- /* Save the current report data for later comparison to check for changes */
\r
- PrevMouseReportData = MouseReportData;
\r
-
\r
/* Check if the idle period is set and has elapsed */
\r
if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining)))
\r
{
\r
/* Check if the idle period is set and has elapsed */
\r
if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining)))
\r
{
\r
@@
-293,7
+283,10
@@
void SendNextReport(void)
\r
/* Check if Mouse Endpoint Ready for Read/Write and if we should send a new report */
\r
if (Endpoint_IsReadWriteAllowed() && SendReport)
\r
\r
/* Check if Mouse Endpoint Ready for Read/Write and if we should send a new report */
\r
if (Endpoint_IsReadWriteAllowed() && SendReport)
\r
- {
\r
+ {
\r
+ /* Save the current report data for later comparison to check for changes */
\r
+ PrevMouseReportData = MouseReportData;
\r
+
\r
/* Write Mouse Report Data */
\r
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
\r
\r
/* Write Mouse Report Data */
\r
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
\r
\r