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/TeensyHID/TeensyHID.c | |
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/TeensyHID/TeensyHID.c')
-rw-r--r-- | Bootloaders/TeensyHID/TeensyHID.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Bootloaders/TeensyHID/TeensyHID.c b/Bootloaders/TeensyHID/TeensyHID.c index b93be6d18..ff28927b4 100644 --- a/Bootloaders/TeensyHID/TeensyHID.c +++ b/Bootloaders/TeensyHID/TeensyHID.c @@ -105,18 +105,24 @@ void EVENT_USB_Device_UnhandledControlRequest(void) /* Wait until the command has been sent by the host */
while (!(Endpoint_IsOUTReceived()));
- /* Read in the write destination address */
- uint16_t PageAddress = Endpoint_Read_Word_LE();
+ /* Read in the write destination index */
+ uint16_t PageIndex = Endpoint_Read_Word_LE();
/* Check if the command is a program page command, or a start application command */
- if (PageAddress == TEENSY_STARTAPPLICATION)
+ if (PageIndex == TEENSY_STARTAPPLICATION)
{
RunBootloader = false;
}
else
{
+ #if (SPM_PAGESIZE == 128)
+ uint16_t PageByteAddress = PageIndex;
+ #else
+ uint32_t PageByteAddress = ((uint32_t)PageIndex << 8);
+ #endif
+
/* Erase the given FLASH page, ready to be programmed */
- boot_page_erase(PageAddress);
+ boot_page_erase(PageByteAddress);
boot_spm_busy_wait();
/* Write each of the FLASH page's bytes in sequence */
@@ -134,15 +140,12 @@ void EVENT_USB_Device_UnhandledControlRequest(void) }
/* Write the next data word to the FLASH page */
- boot_page_fill(PageAddress + PageByte, Endpoint_Read_Word_LE());
+ boot_page_fill(PageByteAddress + PageByte, Endpoint_Read_Word_LE());
}
/* Write the filled FLASH page to memory */
- boot_page_write(PageAddress);
+ boot_page_write(PageByteAddress);
boot_spm_busy_wait();
-
- /* Re-enable RWW section */
- boot_rww_enable();
}
Endpoint_ClearOUT();
|