diff --git a/portable/GCC/ATmegaxxxx/port.c b/portable/GCC/ATmegaxxxx/port.c index fe1709788..1373970fc 100644 --- a/portable/GCC/ATmegaxxxx/port.c +++ b/portable/GCC/ATmegaxxxx/port.c @@ -38,11 +38,11 @@ *----------------------------------------------------------*/ /* Start tasks with interrupts enabled. */ -#define portFLAGS_INT_ENABLED ( (StackType_t) 0x80 ) +#define portFLAGS_INT_ENABLED ( (StackType_t) 0x80 ) #if defined( portUSE_WDTO) #warning "Watchdog Timer used for scheduler." - #define portSCHEDULER_ISR WDT_vect + #define portSCHEDULER_ISR WDT_vect #elif defined( portUSE_TIMER0 ) /* Hardware constants for Timer0. */ @@ -97,6 +97,8 @@ static void prvSetupTimerInterrupt( void ); Updated to match avr-libc 2.0.0 */ +#if defined( portUSE_WDTO) + static __inline__ __attribute__ ((__always_inline__)) void wdt_interrupt_enable (const uint8_t value) @@ -136,6 +138,7 @@ void wdt_interrupt_enable (const uint8_t value) ); } } +#endif /*-----------------------------------------------------------*/ /** @@ -160,6 +163,8 @@ void wdt_interrupt_enable (const uint8_t value) Updated to match avr-libc 2.0.0 */ +#if defined( portUSE_WDTO) + static __inline__ __attribute__ ((__always_inline__)) void wdt_interrupt_reset_enable (const uint8_t value) @@ -199,6 +204,7 @@ void wdt_interrupt_reset_enable (const uint8_t value) ); } } +#endif /*-----------------------------------------------------------*/ diff --git a/portable/GCC/ATmegaxxxx/portmacro.h b/portable/GCC/ATmegaxxxx/portmacro.h index 80fbbd3fd..ae6ce20cd 100644 --- a/portable/GCC/ATmegaxxxx/portmacro.h +++ b/portable/GCC/ATmegaxxxx/portmacro.h @@ -43,11 +43,11 @@ extern "C" { */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT int +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT int typedef uint8_t StackType_t; typedef int8_t BaseType_t; @@ -55,16 +55,16 @@ typedef uint8_t UBaseType_t; #if configUSE_16_BIT_TICKS == 1 typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff + #define portMAX_DELAY ( TickType_t ) 0xffff #else typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #endif /*-----------------------------------------------------------*/ /* Critical section management. */ -#define portENTER_CRITICAL() __asm__ __volatile__ ( \ +#define portENTER_CRITICAL() __asm__ __volatile__ ( \ "in __tmp_reg__, __SREG__" "\n\t" \ "cli" "\n\t" \ "push __tmp_reg__" "\n\t" \ @@ -72,39 +72,44 @@ typedef uint8_t UBaseType_t; ) -#define portEXIT_CRITICAL() __asm__ __volatile__ ( \ +#define portEXIT_CRITICAL() __asm__ __volatile__ ( \ "pop __tmp_reg__" "\n\t" \ "out __SREG__, __tmp_reg__" "\n\t" \ ::: "memory" \ ) -#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory") -#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory") +#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory") +#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory") /*-----------------------------------------------------------*/ /* Architecture specifics. */ // System Tick - Scheduler timer -// Prefer to use the Watchdog timer, but also Timer 0 is ok. +// Prefer to use the enhanced Watchdog Timer, but also Timer0 is ok. -#define portUSE_WDTO WDTO_15MS // portUSE_WDTO to use the Watchdog Timer for xTaskIncrementTick +#if defined(WDIE) && defined(WDIF) // Enhanced WDT with interrupt capability -/* Watchdog period options: WDTO_15MS - WDTO_30MS - WDTO_60MS - WDTO_120MS - WDTO_250MS - WDTO_500MS +#define portUSE_WDTO WDTO_15MS // portUSE_WDTO to use the Watchdog Timer for xTaskIncrementTick +/* Watchdog period options: WDTO_15MS + WDTO_30MS + WDTO_60MS + WDTO_120MS + WDTO_250MS + WDTO_500MS + WDTO_1S + WDTO_2S */ -#if !defined( portUSE_WDTO ) +#else + #define portUSE_TIMER0 // portUSE_TIMER0 to use 8 bit Timer0 for xTaskIncrementTick + #endif -#define portSTACK_GROWTH ( -1 ) +#define portSTACK_GROWTH ( -1 ) /* Timing for the scheduler. * Watchdog Timer is 128kHz nominal, @@ -112,23 +117,23 @@ typedef uint8_t UBaseType_t; * from data sheet. */ #if defined( portUSE_WDTO ) -#define portTICK_PERIOD_MS ( (TickType_t) _BV( portUSE_WDTO + 4 ) ) // Inaccurately assuming 128 kHz Watchdog Timer. +#define portTICK_PERIOD_MS ( (TickType_t) _BV( portUSE_WDTO + 4 ) ) // Inaccurately assuming 128 kHz Watchdog Timer. #else -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) #endif -#define portBYTE_ALIGNMENT 1 -#define portNOP() __asm__ __volatile__ ( "nop" ); +#define portBYTE_ALIGNMENT 1 +#define portNOP() __asm__ __volatile__ ( "nop" ); /*-----------------------------------------------------------*/ /* Kernel utilities. */ -extern void vPortYield( void ) __attribute__ ( ( naked ) ); -#define portYIELD() vPortYield() +extern void vPortYield( void ) __attribute__ ( ( naked ) ); +#define portYIELD() vPortYield() /*-----------------------------------------------------------*/ #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) /* Task function macros as described on the FreeRTOS.org WEB site. */ -// Add .lowtext tag for the linker for ATmega2560 and ATmega2561. To make sure they are loaded in low memory. +// Add .lowtext tag from the linker script avr6.x for ATmega2560 and ATmega2561. To make sure they are loaded in low memory. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__ ((section (".lowtext"))) #else #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )