diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-07-13 05:34:43 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-07-13 05:34:43 +0000 |
commit | 0fcbe22c9eb68f5769bf57469e1bcf9b340d0ae3 (patch) | |
tree | 3c9c1613def7ed9c299d197c9a97fe7622eb987d /Demos/Host/LowLevel/MassStorageHost | |
parent | a54ed0085b29f81946f3652bd412103292da7589 (diff) | |
download | lufa-0fcbe22c9eb68f5769bf57469e1bcf9b340d0ae3.tar.gz lufa-0fcbe22c9eb68f5769bf57469e1bcf9b340d0ae3.tar.bz2 lufa-0fcbe22c9eb68f5769bf57469e1bcf9b340d0ae3.zip |
Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking disabling of device communications until the device has been removed (for use when an error occurs or communications with the device have completed). Changed over all host mode demos to use the new state.
Added verbose documentation for each of the USB Host state machine states.
Diffstat (limited to 'Demos/Host/LowLevel/MassStorageHost')
-rw-r--r-- | Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c index 2f84d0fb8..1bb94f6c8 100644 --- a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c @@ -154,7 +154,7 @@ void MassStorage_Task(void) LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -168,7 +168,7 @@ void MassStorage_Task(void) LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -187,6 +187,8 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_GetMaxLUN(&MassStore_MaxLUNIndex)) != HOST_SENDCONTROL_Successful)
{
ShowDiskReadError(PSTR("Get Max LUN"), false, ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -197,6 +199,8 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_MassStorageReset()) != HOST_SENDCONTROL_Successful)
{
ShowDiskReadError(PSTR("Mass Storage Reset"), false, ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -213,6 +217,8 @@ void MassStorage_Task(void) if (((ErrorCode = MassStore_PreventAllowMediumRemoval(0, true)) != 0) || (SCSICommandStatus.Status != Command_Pass))
{
ShowDiskReadError(PSTR("Prevent/Allow Medium Removal"), (SCSICommandStatus.Status != Command_Pass), ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -221,6 +227,8 @@ void MassStorage_Task(void) if (((ErrorCode = MassStore_Inquiry(0, &InquiryData)) != 0) || (SCSICommandStatus.Status != Command_Pass))
{
ShowDiskReadError(PSTR("Inquiry"), (SCSICommandStatus.Status != Command_Pass), ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -237,7 +245,9 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_TestUnitReady(0)) != 0)
{
ShowDiskReadError(PSTR("Test Unit Ready"), false, ErrorCode);
- break;
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
}
}
while ((SCSICommandStatus.Status != Command_Pass) && USB_IsConnected);
@@ -255,6 +265,8 @@ void MassStorage_Task(void) if (((ErrorCode = MassStore_ReadCapacity(0, &DiskCapacity)) != 0) || (SCSICommandStatus.Status != Command_Pass))
{
ShowDiskReadError(PSTR("Read Capacity"), (SCSICommandStatus.Status != Command_Pass), ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -269,6 +281,8 @@ void MassStorage_Task(void) (SCSICommandStatus.Status != Command_Pass))
{
ShowDiskReadError(PSTR("Read Device Block"), (SCSICommandStatus.Status != Command_Pass), ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -319,6 +333,8 @@ void MassStorage_Task(void) (SCSICommandStatus.Status != Command_Pass))
{
ShowDiskReadError(PSTR("Read Device Block"), (SCSICommandStatus.Status != Command_Pass), ErrorCode);
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -339,8 +355,7 @@ void MassStorage_Task(void) LEDs_SetAllLEDs(LEDMASK_USB_READY);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
-
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
}
@@ -372,7 +387,4 @@ void ShowDiskReadError(char* CommandString, bool FailedAtSCSILayer, uint8_t Erro /* Indicate device error via the status LEDs */
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-
- /* Wait until USB device disconnected */
- while (USB_IsConnected);
}
|