X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/8be9c4dd8ed7ae824080a9f5ef9e571aa1304241..4cadc9e7c294d43091e79c60e9fe9ad80f87f3bb:/firmware/main.c?ds=inline diff --git a/firmware/main.c b/firmware/main.c index c450095..91127ef 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -145,7 +145,7 @@ static const uchar signatureBytes[4] = { 0x1e, 0x93, 0x0F, 0 #elif defined (__AVR_ATmega164A__) 0x1e, 0x94, 0x0f, 0 -#elif defined (__AVR_ATmega164P__) +#elif defined (__AVR_ATmega164P__) || defined (__AVR_ATmega164PA__) 0x1e, 0x94, 0x0a, 0 #elif defined (__AVR_ATmega168__) || defined (__AVR_ATmega168A__) || defined (__AVR_ATmega168P__) 0x1e, 0x94, 0x06, 0 @@ -178,6 +178,32 @@ static const uchar signatureBytes[4] = { /* ------------------------------------------------------------------------ */ +#if (USE_BOOTUP_CLEARRAM) +/* +* Under normal circumstances, RESET will not clear contents of RAM. +* As always, if you want it done - do it yourself... +*/ +void __attribute__ ((naked)) __attribute__ ((section (".init3"))) __clearram(void); +void __clearram(void) { + extern size_t __bss_end; + asm volatile ( + "__clearram:\n\t" + "ldi r29, %[ramendhi]\n\t" + "ldi r28, %[ramendlo]\n\t" + "__clearramloop%=:\n\t" + "st -Y , __zero_reg__\n\t" + "cp r28, %A[bssend]\n\t" + "cpc r29, %B[bssend]\n\t" + "brne __clearramloop%=\n\t" + : + : [ramendhi] "M" (((RAMEND+1)>>8) & 0xff), + [ramendlo] "M" (((RAMEND+1)>>0) & 0xff), + [bssend] "r" (&__bss_end) + : "memory" + ); +} +#endif + #if (!USE_EXCESSIVE_ASSEMBLER) || (!(defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__))) static void (*nullVector)(void) __attribute__((__noreturn__)); #endif