Style: revert more uncrustify files

This commit is contained in:
Alfred Gedeon 2020-08-11 21:46:34 -07:00
parent 949096a861
commit 88e692ff55
4 changed files with 927 additions and 960 deletions

View file

@ -36,13 +36,13 @@
#include "task.h"
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the AVR port.
*----------------------------------------------------------*/
* Implementation of functions defined in portable.h for the AVR port.
*----------------------------------------------------------*/
/* 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."
#define portSCHEDULER_ISR WDT_vect
@ -50,50 +50,50 @@
/* Hardware constants for Timer0. */
#warning "Timer0 used for scheduler."
#define portSCHEDULER_ISR TIMER0_COMPA_vect
#define portCLEAR_COUNTER_ON_MATCH ( ( uint8_t ) _BV( WGM01 ) )
#define portPRESCALE_1024 ( ( uint8_t ) ( _BV( CS02 ) | _BV( CS00 ) ) )
#define portCLOCK_PRESCALER ( ( uint32_t ) 1024 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( uint8_t ) _BV( OCIE0A ) )
#define portCLEAR_COUNTER_ON_MATCH ( (uint8_t) _BV(WGM01) )
#define portPRESCALE_1024 ( (uint8_t) (_BV(CS02)|_BV(CS00)) )
#define portCLOCK_PRESCALER ( (uint32_t) 1024 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( (uint8_t) _BV(OCIE0A) )
#define portOCRL OCR0A
#define portTCCRa TCCR0A
#define portTCCRb TCCR0B
#define portTIMSK TIMSK0
#define portTIFR TIFR0
#endif /* if defined( portUSE_WDTO ) */
#endif
/*-----------------------------------------------------------*/
/* We require the address of the pxCurrentTCB variable, but don't want to know
* any details of its type. */
any details of its type. */
typedef void TCB_t;
extern volatile TCB_t * volatile pxCurrentTCB;
/*-----------------------------------------------------------*/
/**
* Enable the watchdog timer, configuring it for expire after
* (value) timeout (which is a combination of the WDP0
* through WDP3 bits).
*
* This function is derived from <avr/wdt.h> but enables only
* the interrupt bit (WDIE), rather than the reset bit (WDE).
*
* Can't find it documented but the WDT, once enabled,
* rolls over and fires a new interrupt each time.
*
* See also the symbolic constants WDTO_15MS et al.
*
* Updated to match avr-libc 2.0.0
*/
Enable the watchdog timer, configuring it for expire after
(value) timeout (which is a combination of the WDP0
through WDP3 bits).
#if defined( portUSE_WDTO )
This function is derived from <avr/wdt.h> but enables only
the interrupt bit (WDIE), rather than the reset bit (WDE).
static __inline__
__attribute__( ( __always_inline__ ) )
void wdt_interrupt_enable( const uint8_t value )
{
if( _SFR_IO_REG_P( _WD_CONTROL_REG ) )
Can't find it documented but the WDT, once enabled,
rolls over and fires a new interrupt each time.
See also the symbolic constants WDTO_15MS et al.
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)
{
if (_SFR_IO_REG_P (_WD_CONTROL_REG))
{
__asm__ __volatile__ (
"in __tmp_reg__,__SREG__" "\n\t"
@ -103,10 +103,10 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__,__tmp_reg__" "\n\t"
"out %0, %2" "\n\t"
: /* no outputs */
: "I" ( _SFR_IO_ADDR( _WD_CONTROL_REG ) ),
"r" ( ( uint8_t ) ( _BV( _WD_CHANGE_BIT ) | _BV( WDE ) ) ),
"r" ( ( uint8_t ) ( ( value & 0x08 ? _WD_PS3_MASK : 0x00 ) |
_BV( WDIF ) | _BV( WDIE ) | ( value & 0x07 ) ) )
: "I" (_SFR_IO_ADDR(_WD_CONTROL_REG)),
"r" ((uint8_t)(_BV(_WD_CHANGE_BIT) | _BV(WDE))),
"r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) |
_BV(WDIF) | _BV(WDIE) | (value & 0x07)) )
: "r0"
);
}
@ -120,47 +120,46 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__,__tmp_reg__" "\n\t"
"sts %0, %2" "\n\t"
: /* no outputs */
: "n" ( _SFR_MEM_ADDR( _WD_CONTROL_REG ) ),
"r" ( ( uint8_t ) ( _BV( _WD_CHANGE_BIT ) | _BV( WDE ) ) ),
"r" ( ( uint8_t ) ( ( value & 0x08 ? _WD_PS3_MASK : 0x00 ) |
_BV( WDIF ) | _BV( WDIE ) | ( value & 0x07 ) ) )
: "n" (_SFR_MEM_ADDR(_WD_CONTROL_REG)),
"r" ((uint8_t)(_BV(_WD_CHANGE_BIT) | _BV(WDE))),
"r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) |
_BV(WDIF) | _BV(WDIE) | (value & 0x07)) )
: "r0"
);
}
}
#endif /* if defined( portUSE_WDTO ) */
}
#endif
/*-----------------------------------------------------------*/
/**
* Enable the watchdog timer, configuring it for expire after
* (value) timeout (which is a combination of the WDP0
* through WDP3 bits).
*
* This function is derived from <avr/wdt.h> but enables both
* the reset bit (WDE), and the interrupt bit (WDIE).
*
* This will ensure that if the interrupt is not serviced
* before the second timeout, the AVR will reset.
*
* Servicing the interrupt automatically clears it,
* and ensures the AVR does not reset.
*
* Can't find it documented but the WDT, once enabled,
* rolls over and fires a new interrupt each time.
*
* See also the symbolic constants WDTO_15MS et al.
*
* Updated to match avr-libc 2.0.0
*/
Enable the watchdog timer, configuring it for expire after
(value) timeout (which is a combination of the WDP0
through WDP3 bits).
#if defined( portUSE_WDTO )
This function is derived from <avr/wdt.h> but enables both
the reset bit (WDE), and the interrupt bit (WDIE).
static __inline__
__attribute__( ( __always_inline__ ) )
void wdt_interrupt_reset_enable( const uint8_t value )
{
if( _SFR_IO_REG_P( _WD_CONTROL_REG ) )
This will ensure that if the interrupt is not serviced
before the second timeout, the AVR will reset.
Servicing the interrupt automatically clears it,
and ensures the AVR does not reset.
Can't find it documented but the WDT, once enabled,
rolls over and fires a new interrupt each time.
See also the symbolic constants WDTO_15MS et al.
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)
{
if (_SFR_IO_REG_P (_WD_CONTROL_REG))
{
__asm__ __volatile__ (
"in __tmp_reg__,__SREG__" "\n\t"
@ -170,10 +169,10 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__,__tmp_reg__" "\n\t"
"out %0, %2" "\n\t"
: /* no outputs */
: "I" ( _SFR_IO_ADDR( _WD_CONTROL_REG ) ),
"r" ( ( uint8_t ) ( _BV( _WD_CHANGE_BIT ) | _BV( WDE ) ) ),
"r" ( ( uint8_t ) ( ( value & 0x08 ? _WD_PS3_MASK : 0x00 ) |
_BV( WDIF ) | _BV( WDIE ) | _BV( WDE ) | ( value & 0x07 ) ) )
: "I" (_SFR_IO_ADDR(_WD_CONTROL_REG)),
"r" ((uint8_t)(_BV(_WD_CHANGE_BIT) | _BV(WDE))),
"r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) |
_BV(WDIF) | _BV(WDIE) | _BV(WDE) | (value & 0x07)) )
: "r0"
);
}
@ -187,15 +186,15 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__,__tmp_reg__" "\n\t"
"sts %0, %2" "\n\t"
: /* no outputs */
: "n" ( _SFR_MEM_ADDR( _WD_CONTROL_REG ) ),
"r" ( ( uint8_t ) ( _BV( _WD_CHANGE_BIT ) | _BV( WDE ) ) ),
"r" ( ( uint8_t ) ( ( value & 0x08 ? _WD_PS3_MASK : 0x00 ) |
_BV( WDIF ) | _BV( WDIE ) | _BV( WDE ) | ( value & 0x07 ) ) )
: "n" (_SFR_MEM_ADDR(_WD_CONTROL_REG)),
"r" ((uint8_t)(_BV(_WD_CHANGE_BIT) | _BV(WDE))),
"r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) |
_BV(WDIF) | _BV(WDIE) | _BV(WDE) | (value & 0x07)) )
: "r0"
);
}
}
#endif /* if defined( portUSE_WDTO ) */
}
#endif
/*-----------------------------------------------------------*/
@ -224,9 +223,9 @@ extern volatile TCB_t * volatile pxCurrentTCB;
* 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__ ) && defined( __AVR_HAVE_RAMPZ__ )
#if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__)
/* 3-Byte PC Save with RAMPZ */
#define portSAVE_CONTEXT() \
#define portSAVE_CONTEXT() \
__asm__ __volatile__ ( "push __tmp_reg__ \n\t" \
"in __tmp_reg__, __SREG__ \n\t" \
"cli \n\t" \
@ -274,9 +273,9 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"in __tmp_reg__, __SP_H__ \n\t" \
"st x+, __tmp_reg__ \n\t" \
);
#elif defined( __AVR_HAVE_RAMPZ__ )
#elif defined(__AVR_HAVE_RAMPZ__)
/* 2-Byte PC Save with RAMPZ */
#define portSAVE_CONTEXT() \
#define portSAVE_CONTEXT() \
__asm__ __volatile__ ( "push __tmp_reg__ \n\t" \
"in __tmp_reg__, __SREG__ \n\t" \
"cli \n\t" \
@ -322,9 +321,9 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"in __tmp_reg__, __SP_H__ \n\t" \
"st x+, __tmp_reg__ \n\t" \
);
#else /* if defined( __AVR_3_BYTE_PC__ ) && defined( __AVR_HAVE_RAMPZ__ ) */
#else
/* 2-Byte PC Save */
#define portSAVE_CONTEXT() \
#define portSAVE_CONTEXT() \
__asm__ __volatile__ ( "push __tmp_reg__ \n\t" \
"in __tmp_reg__, __SREG__ \n\t" \
"cli \n\t" \
@ -368,15 +367,15 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"in __tmp_reg__, __SP_H__ \n\t" \
"st x+, __tmp_reg__ \n\t" \
);
#endif /* if defined( __AVR_3_BYTE_PC__ ) && defined( __AVR_HAVE_RAMPZ__ ) */
#endif
/*
* 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__ ) && defined( __AVR_HAVE_RAMPZ__ )
#if defined(__AVR_3_BYTE_PC__) && defined(__AVR_HAVE_RAMPZ__)
/* 3-Byte PC Restore with RAMPZ */
#define portRESTORE_CONTEXT() \
#define portRESTORE_CONTEXT() \
__asm__ __volatile__ ( "lds r26, pxCurrentTCB \n\t" \
"lds r27, pxCurrentTCB + 1 \n\t" \
"ld r28, x+ \n\t" \
@ -422,9 +421,9 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__, __tmp_reg__ \n\t" \
"pop __tmp_reg__ \n\t" \
);
#elif defined( __AVR_HAVE_RAMPZ__ )
#elif defined(__AVR_HAVE_RAMPZ__)
/* 2-Byte PC Restore with RAMPZ */
#define portRESTORE_CONTEXT() \
#define portRESTORE_CONTEXT() \
__asm__ __volatile__ ( "lds r26, pxCurrentTCB \n\t" \
"lds r27, pxCurrentTCB + 1 \n\t" \
"ld r28, x+ \n\t" \
@ -468,9 +467,9 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__, __tmp_reg__ \n\t" \
"pop __tmp_reg__ \n\t" \
);
#else /* if defined( __AVR_3_BYTE_PC__ ) && defined( __AVR_HAVE_RAMPZ__ ) */
#else
/* 2-Byte PC Restore */
#define portRESTORE_CONTEXT() \
#define portRESTORE_CONTEXT() \
__asm__ __volatile__ ( "lds r26, pxCurrentTCB \n\t" \
"lds r27, pxCurrentTCB + 1 \n\t" \
"ld r28, x+ \n\t" \
@ -512,7 +511,7 @@ extern volatile TCB_t * volatile pxCurrentTCB;
"out __SREG__, __tmp_reg__ \n\t" \
"pop __tmp_reg__ \n\t" \
);
#endif /* if defined( __AVR_3_BYTE_PC__ ) && defined( __AVR_HAVE_RAMPZ__ ) */
#endif
/*-----------------------------------------------------------*/
/*
@ -524,17 +523,14 @@ static void prvSetupTimerInterrupt( void );
/*
* See header file for description.
*/
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
uint16_t usAddress;
uint16_t usAddress;
/* Simulate how the stack would look after a call to vPortYield() generated by
* the compiler. */
the compiler. */
/* The start of the task code will be popped off the stack last, so place
* it on first. */
it on first. */
usAddress = ( uint16_t ) pxCode;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
@ -543,8 +539,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
#if defined( __AVR_3_BYTE_PC__ )
#if defined(__AVR_3_BYTE_PC__)
/* 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.
@ -557,34 +552,32 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
*/
*pxTopOfStack = 0;
pxTopOfStack--;
#endif
#endif
/* Next simulate the stack as if after a call to portSAVE_CONTEXT().
* portSAVE_CONTEXT places the flags on the stack immediately after r0
* to ensure the interrupts get disabled as soon as possible, and so ensuring
* the stack use is minimal should a context switch interrupt occur. */
portSAVE_CONTEXT places the flags on the stack immediately after r0
to ensure the interrupts get disabled as soon as possible, and so ensuring
the stack use is minimal should a context switch interrupt occur. */
*pxTopOfStack = ( StackType_t ) 0x00; /* R0 */
pxTopOfStack--;
*pxTopOfStack = portFLAGS_INT_ENABLED;
pxTopOfStack--;
#if defined( __AVR_3_BYTE_PC__ )
#if defined(__AVR_3_BYTE_PC__)
/* If we have an ATmega256x, we are also saving the EIND register.
* We should default to 0.
*/
*pxTopOfStack = ( StackType_t ) 0x00; /* EIND */
pxTopOfStack--;
#endif
#if defined( __AVR_HAVE_RAMPZ__ )
#endif
#if defined(__AVR_HAVE_RAMPZ__)
/* We are saving the RAMPZ register.
* We should default to 0.
*/
*pxTopOfStack = ( StackType_t ) 0x00; /* RAMPZ */
pxTopOfStack--;
#endif
#endif
/* Now the remaining registers. The compiler expects R1 to be 0. */
*pxTopOfStack = ( StackType_t ) 0x00; /* R1 */
@ -616,7 +609,7 @@ BaseType_t xPortStartScheduler( void )
portRESTORE_CONTEXT();
/* Simulate a function call end as generated by the compiler. We will now
* jump to the start of the task the context of which we have just restored. */
jump to the start of the task the context of which we have just restored. */
__asm__ __volatile__ ( "ret" );
/* Should not get here. */
@ -634,7 +627,7 @@ void vPortEndScheduler( void )
* Manual context switch. The first thing we do is save the registers so we
* can use a naked attribute.
*/
void vPortYield( void ) __attribute__( ( hot, flatten, naked ) );
void vPortYield( void ) __attribute__ ( ( hot, flatten, naked ) );
void vPortYield( void )
{
portSAVE_CONTEXT();
@ -649,8 +642,8 @@ void vPortYield( void )
* Manual context switch callable from ISRs. The first thing we do is save
* the registers so we can use a naked attribute.
*/
void vPortYieldFromISR( void ) __attribute__( ( hot, flatten, naked ) );
void vPortYieldFromISR( void )
void vPortYieldFromISR(void) __attribute__ ( ( hot, flatten, naked ) );
void vPortYieldFromISR(void)
{
portSAVE_CONTEXT();
vTaskSwitchContext();
@ -666,48 +659,44 @@ void vPortYieldFromISR( void )
* difference from vPortYield() is the tick count is incremented as the
* call comes from the tick ISR.
*/
void vPortYieldFromTick( void ) __attribute__( ( hot, flatten, naked ) );
void vPortYieldFromTick( void ) __attribute__ ( ( hot, flatten, naked ) );
void vPortYieldFromTick( void )
{
portSAVE_CONTEXT();
if( xTaskIncrementTick() != pdFALSE )
{
vTaskSwitchContext();
}
portRESTORE_CONTEXT();
__asm__ __volatile__ ( "ret" );
}
/*-----------------------------------------------------------*/
#if defined( portUSE_WDTO )
#if defined(portUSE_WDTO)
/*
* Setup WDT to generate a tick interrupt.
*/
void prvSetupTimerInterrupt( void )
{
void prvSetupTimerInterrupt( void )
{
/* reset watchdog */
wdt_reset();
/* set up WDT Interrupt (rather than the WDT Reset). */
wdt_interrupt_enable( portUSE_WDTO );
}
#elif defined( portUSE_TIMER0 )
}
#elif defined (portUSE_TIMER0)
/*
* Setup Timer0 compare match A to generate a tick interrupt.
*/
static void prvSetupTimerInterrupt( void )
{
uint32_t ulCompareMatch;
uint8_t ucLowByte;
static void prvSetupTimerInterrupt( void )
{
uint32_t ulCompareMatch;
uint8_t ucLowByte;
/* Using 8bit Timer0 to generate the tick. Correct fuses must be
* selected for the configCPU_CLOCK_HZ clock.*/
selected for the configCPU_CLOCK_HZ clock.*/
ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;
@ -718,7 +707,7 @@ void vPortYieldFromTick( void )
ulCompareMatch -= ( uint32_t ) 1;
/* Setup compare match value for compare match A. Interrupts are disabled
* before this is called so we need not worry here. */
before this is called so we need not worry here. */
ucLowByte = ( uint8_t ) ( ulCompareMatch & ( uint32_t ) 0xff );
portOCRL = ucLowByte;
@ -731,15 +720,15 @@ void vPortYieldFromTick( void )
ucLowByte = portTIMSK;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
portTIMSK = ucLowByte;
}
}
#endif /* if defined( portUSE_WDTO ) */
#endif
/*-----------------------------------------------------------*/
#if configUSE_PREEMPTION == 1
/*
/*
* Tick ISR for preemptive scheduler. We can use a naked attribute as
* the context is saved at the start of vPortYieldFromTick(). The tick
* count is incremented after the context is saved.
@ -747,30 +736,30 @@ void vPortYieldFromTick( void )
* use ISR_NOBLOCK where there is an important timer running, that should preempt the scheduler.
*
*/
ISR( portSCHEDULER_ISR, ISR_NAKED ) __attribute__( ( hot, flatten ) );
ISR(portSCHEDULER_ISR, ISR_NAKED) __attribute__ ((hot, flatten));
/* ISR(portSCHEDULER_ISR, ISR_NAKED ISR_NOBLOCK) __attribute__ ((hot, flatten));
*/
ISR( portSCHEDULER_ISR )
ISR(portSCHEDULER_ISR)
{
vPortYieldFromTick();
__asm__ __volatile__ ( "reti" );
}
#else /* if configUSE_PREEMPTION == 1 */
#else
/*
/*
* Tick ISR for the cooperative scheduler. All this does is increment the
* tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD();
*
* use ISR_NOBLOCK where there is an important timer running, that should preempt the scheduler.
*/
ISR( portSCHEDULER_ISR ) __attribute__( ( hot, flatten ) );
ISR(portSCHEDULER_ISR) __attribute__ ((hot, flatten));
/* ISR(portSCHEDULER_ISR, ISR_NOBLOCK) __attribute__ ((hot, flatten));
*/
ISR( portSCHEDULER_ISR )
ISR(portSCHEDULER_ISR)
{
xTaskIncrementTick();
}
#endif /* if configUSE_PREEMPTION == 1 */
#endif

View file

@ -23,14 +23,14 @@
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#define PORTMACRO_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------
* Port specific definitions.
@ -42,32 +42,31 @@
*-----------------------------------------------------------
*/
#include <avr/wdt.h>
#include <avr/wdt.h>
/* 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;
typedef uint8_t UBaseType_t;
typedef uint8_t StackType_t;
typedef int8_t BaseType_t;
typedef uint8_t UBaseType_t;
#if configUSE_16_BIT_TICKS == 1
#if configUSE_16_BIT_TICKS == 1
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#else
#else
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
#endif
#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" \
@ -75,16 +74,15 @@
)
#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. */
@ -93,66 +91,66 @@
* Prefer to use the enhanced Watchdog Timer, but also Timer0 is ok.
*/
#if defined( WDIE ) && defined( WDIF ) /* If Enhanced WDT with interrupt capability is available */
#if defined(WDIE) && defined(WDIF) /* If Enhanced WDT with interrupt capability is available */
#define portUSE_WDTO WDTO_15MS /* use the Watchdog Timer for xTaskIncrementTick */
#define portUSE_WDTO WDTO_15MS /* 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
*/
WDTO_30MS
WDTO_60MS
WDTO_120MS
WDTO_250MS
WDTO_500MS
WDTO_1S
WDTO_2S
*/
#else
#else
#define portUSE_TIMER0 /* use the 8-bit Timer0 for xTaskIncrementTick */
#define portUSE_TIMER0 /* use the 8-bit Timer0 for xTaskIncrementTick */
#endif
#endif
#define portSTACK_GROWTH ( -1 )
#define portSTACK_GROWTH ( -1 )
/* Timing for the scheduler.
* Watchdog Timer is 128kHz nominal,
* but 120 kHz at 5V DC and 25 degrees is actually more accurate,
* from data sheet.
*/
#if defined( portUSE_WDTO )
#define portTICK_PERIOD_MS ( ( TickType_t ) _BV( portUSE_WDTO + 4 ) )
#else
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#endif
#if defined( portUSE_WDTO )
#define portTICK_PERIOD_MS ( (TickType_t) _BV( portUSE_WDTO + 4 ) )
#else
#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()
extern void vPortYieldFromISR( void ) __attribute__( ( naked ) );
#define portYIELD_FROM_ISR() vPortYieldFromISR()
extern void vPortYieldFromISR( void ) __attribute__ ( ( naked ) );
#define portYIELD_FROM_ISR() vPortYieldFromISR()
/*-----------------------------------------------------------*/
#if defined( __AVR_3_BYTE_PC__ )
#if defined(__AVR_3_BYTE_PC__)
/* Task function macros as described on the FreeRTOS.org WEB site. */
/* Add .lowtext tag from the avr linker script avr6.x for ATmega2560 and ATmega2561
* to make sure functions 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 )
#endif
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__ ((section (".lowtext")))
#else
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#endif
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* PORTMACRO_H */

View file

@ -26,31 +26,31 @@
*/
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the Posix port.
*
* Each task has a pthread which eases use of standard debuggers
* (allowing backtraces of tasks etc). Threads for tasks that are not
* running are blocked in sigwait().
*
* Task switch is done by resuming the thread for the next task by
* sending it the resume signal (SIGUSR1) and then suspending the
* current thread.
*
* The timer interrupt uses SIGALRM and care is taken to ensure that
* the signal handler runs only on the thread for the current task.
*
* Use of part of the standard C library requires care as some
* functions can take pthread mutexes internally which can result in
* deadlocks as the FreeRTOS kernel can switch tasks while they're
* holding a pthread mutex.
*
* Replacement malloc(), free(), calloc(), and realloc() are provided
* for glibc (see below for more information).
*
* stdio (printf() and friends) should be called from a single task
* only or serialized with a FreeRTOS primitive such as a binary
* semaphore or mutex.
*----------------------------------------------------------*/
* Implementation of functions defined in portable.h for the Posix port.
*
* Each task has a pthread which eases use of standard debuggers
* (allowing backtraces of tasks etc). Threads for tasks that are not
* running are blocked in sigwait().
*
* Task switch is done by resuming the thread for the next task by
* sending it the resume signal (SIGUSR1) and then suspending the
* current thread.
*
* The timer interrupt uses SIGALRM and care is taken to ensure that
* the signal handler runs only on the thread for the current task.
*
* Use of part of the standard C library requires care as some
* functions can take pthread mutexes internally which can result in
* deadlocks as the FreeRTOS kernel can switch tasks while they're
* holding a pthread mutex.
*
* Replacement malloc(), free(), calloc(), and realloc() are provided
* for glibc (see below for more information).
*
* stdio (printf() and friends) should be called from a single task
* only or serialized with a FreeRTOS primitive such as a binary
* semaphore or mutex.
*----------------------------------------------------------*/
#include <errno.h>
#include <pthread.h>
@ -73,7 +73,7 @@ typedef struct THREAD
{
pthread_t pthread;
pdTASK_CODE pxCode;
void * pvParams;
void *pvParams;
BaseType_t xDying;
} Thread_t;
@ -81,11 +81,11 @@ typedef struct THREAD
* The additional per-thread data is stored at the beginning of the
* task's stack.
*/
static inline Thread_t * prvGetThreadFromTask( TaskHandle_t xTask )
static inline Thread_t *prvGetThreadFromTask(TaskHandle_t xTask)
{
StackType_t * pxTopOfStack = *( StackType_t ** ) xTask;
StackType_t *pxTopOfStack = *(StackType_t **)xTask;
return ( Thread_t * ) ( pxTopOfStack + 1 );
return (Thread_t *)(pxTopOfStack + 1);
}
/*-----------------------------------------------------------*/
@ -94,7 +94,7 @@ static pthread_once_t hSigSetupThread = PTHREAD_ONCE_INIT;
static sigset_t xResumeSignals;
static sigset_t xAllSignals;
static sigset_t xSchedulerOriginalSignalMask;
static pthread_t hMainThread = ( pthread_t ) NULL;
static pthread_t hMainThread = ( pthread_t )NULL;
static volatile portBASE_TYPE uxCriticalNesting;
/*-----------------------------------------------------------*/
@ -103,9 +103,8 @@ static portBASE_TYPE xSchedulerEnd = pdFALSE;
static void prvSetupSignalsAndSchedulerPolicy( void );
static void prvSetupTimerInterrupt( void );
static void * prvWaitForStart( void * pvParams );
static void prvSwitchThread( Thread_t * xThreadToResume,
Thread_t * xThreadToSuspend );
static void *prvWaitForStart( void * pvParams );
static void prvSwitchThread( Thread_t *xThreadToResume, Thread_t *xThreadToSuspend );
static void prvSuspendSelf( void );
static void prvResumeThread( pthread_t xThreadId );
static void vPortSystemTickHandler( int sig );
@ -132,17 +131,15 @@ static void vPortStartFirstTask( void );
* timer (SIGALRM) and other signals.
*/
extern void * __libc_malloc( size_t );
extern void __libc_free( void * );
extern void * __libc_calloc( size_t,
size_t );
extern void * __libc_realloc( void * ptr,
size_t );
extern void *__libc_malloc(size_t);
extern void __libc_free(void *);
extern void *__libc_calloc(size_t, size_t);
extern void *__libc_realloc(void *ptr, size_t);
void * malloc( size_t size )
void *malloc(size_t size)
{
sigset_t xSavedSignals;
void * ptr;
sigset_t xSavedSignals;
void *ptr;
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
ptr = __libc_malloc( size );
@ -151,20 +148,19 @@ void * malloc( size_t size )
return ptr;
}
void free( void * ptr )
void free(void *ptr)
{
sigset_t xSavedSignals;
sigset_t xSavedSignals;
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
__libc_free( ptr );
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
}
void * calloc( size_t nmemb,
size_t size )
void *calloc(size_t nmemb, size_t size)
{
sigset_t xSavedSignals;
void * ptr;
sigset_t xSavedSignals;
void *ptr;
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
ptr = __libc_calloc( nmemb, size );
@ -173,10 +169,9 @@ void * calloc( size_t nmemb,
return ptr;
}
void * realloc( void * ptr,
size_t size )
void *realloc(void *ptr, size_t size)
{
sigset_t xSavedSignals;
sigset_t xSavedSignals;
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
ptr = __libc_realloc( ptr, size );
@ -185,8 +180,7 @@ void * realloc( void * ptr,
return ptr;
}
static void prvFatalError( const char * pcCall,
int iErrno )
static void prvFatalError( const char *pcCall, int iErrno )
{
fprintf( stderr, "%s: %s\n", pcCall, strerror( iErrno ) );
abort();
@ -195,24 +189,23 @@ static void prvFatalError( const char * pcCall,
/*
* See header file for description.
*/
portSTACK_TYPE * pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack,
portSTACK_TYPE * pxEndOfStack,
pdTASK_CODE pxCode,
void * pvParameters )
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack,
portSTACK_TYPE *pxEndOfStack,
pdTASK_CODE pxCode, void *pvParameters )
{
Thread_t * thread;
pthread_attr_t xThreadAttributes;
size_t ulStackSize;
int iRet;
Thread_t *thread;
pthread_attr_t xThreadAttributes;
size_t ulStackSize;
int iRet;
( void ) pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
(void)pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
/*
* Store the additional thread data at the start of the stack.
*/
thread = ( Thread_t * ) ( pxTopOfStack + 1 ) - 1;
pxTopOfStack = ( portSTACK_TYPE * ) thread - 1;
ulStackSize = ( pxTopOfStack + 1 - pxEndOfStack ) * sizeof( *pxTopOfStack );
thread = (Thread_t *)(pxTopOfStack + 1) - 1;
pxTopOfStack = (portSTACK_TYPE *)thread - 1;
ulStackSize = (pxTopOfStack + 1 - pxEndOfStack) * sizeof(*pxTopOfStack);
thread->pxCode = pxCode;
thread->pvParams = pvParameters;
@ -225,8 +218,7 @@ portSTACK_TYPE * pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack,
iRet = pthread_create( &thread->pthread, &xThreadAttributes,
prvWaitForStart, thread );
if( iRet )
if ( iRet )
{
prvFatalError( "pthread_create", iRet );
}
@ -239,7 +231,7 @@ portSTACK_TYPE * pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack,
void vPortStartFirstTask( void )
{
Thread_t * pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
Thread_t *pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
/* Start the first task. */
prvResumeThread( pxFirstThread->pthread );
@ -251,13 +243,13 @@ void vPortStartFirstTask( void )
*/
portBASE_TYPE xPortStartScheduler( void )
{
int iSignal;
sigset_t xSignals;
int iSignal;
sigset_t xSignals;
hMainThread = pthread_self();
/* Start the timer that generates the tick ISR. Interrupts are disabled
* here already. */
here already. */
prvSetupTimerInterrupt();
/* Start the first task. */
@ -267,13 +259,13 @@ portBASE_TYPE xPortStartScheduler( void )
sigemptyset( &xSignals );
sigaddset( &xSignals, SIG_RESUME );
while( !xSchedulerEnd )
while ( !xSchedulerEnd )
{
sigwait( &xSignals, &iSignal );
}
/* Restore original signal mask. */
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
(void)pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
return 0;
}
@ -281,8 +273,8 @@ portBASE_TYPE xPortStartScheduler( void )
void vPortEndScheduler( void )
{
struct itimerval itimer;
struct sigaction sigtick;
struct itimerval itimer;
struct sigaction sigtick;
/* Stop the timer and ignore any pending SIGALRMs that would end
* up running on the main thread when it is resumed. */
@ -291,7 +283,7 @@ void vPortEndScheduler( void )
itimer.it_interval.tv_sec = 0;
itimer.it_interval.tv_usec = 0;
( void ) setitimer( ITIMER_REAL, &itimer, NULL );
(void)setitimer( ITIMER_REAL, &itimer, NULL );
sigtick.sa_flags = 0;
sigtick.sa_handler = SIG_IGN;
@ -300,7 +292,7 @@ void vPortEndScheduler( void )
/* Signal the scheduler to exit its loop. */
xSchedulerEnd = pdTRUE;
( void ) pthread_kill( hMainThread, SIG_RESUME );
(void)pthread_kill( hMainThread, SIG_RESUME );
prvSuspendSelf();
}
@ -308,11 +300,10 @@ void vPortEndScheduler( void )
void vPortEnterCritical( void )
{
if( uxCriticalNesting == 0 )
if ( uxCriticalNesting == 0 )
{
vPortDisableInterrupts();
}
uxCriticalNesting++;
}
/*-----------------------------------------------------------*/
@ -331,8 +322,8 @@ void vPortExitCritical( void )
void vPortYieldFromISR( void )
{
Thread_t * xThreadToSuspend;
Thread_t * xThreadToResume;
Thread_t *xThreadToSuspend;
Thread_t *xThreadToResume;
xThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
@ -369,7 +360,7 @@ void vPortEnableInterrupts( void )
portBASE_TYPE xPortSetInterruptMask( void )
{
/* Interrupts are always disabled inside ISRs (signals
* handlers). */
handlers). */
return pdTRUE;
}
/*-----------------------------------------------------------*/
@ -379,11 +370,11 @@ void vPortClearInterruptMask( portBASE_TYPE xMask )
}
/*-----------------------------------------------------------*/
static uint64_t prvGetTimeNs( void )
static uint64_t prvGetTimeNs(void)
{
struct timespec t;
struct timespec t;
clock_gettime( CLOCK_MONOTONIC, &t );
clock_gettime(CLOCK_MONOTONIC, &t);
return t.tv_sec * 1000000000ull + t.tv_nsec;
}
@ -397,13 +388,12 @@ static uint64_t prvTickCount;
*/
void prvSetupTimerInterrupt( void )
{
struct itimerval itimer;
int iRet;
struct itimerval itimer;
int iRet;
/* Initialise the structure with the current timer information. */
iRet = getitimer( ITIMER_REAL, &itimer );
if( iRet )
if ( iRet )
{
prvFatalError( "getitimer", errno );
}
@ -418,8 +408,7 @@ void prvSetupTimerInterrupt( void )
/* Set-up the timer interrupt. */
iRet = setitimer( ITIMER_REAL, &itimer, NULL );
if( iRet )
if ( iRet )
{
prvFatalError( "setitimer", errno );
}
@ -430,9 +419,9 @@ void prvSetupTimerInterrupt( void )
static void vPortSystemTickHandler( int sig )
{
Thread_t * pxThreadToSuspend;
Thread_t * pxThreadToResume;
uint64_t xExpectedTicks;
Thread_t *pxThreadToSuspend;
Thread_t *pxThreadToResume;
uint64_t xExpectedTicks;
uxCriticalNesting++; /* Signals are blocked in this signal handler. */
@ -440,39 +429,36 @@ static void vPortSystemTickHandler( int sig )
/* Tick Increment, accounting for any lost signals or drift in
* the timer. */
xExpectedTicks = ( prvGetTimeNs() - prvStartTimeNs )
/ ( portTICK_RATE_MICROSECONDS * 1000 );
do
{
xExpectedTicks = (prvGetTimeNs() - prvStartTimeNs)
/ (portTICK_RATE_MICROSECONDS * 1000);
do {
xTaskIncrementTick();
prvTickCount++;
} while( prvTickCount < xExpectedTicks );
} while (prvTickCount < xExpectedTicks);
#if ( configUSE_PREEMPTION == 1 )
#if ( configUSE_PREEMPTION == 1 )
/* Select Next Task. */
vTaskSwitchContext();
pxThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
prvSwitchThread( pxThreadToResume, pxThreadToSuspend );
#endif
prvSwitchThread(pxThreadToResume, pxThreadToSuspend);
#endif
uxCriticalNesting--;
}
/*-----------------------------------------------------------*/
void vPortThreadDying( void * pxTaskToDelete,
volatile BaseType_t * pxPendYield )
void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield )
{
Thread_t * pxThread = prvGetThreadFromTask( pxTaskToDelete );
Thread_t *pxThread = prvGetThreadFromTask( pxTaskToDelete );
pxThread->xDying = pdTRUE;
}
void vPortCancelThread( void * pxTaskToDelete )
void vPortCancelThread( void *pxTaskToDelete )
{
Thread_t * pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
Thread_t *pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
/*
* The thread has already been suspended so it can be safely
@ -483,9 +469,9 @@ void vPortCancelThread( void * pxTaskToDelete )
}
/*-----------------------------------------------------------*/
static void * prvWaitForStart( void * pvParams )
static void *prvWaitForStart( void * pvParams )
{
Thread_t * pxThread = pvParams;
Thread_t *pxThread = pvParams;
prvSuspendSelf();
@ -500,12 +486,12 @@ static void * prvWaitForStart( void * pvParams )
}
/*-----------------------------------------------------------*/
static void prvSwitchThread( Thread_t * pxThreadToResume,
Thread_t * pxThreadToSuspend )
static void prvSwitchThread( Thread_t *pxThreadToResume,
Thread_t *pxThreadToSuspend )
{
BaseType_t uxSavedCriticalNesting;
BaseType_t uxSavedCriticalNesting;
if( pxThreadToSuspend != pxThreadToResume )
if ( pxThreadToSuspend != pxThreadToResume )
{
/*
* Switch tasks.
@ -517,12 +503,10 @@ static void prvSwitchThread( Thread_t * pxThreadToResume,
uxSavedCriticalNesting = uxCriticalNesting;
prvResumeThread( pxThreadToResume->pthread );
if( pxThreadToSuspend->xDying )
if ( pxThreadToSuspend->xDying )
{
pthread_exit( NULL );
}
prvSuspendSelf();
uxCriticalNesting = uxSavedCriticalNesting;
@ -532,7 +516,7 @@ static void prvSwitchThread( Thread_t * pxThreadToResume,
static void prvSuspendSelf( void )
{
int iSig;
int iSig;
/*
* Suspend this thread by waiting for a SIG_RESUME signal.
@ -554,7 +538,7 @@ static void prvSuspendSelf( void )
static void prvResumeThread( pthread_t xThreadId )
{
if( pthread_self() != xThreadId )
if ( pthread_self() != xThreadId )
{
pthread_kill( xThreadId, SIG_RESUME );
}
@ -563,8 +547,8 @@ static void prvResumeThread( pthread_t xThreadId )
static void prvSetupSignalsAndSchedulerPolicy( void )
{
struct sigaction sigresume, sigtick;
int iRet;
struct sigaction sigresume, sigtick;
int iRet;
hMainThread = pthread_self();
@ -572,7 +556,6 @@ static void prvSetupSignalsAndSchedulerPolicy( void )
sigemptyset( &xResumeSignals );
sigaddset( &xResumeSignals, SIG_RESUME );
sigfillset( &xAllSignals );
/* Don't block SIGINT so this can be used to break into GDB while
* in a critical section. */
sigdelset( &xAllSignals, SIGINT );
@ -584,11 +567,11 @@ static void prvSetupSignalsAndSchedulerPolicy( void )
* When a thread is resumed for the first time, all signals
* will be unblocked.
*/
( void ) pthread_sigmask( SIG_SETMASK, &xAllSignals,
(void)pthread_sigmask( SIG_SETMASK, &xAllSignals,
&xSchedulerOriginalSignalMask );
/* SIG_RESUME is only used with sigwait() so doesn't need a
* handler. */
handler. */
sigresume.sa_flags = 0;
sigresume.sa_handler = SIG_IGN;
sigfillset( &sigresume.sa_mask );
@ -598,15 +581,13 @@ static void prvSetupSignalsAndSchedulerPolicy( void )
sigfillset( &sigtick.sa_mask );
iRet = sigaction( SIG_RESUME, &sigresume, NULL );
if( iRet )
if ( iRet )
{
prvFatalError( "sigaction", errno );
}
iRet = sigaction( SIGALRM, &sigtick, NULL );
if( iRet )
if ( iRet )
{
prvFatalError( "sigaction", errno );
}
@ -615,7 +596,7 @@ static void prvSetupSignalsAndSchedulerPolicy( void )
unsigned long ulPortGetRunTime( void )
{
struct tms xTimes;
struct tms xTimes;
times( &xTimes );

View file

@ -27,13 +27,13 @@
#ifndef PORTMACRO_H
#define PORTMACRO_H
#define PORTMACRO_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <limits.h>
#include <limits.h>
/*-----------------------------------------------------------
* Port specific definitions.
@ -46,72 +46,71 @@
*/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE unsigned long
#define portBASE_TYPE long
#define portPOINTER_SIZE_TYPE intptr_t
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE unsigned long
#define portBASE_TYPE long
#define portPOINTER_SIZE_TYPE intptr_t
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
typedef unsigned long TickType_t;
#define portMAX_DELAY ( TickType_t ) ULONG_MAX
typedef unsigned long TickType_t;
#define portMAX_DELAY ( TickType_t ) ULONG_MAX
#define portTICK_TYPE_IS_ATOMIC 1
#define portTICK_TYPE_IS_ATOMIC 1
/*-----------------------------------------------------------*/
/* Architecture specifics. */
#define portSTACK_GROWTH ( -1 )
#define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
#define portSTACK_GROWTH ( -1 )
#define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
/*-----------------------------------------------------------*/
/* Scheduler utilities. */
extern void vPortYield( void );
extern void vPortYield( void );
#define portYIELD() vPortYield()
#define portYIELD() vPortYield()
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/
/* Critical section management. */
extern void vPortDisableInterrupts( void );
extern void vPortEnableInterrupts( void );
#define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
#define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
extern void vPortDisableInterrupts( void );
extern void vPortEnableInterrupts( void );
#define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
#define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
extern portBASE_TYPE xPortSetInterruptMask( void );
extern void vPortClearInterruptMask( portBASE_TYPE xMask );
extern portBASE_TYPE xPortSetInterruptMask( void );
extern void vPortClearInterruptMask( portBASE_TYPE xMask );
extern void vPortEnterCritical( void );
extern void vPortExitCritical( void );
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortClearInterruptMask( x )
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
extern void vPortEnterCritical( void );
extern void vPortExitCritical( void );
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
/*-----------------------------------------------------------*/
extern void vPortThreadDying( void * pxTaskToDelete,
volatile BaseType_t * pxPendYield );
extern void vPortCancelThread( void * pxTaskToDelete );
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
#define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield );
extern void vPortCancelThread( void *pxTaskToDelete );
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
#define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
/*-----------------------------------------------------------*/
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
/*-----------------------------------------------------------*/
/*
@ -122,14 +121,14 @@
* Thus, only a compilier barrier is needed to prevent the compiler
* reordering.
*/
#define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
extern unsigned long ulPortGetRunTime( void );
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
#define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
extern unsigned long ulPortGetRunTime( void );
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
#define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* PORTMACRO_H */