diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-05-06 07:27:13 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-05-06 07:27:13 +0000 |
commit | c3db72afdc9928afbf2a8986f6970aa85dd9902a (patch) | |
tree | cd69c9f45e00bd2788f6bfbffc2aa05878d69519 /Bootloaders/CDC | |
parent | add51923661b5df5985bcd76e33f89835a9ead55 (diff) | |
download | lufa-c3db72afdc9928afbf2a8986f6970aa85dd9902a.tar.gz lufa-c3db72afdc9928afbf2a8986f6970aa85dd9902a.tar.bz2 lufa-c3db72afdc9928afbf2a8986f6970aa85dd9902a.zip |
Make CDC class bootloader hard-reset the AVR when exited instead of a soft-reset. Reduce size of the TeensyHID bootloader slightly.
Fix the TeensyHID bootloader for the larger USB AVR devices, since Paul uses a different (undocumented) addressing scheme on these devices.
Diffstat (limited to 'Bootloaders/CDC')
-rw-r--r-- | Bootloaders/CDC/BootloaderCDC.c | 29 | ||||
-rw-r--r-- | Bootloaders/CDC/BootloaderCDC.h | 1 |
2 files changed, 8 insertions, 22 deletions
diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c index 83fd0ee92..9f7878617 100644 --- a/Bootloaders/CDC/BootloaderCDC.c +++ b/Bootloaders/CDC/BootloaderCDC.c @@ -54,8 +54,8 @@ CDC_Line_Coding_t LineCoding = { .BaudRateBPS = 9600, uint32_t CurrAddress;
/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
- * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application
- * jumped to via an indirect jump to location 0x0000.
+ * via a watchdog reset. When cleared the bootloader will exit, starting the watchdog and entering an infinite
+ * loop until the AVR restarts and the application runs.
*/
bool RunBootloader = true;
@@ -78,12 +78,13 @@ int main(void) USB_USBTask();
}
- /* Reset all configured hardware to their default states for the user app */
- ResetHardware();
+ /* Disconnect from the host - USB interface will be reset later along with the AVR */
+ USB_Detach();
- /* Start the user application */
- AppPtr_t AppStartPtr = (AppPtr_t)0x0000;
- AppStartPtr();
+ /* Enable the watchdog and force a timeout to reset the AVR */
+ wdt_enable(WDTO_250MS);
+
+ for (;;);
}
/** Configures all hardware required for the bootloader. */
@@ -104,20 +105,6 @@ void SetupHardware(void) 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();
-
- /* Relocate the interrupt vector table back to the application section */
- MCUCR = (1 << IVCE);
- MCUCR = 0;
-
- /* Re-enable RWW section */
- boot_rww_enable();
-}
-
/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
* to relay data to and from the attached USB host.
*/
diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h index 22b57438d..81422119f 100644 --- a/Bootloaders/CDC/BootloaderCDC.h +++ b/Bootloaders/CDC/BootloaderCDC.h @@ -117,7 +117,6 @@ /* Function Prototypes: */
void CDC_Task(void);
void SetupHardware(void);
- void ResetHardware(void);
void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_UnhandledControlRequest(void);
|