- /* 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 */
- WriteNextResponseByte(0x44);
- WriteNextResponseByte(0x00);
- }
- else if (Command == 'a')
- {
- /* Indicate auto-address increment is supported */
- WriteNextResponseByte('Y');
- }
- else if (Command == 'A')
- {
- /* Set the current address to that given by the host */
- CurrAddress = (FetchNextCommandByte() << 9);
- CurrAddress |= (FetchNextCommandByte() << 1);
-
- /* Send confirmation byte back to the host */
- WriteNextResponseByte('\r');
- }
- else if (Command == 'p')
- {
- /* Indicate serial programmer back to the host */
- WriteNextResponseByte('S');
- }
- else if (Command == 'S')
- {
- /* Write the 7-byte software identifier to the endpoint */
- for (uint8_t CurrByte = 0; CurrByte < 7; CurrByte++)
- WriteNextResponseByte(SOFTWARE_IDENTIFIER[CurrByte]);
- }
- else if (Command == 'V')
- {
- WriteNextResponseByte('0' + BOOTLOADER_VERSION_MAJOR);
- WriteNextResponseByte('0' + BOOTLOADER_VERSION_MINOR);
- }
- else if (Command == 's')
- {
- WriteNextResponseByte(AVR_SIGNATURE_3);
- WriteNextResponseByte(AVR_SIGNATURE_2);
- WriteNextResponseByte(AVR_SIGNATURE_1);
- }
- else if (Command == 'b')
- {
- WriteNextResponseByte('Y');
-
- /* Send block size to the host */
- WriteNextResponseByte(SPM_PAGESIZE >> 8);
- WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
- }
- else if (Command == 'e')
- {
- /* Clear the application section of flash */
- for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < BOOT_START_ADDR; CurrFlashAddress++)
- {
- boot_page_erase(CurrFlashAddress);
- boot_spm_busy_wait();
- boot_page_write(CurrFlashAddress);
- boot_spm_busy_wait();