diff options
Diffstat (limited to 'LUFA/Drivers/USB/Core/AVR8')
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 92 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | 70 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c | 29 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c | 8 |
10 files changed, 37 insertions, 180 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index 9899251ee..b5dc7e439 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -132,8 +132,8 @@ * \note This macro should only be used if the device has indicated to the host that it * supports the Remote Wakeup feature in the device descriptors, and should only be * issued if the host is currently allowing remote wakeup events from the device (i.e., - * the \ref USB_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP compile - * time option is used, this macro is unavailable. + * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP + * compile time option is used, this macro is unavailable. * \n\n * * \note The USB clock must be running for this function to operate. If the stack is initialized with diff --git a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c index 2ec49a5d5..6d4df036b 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c @@ -36,7 +36,7 @@ #include "../Endpoint.h" #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) -uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; +uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; #endif bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, diff --git a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h index 7868ac36a..8611dd638 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h @@ -846,9 +846,9 @@ * changed in value. */ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) - extern uint8_t USB_ControlEndpointSize; + extern uint8_t USB_Device_ControlEndpointSize; #else - #define USB_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE + #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE #endif /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c index 5f475a1cc..55cd8f991 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -137,7 +137,7 @@ void USB_Host_ProcessNextHostState(void) break; } - USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; + USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; USB_Host_ResetDevice(); @@ -146,7 +146,7 @@ void USB_Host_ProcessNextHostState(void) case HOST_STATE_Default_PostReset: Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP, - USB_ControlPipeSize, PIPE_BANK_SINGLE); + USB_Host_ControlPipeSize, PIPE_BANK_SINGLE); if (!(Pipe_IsConfigured())) { @@ -175,8 +175,9 @@ void USB_Host_ProcessNextHostState(void) case HOST_STATE_Default_PostAddressSet: USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS); - EVENT_USB_Host_DeviceEnumerationComplete(); USB_HostState = HOST_STATE_Addressed; + + EVENT_USB_Host_DeviceEnumerationComplete(); break; } @@ -253,6 +254,8 @@ static void USB_Host_ResetDevice(void) USB_Host_ResetBus(); while (!(USB_Host_IsBusResetComplete())); USB_Host_ResumeBus(); + + USB_Host_ConfigurationNumber = 0; bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); @@ -285,88 +288,5 @@ static void USB_Host_ResetDevice(void) USB_INT_Enable(USB_INT_DDISCI); } -uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_SetConfiguration, - .wValue = ConfigNumber, - .wIndex = 0, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(NULL); -} - -uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr) -{ - 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), - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(DeviceDescriptorPtr); -} - -uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, - void* const Buffer, - const uint8_t BufferLength) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_GetDescriptor, - .wValue = (DTYPE_String << 8) | Index, - .wIndex = 0, - .wLength = BufferLength, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(Buffer); -} - -uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT), - .bRequest = REQ_ClearFeature, - .wValue = FEATURE_SEL_EndpointHalt, - .wIndex = EndpointNum, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(NULL); -} - -uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, - const uint8_t AltSetting) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), - .bRequest = REQ_SetInterface, - .wValue = AltSetting, - .wIndex = InterfaceIndex, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(NULL); -} - #endif diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h index 6854128d3..1b34801d4 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h @@ -207,6 +207,9 @@ /** Suspends the USB bus, preventing any communications from occurring between the host and attached * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame * messages to the device. + * + * \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that + * some events (such as device disconnections) will not fire until the bus is resumed. */ static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE; static inline void USB_Host_SuspendBus(void) @@ -276,73 +279,6 @@ return ((UHCON & (1 << RESUME)) ? false : true); } - /* Function Prototypes: */ - /** Convenience function. This routine sends a SET CONFIGURATION standard request to the attached - * device, with the given configuration index. This can be used to easily set the device - * configuration without creating and sending the request manually. - * - * \note After this routine returns, the control pipe will be selected. - * - * \param[in] ConfigNumber Configuration index to send to the device. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber); - - /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached - * device, requesting the device descriptor. This can be used to easily retrieve information - * about the device such as its VID, PID and power requirements. - * - * \note After this routine returns, the control pipe will be selected. - * - * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where - * the read data is to be stored. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr); - - /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached - * device, requesting the string descriptor of the specified index. This can be used to easily - * retrieve string descriptors from the device by index, after the index is obtained from the - * Device or Configuration descriptors. - * - * \note After this routine returns, the control pipe will be selected. - * - * \param[in] Index Index of the string index to retrieve. - * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is - * to be stored. - * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, - void* const Buffer, - const uint8_t BufferLength); - - /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device. - * - * \note After this routine returns, the control pipe will be selected. - * - * \param[in] EndpointIndex Index of the endpoint to clear, including the endpoint's direction. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex); - - /** Selects a given alternative setting for the specified interface, via a SET INTERFACE standard request to - * the attached device. - * - * \note After this routine returns, the control pipe will be selected. - * - * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. - * \param[in] AltSetting Index of the interface's alternative setting which is to be selected. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, - const uint8_t AltSetting); - /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ diff --git a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c index e93b256c6..5d7c8ac1b 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c @@ -35,7 +35,7 @@ #include "../Pipe.h" -uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; +uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; bool Pipe_ConfigurePipe(const uint8_t Number, const uint8_t Type, diff --git a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h index 1939d3906..efe0ef1ba 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h @@ -804,7 +804,7 @@ * \note This variable should be treated as read-only in the user application, and never manually * changed in value. */ - extern uint8_t USB_ControlPipeSize; + extern uint8_t USB_Host_ControlPipeSize; /* Function Prototypes: */ /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the diff --git a/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c index 1d6361fb8..5d4fc42f2 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c +++ b/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c @@ -58,7 +58,7 @@ uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, { uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); - while (Length && (BytesInEndpoint < USB_ControlEndpointSize)) + while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) { TEMPLATE_TRANSFER_BYTE(DataStream); TEMPLATE_BUFFER_MOVE(DataStream, 1); @@ -66,7 +66,7 @@ uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, BytesInEndpoint++; } - LastPacketFull = (BytesInEndpoint == USB_ControlEndpointSize); + LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); Endpoint_ClearIN(); } } diff --git a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c index 4802463f0..571ab6c8a 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c @@ -178,15 +178,15 @@ void USB_ResetInterface(void) #if defined(USB_CAN_BE_DEVICE) static void USB_Init_Device(void) { - USB_DeviceState = DEVICE_STATE_Unattached; - USB_ConfigurationNumber = 0; + USB_DeviceState = DEVICE_STATE_Unattached; + USB_Device_ConfigurationNumber = 0; #if !defined(NO_DEVICE_REMOTE_WAKEUP) - USB_RemoteWakeupEnabled = false; + USB_Device_RemoteWakeupEnabled = false; #endif #if !defined(NO_DEVICE_SELF_POWER) - USB_CurrentlySelfPowered = false; + USB_Device_CurrentlySelfPowered = false; #endif #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) @@ -199,21 +199,21 @@ static void USB_Init_Device(void) if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR) { if (DescriptorAddressSpace == MEMSPACE_FLASH) - USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); else if (DescriptorAddressSpace == MEMSPACE_EEPROM) - USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); else - USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; } #else if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) { #if defined(USE_RAM_DESCRIPTORS) - USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; #elif defined(USE_EEPROM_DESCRIPTORS) - USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); #else - USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); #endif } #endif @@ -229,7 +229,7 @@ static void USB_Init_Device(void) #endif Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, - ENDPOINT_DIR_OUT, USB_ControlEndpointSize, + ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, ENDPOINT_BANK_SINGLE); USB_INT_Clear(USB_INT_SUSPI); @@ -243,8 +243,9 @@ static void USB_Init_Device(void) #if defined(USB_CAN_BE_HOST) static void USB_Init_Host(void) { - USB_HostState = HOST_STATE_Unattached; - USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + USB_HostState = HOST_STATE_Unattached; + USB_Host_ConfigurationNumber = 0; + USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; USB_Host_HostMode_On(); @@ -254,7 +255,7 @@ static void USB_Init_Host(void) USB_INT_Enable(USB_INT_SRPI); USB_INT_Enable(USB_INT_BCERRI); - + USB_Attach(); } #endif diff --git a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c index 4939ec2ed..328017ef3 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c @@ -144,7 +144,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) USB_INT_Disable(USB_INT_WAKEUPI); USB_INT_Enable(USB_INT_SUSPI); - if (USB_ConfigurationNumber) + if (USB_Device_ConfigurationNumber) USB_DeviceState = DEVICE_STATE_Configured; else USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; @@ -160,15 +160,15 @@ ISR(USB_GEN_vect, ISR_BLOCK) { USB_INT_Clear(USB_INT_EORSTI); - USB_DeviceState = DEVICE_STATE_Default; - USB_ConfigurationNumber = 0; + USB_DeviceState = DEVICE_STATE_Default; + USB_Device_ConfigurationNumber = 0; USB_INT_Clear(USB_INT_SUSPI); USB_INT_Disable(USB_INT_SUSPI); USB_INT_Enable(USB_INT_WAKEUPI); Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, - ENDPOINT_DIR_OUT, USB_ControlEndpointSize, + ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, ENDPOINT_BANK_SINGLE); #if defined(INTERRUPT_CONTROL_ENDPOINT) |