|
|
|
@ -332,21 +332,31 @@ void CDC_Task(void)
|
|
|
|
|
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
|
|
|
|
|
|
|
|
|
/* Check if endpoint has a command in it sent from the host */
|
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
|
{
|
|
|
|
|
if (!(Endpoint_IsOUTReceived()))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Read in the bootloader command (first byte sent from host) */
|
|
|
|
|
uint8_t Command = FetchNextCommandByte();
|
|
|
|
|
|
|
|
|
|
if ((Command == 'L') || (Command == 'P') || (Command == 'T') || (Command == 'E'))
|
|
|
|
|
{
|
|
|
|
|
if (Command == 'E')
|
|
|
|
|
{
|
|
|
|
|
RunBootloader = false;
|
|
|
|
|
|
|
|
|
|
/* Send confirmation byte back to the host */
|
|
|
|
|
WriteNextResponseByte('\r');
|
|
|
|
|
}
|
|
|
|
|
else if (Command == 'T')
|
|
|
|
|
{
|
|
|
|
|
FetchNextCommandByte();
|
|
|
|
|
|
|
|
|
|
/* Send confirmation byte back to the host */
|
|
|
|
|
WriteNextResponseByte('\r');
|
|
|
|
|
}
|
|
|
|
|
else if ((Command == 'L') || (Command == 'P'))
|
|
|
|
|
{
|
|
|
|
|
/* Send confirmation byte back to the host */
|
|
|
|
|
WriteNextResponseByte('\r');
|
|
|
|
|
}
|
|
|
|
|
else if (Command == 't')
|
|
|
|
|
{
|
|
|
|
|
/* Return ATMEGA128 part code - this is only to allow AVRProg to use the bootloader */
|
|
|
|
@ -392,20 +402,18 @@ void CDC_Task(void)
|
|
|
|
|
else if (Command == 'e')
|
|
|
|
|
{
|
|
|
|
|
/* Clear the application section of flash */
|
|
|
|
|
for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < BOOT_START_ADDR; CurrFlashAddress++)
|
|
|
|
|
for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE)
|
|
|
|
|
{
|
|
|
|
|
boot_page_erase(CurrFlashAddress);
|
|
|
|
|
boot_spm_busy_wait();
|
|
|
|
|
boot_page_write(CurrFlashAddress);
|
|
|
|
|
boot_spm_busy_wait();
|
|
|
|
|
|
|
|
|
|
CurrFlashAddress += SPM_PAGESIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Send confirmation byte back to the host */
|
|
|
|
|
WriteNextResponseByte('\r');
|
|
|
|
|
}
|
|
|
|
|
#if !defined(NO_LOCK_BYTE_SUPPORT)
|
|
|
|
|
#if !defined(NO_LOCK_BYTE_WRITE_SUPPORT)
|
|
|
|
|
else if (Command == 'l')
|
|
|
|
|
{
|
|
|
|
|
/* Set the lock bits to those given by the host */
|
|
|
|
@ -550,5 +558,4 @@ void CDC_Task(void)
|
|
|
|
|
/* Acknowledge the command from the host */
|
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|