From 520456577a795a5ca565307c6771305fe441dab4 Mon Sep 17 00:00:00 2001 From: Phillip Stevens Date: Sat, 11 Apr 2020 12:24:22 +1000 Subject: [PATCH] ATmegaxxxx - add __AVR_HAVE_RAMPZ__ --- portable/GCC/ATmegaxxxx/port.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/portable/GCC/ATmegaxxxx/port.c b/portable/GCC/ATmegaxxxx/port.c index 0a997c876..71c93f9da 100644 --- a/portable/GCC/ATmegaxxxx/port.c +++ b/portable/GCC/ATmegaxxxx/port.c @@ -216,7 +216,7 @@ void wdt_interrupt_reset_enable (const uint8_t value) * * r0 is set to __tmp_reg__ as the compiler expects it to be thus. * - * #if defined(__AVR_3_BYTE_PC__) + * #if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__) * #define __RAMPZ__ 0x3B * #define __EIND__ 0x3C * #endif @@ -224,7 +224,7 @@ void wdt_interrupt_reset_enable (const uint8_t value) * The interrupts will have been disabled during the call to portSAVE_CONTEXT() * so we need not worry about reading/writing to the stack pointer. */ -#if defined(__AVR_3_BYTE_PC__) +#if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__) /* 3-Byte PC Save */ #define portSAVE_CONTEXT() \ __asm__ __volatile__ ( "push __tmp_reg__ \n\t" \ @@ -326,7 +326,7 @@ void wdt_interrupt_reset_enable (const uint8_t value) * Opposite to portSAVE_CONTEXT(). Interrupts will have been disabled during * the context save so we can write to the stack pointer. */ -#if defined(__AVR_3_BYTE_PC__) +#if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__) /* 3-Byte PC Restore */ #define portRESTORE_CONTEXT() \ __asm__ __volatile__ ( "lds r26, pxCurrentTCB \n\t" \ @@ -445,7 +445,7 @@ uint16_t usAddress; /* The start of the task code will be popped off the stack last, so place it on first. */ -#if defined(__AVR_3_BYTE_PC__) +#if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__) /* The AVR ATmega2560/ATmega2561 have 256KBytes of program memory and a 17-bit * program counter. When a code address is stored on the stack, it takes 3 bytes * instead of 2 for the other ATmega* chips. @@ -485,8 +485,7 @@ uint16_t usAddress; *pxTopOfStack = portFLAGS_INT_ENABLED; pxTopOfStack--; -#if defined(__AVR_3_BYTE_PC__) - +#if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__) /* If we have an ATmega256x, we are also saving the RAMPZ and EIND registers. * We should default those to 0. */ @@ -494,7 +493,6 @@ uint16_t usAddress; pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0x00; /* RAMPZ */ pxTopOfStack--; - #endif /* Now the remaining registers. The compiler expects R1 to be 0. */