aboutsummaryrefslogtreecommitdiffstats
path: root/Bootloaders/DFU
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-09 06:05:01 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-09 06:05:01 +0000
commit28343b1475b999e61c8fe98eb420507a0e6da388 (patch)
treede2080f2f4a8b575b5332137a191a4a3d90a3284 /Bootloaders/DFU
parent0323e13b39a8a00ede4a3242bddfc6d8343acdaa (diff)
downloadlufa-28343b1475b999e61c8fe98eb420507a0e6da388.tar.gz
lufa-28343b1475b999e61c8fe98eb420507a0e6da388.tar.bz2
lufa-28343b1475b999e61c8fe98eb420507a0e6da388.zip
Updated bootloaders to use the new main() function layout and remove any references to the scheduler to keep them in line with the rest of the library.
Diffstat (limited to 'Bootloaders/DFU')
-rw-r--r--Bootloaders/DFU/BootloaderDFU.c37
-rw-r--r--Bootloaders/DFU/BootloaderDFU.h3
2 files changed, 24 insertions, 16 deletions
diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c
index 6da741e39..58a751188 100644
--- a/Bootloaders/DFU/BootloaderDFU.c
+++ b/Bootloaders/DFU/BootloaderDFU.c
@@ -98,6 +98,23 @@ uint16_t EndAddr = 0x0000;
*/
int main (void)
{
+ /* Configure hardware required by the bootloader */
+ SetupHardware();
+
+ /* Run the USB management task while the bootloader is supposed to be running */
+ while (RunBootloader || WaitForExit)
+ USB_USBTask();
+
+ /* Reset configured hardware back to their original states for the user application */
+ ResetHardware();
+
+ /* Start the user application */
+ AppStartPtr();
+}
+
+/** Configures all hardware required for the bootloader. */
+void SetupHardware(void)
+{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
wdt_disable();
@@ -111,29 +128,17 @@ int main (void)
/* Initialize the USB subsystem */
USB_Init();
+}
- /* Run the USB management task while the bootloader is supposed to be running */
- while (RunBootloader || WaitForExit)
- USB_USBTask();
-
+/** 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;
-
- /* Reset any used hardware ports back to their defaults */
- PORTD = 0;
- DDRD = 0;
-
- #if defined(PORTE)
- PORTE = 0;
- DDRE = 0;
- #endif
-
- /* Start the user application */
- AppStartPtr();
}
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h
index a78d80d0c..776281eb8 100644
--- a/Bootloaders/DFU/BootloaderDFU.h
+++ b/Bootloaders/DFU/BootloaderDFU.h
@@ -193,6 +193,9 @@
};
/* Function Prototypes: */
+ void SetupHardware(void);
+ void ResetHardware(void);
+
void EVENT_USB_Disconnect(void);
void EVENT_USB_UnhandledControlPacket(void);