mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 09:07:46 -04:00
ATmegaxxxx - refine WDT config
This commit is contained in:
parent
d356bfc02f
commit
3ece178dd0
2 changed files with 41 additions and 30 deletions
|
@ -38,11 +38,11 @@
|
||||||
*----------------------------------------------------------*/
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Start tasks with interrupts enabled. */
|
/* Start tasks with interrupts enabled. */
|
||||||
#define portFLAGS_INT_ENABLED ( (StackType_t) 0x80 )
|
#define portFLAGS_INT_ENABLED ( (StackType_t) 0x80 )
|
||||||
|
|
||||||
#if defined( portUSE_WDTO)
|
#if defined( portUSE_WDTO)
|
||||||
#warning "Watchdog Timer used for scheduler."
|
#warning "Watchdog Timer used for scheduler."
|
||||||
#define portSCHEDULER_ISR WDT_vect
|
#define portSCHEDULER_ISR WDT_vect
|
||||||
|
|
||||||
#elif defined( portUSE_TIMER0 )
|
#elif defined( portUSE_TIMER0 )
|
||||||
/* Hardware constants for Timer0. */
|
/* Hardware constants for Timer0. */
|
||||||
|
@ -97,6 +97,8 @@ static void prvSetupTimerInterrupt( void );
|
||||||
Updated to match avr-libc 2.0.0
|
Updated to match avr-libc 2.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined( portUSE_WDTO)
|
||||||
|
|
||||||
static __inline__
|
static __inline__
|
||||||
__attribute__ ((__always_inline__))
|
__attribute__ ((__always_inline__))
|
||||||
void wdt_interrupt_enable (const uint8_t value)
|
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
|
Updated to match avr-libc 2.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined( portUSE_WDTO)
|
||||||
|
|
||||||
static __inline__
|
static __inline__
|
||||||
__attribute__ ((__always_inline__))
|
__attribute__ ((__always_inline__))
|
||||||
void wdt_interrupt_reset_enable (const uint8_t value)
|
void wdt_interrupt_reset_enable (const uint8_t value)
|
||||||
|
@ -199,6 +204,7 @@ void wdt_interrupt_reset_enable (const uint8_t value)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,11 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Type definitions. */
|
/* Type definitions. */
|
||||||
#define portCHAR char
|
#define portCHAR char
|
||||||
#define portFLOAT float
|
#define portFLOAT float
|
||||||
#define portDOUBLE double
|
#define portDOUBLE double
|
||||||
#define portLONG long
|
#define portLONG long
|
||||||
#define portSHORT int
|
#define portSHORT int
|
||||||
|
|
||||||
typedef uint8_t StackType_t;
|
typedef uint8_t StackType_t;
|
||||||
typedef int8_t BaseType_t;
|
typedef int8_t BaseType_t;
|
||||||
|
@ -55,16 +55,16 @@ typedef uint8_t UBaseType_t;
|
||||||
|
|
||||||
#if configUSE_16_BIT_TICKS == 1
|
#if configUSE_16_BIT_TICKS == 1
|
||||||
typedef uint16_t TickType_t;
|
typedef uint16_t TickType_t;
|
||||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||||
#else
|
#else
|
||||||
typedef uint32_t TickType_t;
|
typedef uint32_t TickType_t;
|
||||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||||
#endif
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Critical section management. */
|
/* Critical section management. */
|
||||||
|
|
||||||
#define portENTER_CRITICAL() __asm__ __volatile__ ( \
|
#define portENTER_CRITICAL() __asm__ __volatile__ ( \
|
||||||
"in __tmp_reg__, __SREG__" "\n\t" \
|
"in __tmp_reg__, __SREG__" "\n\t" \
|
||||||
"cli" "\n\t" \
|
"cli" "\n\t" \
|
||||||
"push __tmp_reg__" "\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" \
|
"pop __tmp_reg__" "\n\t" \
|
||||||
"out __SREG__, __tmp_reg__" "\n\t" \
|
"out __SREG__, __tmp_reg__" "\n\t" \
|
||||||
::: "memory" \
|
::: "memory" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory")
|
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory")
|
||||||
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory")
|
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory")
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Architecture specifics. */
|
/* Architecture specifics. */
|
||||||
|
|
||||||
// System Tick - Scheduler timer
|
// 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
|
#define portUSE_WDTO WDTO_15MS // portUSE_WDTO to use the Watchdog Timer for xTaskIncrementTick
|
||||||
WDTO_30MS
|
|
||||||
WDTO_60MS
|
|
||||||
WDTO_120MS
|
|
||||||
WDTO_250MS
|
|
||||||
WDTO_500MS
|
|
||||||
|
|
||||||
|
/* 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
|
#define portUSE_TIMER0 // portUSE_TIMER0 to use 8 bit Timer0 for xTaskIncrementTick
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define portSTACK_GROWTH ( -1 )
|
#define portSTACK_GROWTH ( -1 )
|
||||||
|
|
||||||
/* Timing for the scheduler.
|
/* Timing for the scheduler.
|
||||||
* Watchdog Timer is 128kHz nominal,
|
* Watchdog Timer is 128kHz nominal,
|
||||||
|
@ -112,23 +117,23 @@ typedef uint8_t UBaseType_t;
|
||||||
* from data sheet.
|
* from data sheet.
|
||||||
*/
|
*/
|
||||||
#if defined( portUSE_WDTO )
|
#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
|
#else
|
||||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define portBYTE_ALIGNMENT 1
|
#define portBYTE_ALIGNMENT 1
|
||||||
#define portNOP() __asm__ __volatile__ ( "nop" );
|
#define portNOP() __asm__ __volatile__ ( "nop" );
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Kernel utilities. */
|
/* Kernel utilities. */
|
||||||
extern void vPortYield( void ) __attribute__ ( ( naked ) );
|
extern void vPortYield( void ) __attribute__ ( ( naked ) );
|
||||||
#define portYIELD() vPortYield()
|
#define portYIELD() vPortYield()
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
/* 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")))
|
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__ ((section (".lowtext")))
|
||||||
#else
|
#else
|
||||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue