Added new GenericHIDHost demo.

Corrections to the KeyboardHost and MouseHost demos' pipe handling to freeze and unfreeze the data pipes at the point of use.
This commit is contained in:
Dean Camera 2009-04-01 07:21:45 +00:00
parent 74496a947e
commit 6198289b38
19 changed files with 3064 additions and 31 deletions

View file

@ -98,8 +98,6 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Enable the pipe IN interrupt for the data pipe */
USB_INT_Enable(PIPE_INT_IN);
#endif
Pipe_Unfreeze();
/* Valid data found, return success */
return SuccessfulConfigRead;

View file

@ -184,12 +184,24 @@ void ReadNextReport(void)
USB_MouseReport_Data_t MouseReport;
uint8_t LEDMask = LEDS_NO_LEDS;
/* Select the mouse report data in pipe */
Pipe_SelectPipe(MOUSE_DATAPIPE);
/* Select mouse data pipe */
Pipe_SelectPipe(MOUSE_DATAPIPE);
#if !defined(INTERRUPT_DATA_PIPE)
/* Unfreeze mouse data pipe */
Pipe_Unfreeze();
#endif
/* Ensure pipe contains data and is ready to be read before continuing */
if (!(Pipe_ReadWriteAllowed()))
return;
{
#if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze mouse data pipe */
Pipe_Freeze();
#endif
return;
}
/* Read in mouse report data */
Pipe_Read_Stream_LE(&MouseReport, sizeof(MouseReport));
@ -219,6 +231,11 @@ void ReadNextReport(void)
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
MouseReport.Y,
MouseReport.Button);
#if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze mouse data pipe */
Pipe_Freeze();
#endif
}
/** Task to set the configuration of the attached device after it has been enumerated, and to read and process
@ -303,22 +320,21 @@ TASK(USB_Mouse_Host)
break;
}
#if defined(INTERRUPT_DATA_PIPE)
/* Select and unfreeze mouse data pipe */
Pipe_SelectPipe(MOUSE_DATAPIPE);
Pipe_Unfreeze();
#endif
puts_P(PSTR("Mouse Enumerated.\r\n"));
USB_HostState = HOST_STATE_Ready;
break;
#if !defined(INTERRUPT_DATA_PIPE)
case HOST_STATE_Ready:
/* Select and unfreeze mouse data pipe */
Pipe_SelectPipe(MOUSE_DATAPIPE);
Pipe_Unfreeze();
/* If a report has been received, read and process it */
if (Pipe_ReadWriteAllowed())
ReadNextReport();
ReadNextReport();
/* Freeze mouse data pipe */
Pipe_Freeze();
break;
#endif
}