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/Incomplete | |
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/Incomplete')
-rw-r--r-- | Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c | 13 | ||||
-rw-r--r-- | Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c | 17 | ||||
-rw-r--r-- | Demos/Host/Incomplete/PrinterHost/PrinterHost.c | 12 |
3 files changed, 10 insertions, 32 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c index b8e87cb60..3222b770e 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c @@ -139,14 +139,11 @@ void Bluetooth_Management_Task(void) LEDs_SetAllLEDs(LEDS_LED1);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
puts_P(PSTR("Bluetooth Dongle Detected.\r\n"));
-
- /* Select the control pipe for the request transfer */
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
/* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
@@ -158,7 +155,7 @@ void Bluetooth_Management_Task(void) LEDs_SetAllLEDs(LEDS_LED1);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -181,7 +178,7 @@ void Bluetooth_Management_Task(void) LEDs_SetAllLEDs(LEDS_LED1);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -189,9 +186,5 @@ void Bluetooth_Management_Task(void) USB_HostState = HOST_STATE_Ready;
break;
- case HOST_STATE_Ready:
- /* Do nothing, Bluetooth stack will take care of enumeration */
-
- break;
}
}
diff --git a/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c b/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c index e9f575c55..f68f957c0 100644 --- a/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c +++ b/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c @@ -34,28 +34,15 @@ uint8_t ProcessDeviceDescriptor(void) {
USB_Descriptor_Device_t DeviceDescriptor;
- /* Standard request to get the device descriptor */
- USB_ControlRequest = (USB_Request_Header_t)
- {
- bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- bRequest: REQ_GetDescriptor,
- wValue: (DTYPE_Device << 8),
- wIndex: 0,
- wLength: sizeof(USB_Descriptor_Device_t),
- };
-
- /* Select the control pipe for the request transfer */
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
/* Send the request to retrieve the device descriptor */
- if (USB_Host_SendControlRequest((void*)&DeviceDescriptor) != HOST_SENDCONTROL_Successful)
+ if (USB_Host_GetDeviceDescriptor(&DeviceDescriptor) != HOST_SENDCONTROL_Successful)
return ControlErrorDuringDeviceRead;
/* Validate returned data - ensure the returned data is a device descriptor */
if (DeviceDescriptor.Header.Type != DTYPE_Device)
return InvalidDeviceDataReturned;
- if ((DeviceDescriptor.Class != BLUETOOTH_DEVICE_CLASS) ||
+ if ((DeviceDescriptor.Class != BLUETOOTH_DEVICE_CLASS) ||
(DeviceDescriptor.SubClass != BLUETOOTH_DEVICE_SUBCLASS) ||
(DeviceDescriptor.Protocol != BLUETOOTH_DEVICE_PROTOCOL))
{
diff --git a/Demos/Host/Incomplete/PrinterHost/PrinterHost.c b/Demos/Host/Incomplete/PrinterHost/PrinterHost.c index df80789dd..7b98542d0 100644 --- a/Demos/Host/Incomplete/PrinterHost/PrinterHost.c +++ b/Demos/Host/Incomplete/PrinterHost/PrinterHost.c @@ -133,7 +133,7 @@ void USB_Printer_Host(void) LEDs_SetAllLEDs(LEDS_LED1);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -147,7 +147,7 @@ void USB_Printer_Host(void) LEDs_SetAllLEDs(LEDS_LED1);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -173,7 +173,7 @@ void USB_Printer_Host(void) LEDs_SetAllLEDs(LEDS_LED1);
/* Wait until USB device disconnected */
- while (USB_IsConnected);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
@@ -181,10 +181,8 @@ void USB_Printer_Host(void) /* Indicate device no longer busy */
LEDs_SetAllLEDs(LEDS_LED4);
-
- /* Wait until USB device disconnected */
- while (USB_IsConnected);
-
+
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
}
|