aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-09-05 07:11:53 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-09-05 07:11:53 +0000
commit18cbd31605dae070f00900161090a72d3eb0f8ab (patch)
tree1166a9c1b27630111d337b76a0eee1292b0d633b /Demos/Host
parent0174d8ea70f3d7180e6ea3da2b3720273adb33d9 (diff)
downloadlufa-18cbd31605dae070f00900161090a72d3eb0f8ab.tar.gz
lufa-18cbd31605dae070f00900161090a72d3eb0f8ab.tar.bz2
lufa-18cbd31605dae070f00900161090a72d3eb0f8ab.zip
Added new USB_Device_GetFrameNumber() and USB_Host_GetFrameNumber() functions to retrieve the current USB frame number.
Added new USB_Host_EnableSOFEvents(), USB_Host_DisableSOFEvents() and EVENT_USB_Host_StartOfFrame() for the user application handling of USB Start of Frame events while in USB Host mode. Changed over all demos, drivers and internal functions to use the current frame number over the Start of Frame flag where possible to free up the Start of Frame flag for interrupt use in the user application.
Diffstat (limited to 'Demos/Host')
-rw-r--r--Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c13
-rw-r--r--Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c18
2 files changed, 17 insertions, 14 deletions
diff --git a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c
index 0d8a231f2..c86e51b0c 100644
--- a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c
+++ b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c
@@ -110,20 +110,23 @@ static uint8_t MassStore_SendCommand(CommandBlockWrapper_t* const SCSICommandBlo
*/
static uint8_t MassStore_WaitForDataReceived(void)
{
- uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
+ uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
/* Select the IN data pipe for data reception */
Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE);
Pipe_Unfreeze();
-
+
/* Wait until data received in the IN pipe */
while (!(Pipe_IsINReceived()))
{
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
+
/* Check to see if a new frame has been issued (1ms elapsed) */
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ if (CurrentFrameNumber != PreviousFrameNumber)
{
- /* Clear the flag and decrement the timeout period counter */
- USB_INT_Clear(USB_INT_HSOFI);
+ /* Save the new frame number and decrement the timeout period */
+ PreviousFrameNumber = CurrentFrameNumber;
TimeoutMSRem--;
/* Check to see if the timeout period for the command has elapsed */
diff --git a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c
index a99a95680..861f55b5d 100644
--- a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c
+++ b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c
@@ -108,28 +108,28 @@ uint8_t SImage_ReceiveEventHeader(void)
*/
uint8_t SImage_ReceiveBlockHeader(void)
{
- uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
+ uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
/* Unfreeze the data IN pipe */
Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE);
Pipe_Unfreeze();
/* Wait until data received on the IN pipe */
- while (!(Pipe_IsReadWriteAllowed()))
+ while (!(Pipe_IsINReceived()))
{
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
+
/* Check to see if a new frame has been issued (1ms elapsed) */
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ if (CurrentFrameNumber != PreviousFrameNumber)
{
- /* Clear the flag and decrement the timeout period counter */
- USB_INT_Clear(USB_INT_HSOFI);
+ /* Save the new frame number and decrement the timeout period */
+ PreviousFrameNumber = CurrentFrameNumber;
TimeoutMSRem--;
/* Check to see if the timeout period for the command has elapsed */
if (!(TimeoutMSRem))
- {
- /* Return error code */
- return PIPE_RWSTREAM_Timeout;
- }
+ return PIPE_RWSTREAM_Timeout;
}
Pipe_Freeze();