Slight changes to TeensyHID bootloader to ensure it builds under the 2KB boundary.

Changed USB_Init() and USB_Shutdown() so that they are no longer dependant on oneanother for possible code savings when the interface is never explicitly shut down.
pull/1469/head
Dean Camera 16 years ago
parent e071f3897a
commit 7a5d045987

@ -55,9 +55,6 @@ int main(void)
while (RunBootloader) while (RunBootloader)
USB_USBTask(); USB_USBTask();
/* Reset all configured hardware to their default states for the user app */
ResetHardware();
/* Wait 100ms to give the host time to register the disconnection */ /* Wait 100ms to give the host time to register the disconnection */
_delay_ms(100); _delay_ms(100);
@ -85,13 +82,6 @@ void SetupHardware(void)
USB_Init(); USB_Init();
} }
/** Resets all configured hardware required for the bootloader back to their original states. */
void ResetHardware(void)
{
/* Shut down the USB subsystem */
USB_ShutDown();
}
/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
* to relay data to and from the attached USB host. * to relay data to and from the attached USB host.
*/ */

@ -63,7 +63,6 @@
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void ResetHardware(void);
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);

@ -54,8 +54,6 @@ void USB_Init(
#endif #endif
) )
{ {
USB_ShutDown();
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
USB_CurrentMode = Mode; USB_CurrentMode = Mode;
#endif #endif
@ -120,29 +118,9 @@ void USB_ShutDown(void)
EVENT_USB_Disconnect(); EVENT_USB_Disconnect();
#endif #endif
USB_ResetInterface();
USB_Detach(); USB_Detach();
USB_Controller_Disable();
USB_INT_DisableAllInterrupts();
USB_INT_ClearAllInterrupts();
USB_IsInitialized = false;
#if defined(USB_CAN_BE_HOST)
USB_HostState = HOST_STATE_Unattached;
#endif
#if defined(USB_CAN_BE_DEVICE)
USB_DeviceState = DEVICE_STATE_Unattached;
USB_ConfigurationNumber = 0;
USB_RemoteWakeupEnabled = false;
USB_CurrentlySelfPowered = false;
#endif
#if defined(CAN_BE_BOTH)
USB_CurrentMode = USB_MODE_NONE;
#endif
USB_Interface_Disable();
USB_PLL_Off(); USB_PLL_Off();
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
@ -152,6 +130,12 @@ void USB_ShutDown(void)
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
UHWCON &= ~(1 << UIDE); UHWCON &= ~(1 << UIDE);
#endif #endif
USB_IsInitialized = false;
#if defined(CAN_BE_BOTH)
USB_CurrentMode = USB_MODE_NONE;
#endif
} }
void USB_ResetInterface(void) void USB_ResetInterface(void)
@ -180,7 +164,7 @@ void USB_ResetInterface(void)
while (!(USB_PLL_IsReady())); while (!(USB_PLL_IsReady()));
} }
USB_Interface_Reset(); USB_Controller_Reset();
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
if (UHWCON & (1 << UIDE)) if (UHWCON & (1 << UIDE))

@ -334,9 +334,9 @@
#define USB_CLK_Freeze() MACROS{ USBCON |= (1 << FRZCLK); }MACROE #define USB_CLK_Freeze() MACROS{ USBCON |= (1 << FRZCLK); }MACROE
#define USB_CLK_Unfreeze() MACROS{ USBCON &= ~(1 << FRZCLK); }MACROE #define USB_CLK_Unfreeze() MACROS{ USBCON &= ~(1 << FRZCLK); }MACROE
#define USB_Interface_Enable() MACROS{ USBCON |= (1 << USBE); }MACROE #define USB_Controller_Enable() MACROS{ USBCON |= (1 << USBE); }MACROE
#define USB_Interface_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE #define USB_Controller_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE
#define USB_Interface_Reset() MACROS{ uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \ #define USB_Controller_Reset() MACROS{ uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \
USBCON = (Temp | (1 << USBE)); }MACROE USBCON = (Temp | (1 << USBE)); }MACROE
/* Inline Functions: */ /* Inline Functions: */

Loading…
Cancel
Save