diff options
author | cpldcpu <cpldcpu@gmail.com> | 2013-12-31 00:54:19 +0100 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2013-12-31 00:54:19 +0100 |
commit | 58514cfadd15985ff3ac279679930d372f705687 (patch) | |
tree | b4e0fc8026ab82cc4af5a8dc6dd60fe384199ad9 | |
parent | c76ecfb6151c615cc35774c404b956a16c14085c (diff) | |
download | micronucleus-58514cfadd15985ff3ac279679930d372f705687.tar.gz micronucleus-58514cfadd15985ff3ac279679930d372f705687.tar.bz2 micronucleus-58514cfadd15985ff3ac279679930d372f705687.zip |
firmware: Directly mapped command register saves 12 btes
-rw-r--r-- | firmware/bootloaderconfig.h | 2 | ||||
-rw-r--r-- | firmware/main.c | 23 |
2 files changed, 11 insertions, 14 deletions
diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h index 57f15f2..9c06de3 100644 --- a/firmware/bootloaderconfig.h +++ b/firmware/bootloaderconfig.h @@ -269,7 +269,7 @@ these macros are defined, the boot loader uses them. #define LED_DDR DDRB #define LED_PORT PORTB -#define LED_PIN PB2 +#define LED_PIN PB1 #if LED_PRESENT #define LED_INIT(x) LED_PORT &=~_BV(LED_PIN); diff --git a/firmware/main.c b/firmware/main.c index 447ff20..d0a3edd 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -36,10 +36,11 @@ register uint8_t command asm( "r3" ); // register saves many bytes enum { - cmd_nop=0, - cmd_erase_application, - cmd_write_page, - cmd_exit + cmd_nop=0, // also: get device info + cmd_transfer_page=1, + cmd_erase_application=2, + cmd_exit=4, + cmd_write_page=5, }; // Definition of sei and cli without memory barrier keyword to prevent reloading of memory variables @@ -162,22 +163,18 @@ static uint8_t usbFunctionSetup(uint8_t data[8]) { if (rq->bRequest == 0) { // get device info usbMsgPtr = replyBuffer; return 4; - } else if (rq->bRequest == 1) { // write page + } else if (rq->bRequest == cmd_transfer_page) { // transfer page // clear page buffer as a precaution before filling the buffer in case // a previous write operation failed and there is still something in the buffer. __boot_page_fill_clear(); currentAddress = rq->wIndex.word; return USB_NO_MSG; // hands off work to usbFunctionWrite - - } else if (rq->bRequest == 2) { // erase application - command=cmd_erase_application; - - } else { // exit bootloader - command=cmd_exit; - } - + } else { + // Handle cmd_erase_application and cmd_exit + command=rq->bRequest; return 0; + } } // read in a page over usb, and write it in to the flash write buffer |