mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-20 10:08:33 -04:00
Style: uncrusitfy
This commit is contained in:
parent
a5dbc2b1de
commit
718178c68a
406 changed files with 108795 additions and 106323 deletions
|
@ -25,46 +25,46 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
Changes from V3.0.0
|
||||
|
||||
Changes from V3.0.1
|
||||
*/
|
||||
* Changes from V3.0.0
|
||||
*
|
||||
* Changes from V3.0.1
|
||||
*/
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#if !defined(_SERIES) || _SERIES != 18
|
||||
#error "WizC supports FreeRTOS on the Microchip PIC18-series only"
|
||||
#endif
|
||||
#if !defined( _SERIES ) || _SERIES != 18
|
||||
#error "WizC supports FreeRTOS on the Microchip PIC18-series only"
|
||||
#endif
|
||||
|
||||
#if !defined(QUICKCALL) || QUICKCALL != 1
|
||||
#error "QuickCall must be enabled (see ProjectOptions/Optimisations)"
|
||||
#endif
|
||||
#if !defined( QUICKCALL ) || QUICKCALL != 1
|
||||
#error "QuickCall must be enabled (see ProjectOptions/Optimisations)"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <pic.h>
|
||||
#include <stddef.h>
|
||||
#include <pic.h>
|
||||
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE portFLOAT
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE uint8_t
|
||||
#define portBASE_TYPE char
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE portFLOAT
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE uint8_t
|
||||
#define portBASE_TYPE char
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef signed char BaseType_t;
|
||||
typedef unsigned char UBaseType_t;
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef signed char BaseType_t;
|
||||
typedef unsigned char UBaseType_t;
|
||||
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) ( 0xFFFF )
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFF )
|
||||
#endif
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) ( 0xFFFF )
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFF )
|
||||
#endif
|
||||
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -72,78 +72,78 @@ typedef unsigned char UBaseType_t;
|
|||
* Constant used for context switch macro when we require the interrupt
|
||||
* enable state to be forced when the interrupted task is switched back in.
|
||||
*/
|
||||
#define portINTERRUPTS_FORCED (0x01)
|
||||
#define portINTERRUPTS_FORCED ( 0x01 )
|
||||
|
||||
/*
|
||||
* Constant used for context switch macro when we require the interrupt
|
||||
* enable state to be unchanged when the interrupted task is switched back in.
|
||||
*/
|
||||
#define portINTERRUPTS_UNCHANGED (0x00)
|
||||
#define portINTERRUPTS_UNCHANGED ( 0x00 )
|
||||
|
||||
/* Initial interrupt enable state for newly created tasks. This value is
|
||||
* used when a task switches in for the first time.
|
||||
*/
|
||||
#define portINTERRUPTS_INITIAL_STATE (portINTERRUPTS_FORCED)
|
||||
#define portINTERRUPTS_INITIAL_STATE ( portINTERRUPTS_FORCED )
|
||||
|
||||
/*
|
||||
* Macros to modify the global interrupt enable bit in INTCON.
|
||||
*/
|
||||
#define portDISABLE_INTERRUPTS() \
|
||||
do \
|
||||
{ \
|
||||
bGIE=0; \
|
||||
} while(bGIE) // MicroChip recommends this check!
|
||||
#define portDISABLE_INTERRUPTS() \
|
||||
do \
|
||||
{ \
|
||||
bGIE = 0; \
|
||||
} while( bGIE ) /* MicroChip recommends this check! */
|
||||
|
||||
#define portENABLE_INTERRUPTS() \
|
||||
do \
|
||||
{ \
|
||||
bGIE=1; \
|
||||
} while(0)
|
||||
#define portENABLE_INTERRUPTS() \
|
||||
do \
|
||||
{ \
|
||||
bGIE = 1; \
|
||||
} while( 0 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Critical section macros.
|
||||
*/
|
||||
extern uint8_t ucCriticalNesting;
|
||||
extern uint8_t ucCriticalNesting;
|
||||
|
||||
#define portNO_CRITICAL_SECTION_NESTING ( ( uint8_t ) 0 )
|
||||
#define portNO_CRITICAL_SECTION_NESTING ( ( uint8_t ) 0 )
|
||||
|
||||
#define portENTER_CRITICAL() \
|
||||
do \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
\
|
||||
/* \
|
||||
* Now interrupts are disabled ucCriticalNesting \
|
||||
* can be accessed directly. Increment \
|
||||
* ucCriticalNesting to keep a count of how \
|
||||
* many times portENTER_CRITICAL() has been called. \
|
||||
*/ \
|
||||
ucCriticalNesting++; \
|
||||
} while(0)
|
||||
#define portENTER_CRITICAL() \
|
||||
do \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
\
|
||||
/* \
|
||||
* Now interrupts are disabled ucCriticalNesting \
|
||||
* can be accessed directly. Increment \
|
||||
* ucCriticalNesting to keep a count of how \
|
||||
* many times portENTER_CRITICAL() has been called. \
|
||||
*/ \
|
||||
ucCriticalNesting++; \
|
||||
} while( 0 )
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
do \
|
||||
{ \
|
||||
if(ucCriticalNesting > portNO_CRITICAL_SECTION_NESTING) \
|
||||
{ \
|
||||
/* \
|
||||
* Decrement the nesting count as we are leaving a \
|
||||
* critical section. \
|
||||
*/ \
|
||||
ucCriticalNesting--; \
|
||||
} \
|
||||
\
|
||||
/* \
|
||||
* If the nesting level has reached zero then \
|
||||
* interrupts should be re-enabled. \
|
||||
*/ \
|
||||
if( ucCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \
|
||||
{ \
|
||||
portENABLE_INTERRUPTS(); \
|
||||
} \
|
||||
} while(0)
|
||||
#define portEXIT_CRITICAL() \
|
||||
do \
|
||||
{ \
|
||||
if( ucCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \
|
||||
{ \
|
||||
/* \
|
||||
* Decrement the nesting count as we are leaving a \
|
||||
* critical section. \
|
||||
*/ \
|
||||
ucCriticalNesting--; \
|
||||
} \
|
||||
\
|
||||
/* \
|
||||
* If the nesting level has reached zero then \
|
||||
* interrupts should be re-enabled. \
|
||||
*/ \
|
||||
if( ucCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \
|
||||
{ \
|
||||
portENABLE_INTERRUPTS(); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -152,18 +152,18 @@ extern uint8_t ucCriticalNesting;
|
|||
* portMINIMAL_STACK_SIZE. Some input to this calculation is
|
||||
* compiletime determined, other input is port-defined (see port.c)
|
||||
*/
|
||||
extern uint16_t usPortCALCULATE_MINIMAL_STACK_SIZE( void );
|
||||
extern uint16_t usCalcMinStackSize;
|
||||
extern uint16_t usPortCALCULATE_MINIMAL_STACK_SIZE( void );
|
||||
extern uint16_t usCalcMinStackSize;
|
||||
|
||||
#define portMINIMAL_STACK_SIZE \
|
||||
((usCalcMinStackSize == 0) \
|
||||
? usPortCALCULATE_MINIMAL_STACK_SIZE() \
|
||||
: usCalcMinStackSize )
|
||||
#define portMINIMAL_STACK_SIZE \
|
||||
( ( usCalcMinStackSize == 0 ) \
|
||||
? usPortCALCULATE_MINIMAL_STACK_SIZE() \
|
||||
: usCalcMinStackSize )
|
||||
|
||||
/*
|
||||
* WizC uses a downgrowing stack
|
||||
*/
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -199,120 +199,120 @@ extern uint16_t usCalcMinStackSize;
|
|||
* assembler definitions.
|
||||
*/
|
||||
|
||||
#define portSAVE_CONTEXT( ucInterruptForced ) \
|
||||
do \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
\
|
||||
_Pragma("asm") \
|
||||
; \
|
||||
; Push the relevant SFR's onto the task's stack \
|
||||
; \
|
||||
movff STATUS,POSTDEC2 \
|
||||
movff WREG,POSTDEC2 \
|
||||
movff BSR,POSTDEC2 \
|
||||
movff PRODH,POSTDEC2 \
|
||||
movff PRODL,POSTDEC2 \
|
||||
movff FSR0H,POSTDEC2 \
|
||||
movff FSR0L,POSTDEC2 \
|
||||
movff FSR1H,POSTDEC2 \
|
||||
movff FSR1L,POSTDEC2 \
|
||||
movff TABLAT,POSTDEC2 \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff TBLPTRU,POSTDEC2 \
|
||||
endif \
|
||||
movff TBLPTRH,POSTDEC2 \
|
||||
movff TBLPTRL,POSTDEC2 \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff PCLATU,POSTDEC2 \
|
||||
endif \
|
||||
movff PCLATH,POSTDEC2 \
|
||||
; \
|
||||
; Store the compiler-scratch-area as described above. \
|
||||
; \
|
||||
movlw OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE \
|
||||
clrf FSR0L,ACCESS \
|
||||
clrf FSR0H,ACCESS \
|
||||
_rtos_S1: \
|
||||
movff POSTINC0,POSTDEC2 \
|
||||
decfsz WREG,W,ACCESS \
|
||||
SMARTJUMP _rtos_S1 \
|
||||
; \
|
||||
; Save the pic call/return-stack belonging to the \
|
||||
; current task by copying it to the task's software- \
|
||||
#define portSAVE_CONTEXT( ucInterruptForced ) \
|
||||
do \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
\
|
||||
_Pragma( "asm" ) \
|
||||
; \
|
||||
; Push the relevant SFR 's onto the task's stack \
|
||||
; \
|
||||
movff STATUS, POSTDEC2 \
|
||||
movff WREG, POSTDEC2 \
|
||||
movff BSR, POSTDEC2 \
|
||||
movff PRODH, POSTDEC2 \
|
||||
movff PRODL, POSTDEC2 \
|
||||
movff FSR0H, POSTDEC2 \
|
||||
movff FSR0L, POSTDEC2 \
|
||||
movff FSR1H, POSTDEC2 \
|
||||
movff FSR1L, POSTDEC2 \
|
||||
movff TABLAT, POSTDEC2 \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff TBLPTRU, POSTDEC2 \
|
||||
endif \
|
||||
movff TBLPTRH, POSTDEC2 \
|
||||
movff TBLPTRL, POSTDEC2 \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff PCLATU, POSTDEC2 \
|
||||
endif \
|
||||
movff PCLATH, POSTDEC2 \
|
||||
; \
|
||||
; Store the compiler - scratch - area as described above. \
|
||||
; \
|
||||
movlw OVERHEADPAGE0 - LOCOPTSIZE + MAXLOCOPTSIZE \
|
||||
clrf FSR0L, ACCESS \
|
||||
clrf FSR0H, ACCESS \
|
||||
_rtos_S1: \
|
||||
movff POSTINC0, POSTDEC2 \
|
||||
decfsz WREG, W, ACCESS \
|
||||
SMARTJUMP _rtos_S1 \
|
||||
; \
|
||||
; Save the pic call / return -stack belonging to the \
|
||||
; current task by copying it to the task 's software- \
|
||||
; stack. We save the hardware stack pointer (which \
|
||||
; is the number of addresses on the stack) in the \
|
||||
; W-register first because we need it later and it \
|
||||
; is modified in the save-loop by executing pop's. \
|
||||
; After the loop the W-register is stored on the \
|
||||
; stack, too. \
|
||||
; \
|
||||
movf STKPTR,W,ACCESS \
|
||||
bz _rtos_s3 \
|
||||
_rtos_S2: \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff TOSU,POSTDEC2 \
|
||||
endif \
|
||||
movff TOSH,POSTDEC2 \
|
||||
movff TOSL,POSTDEC2 \
|
||||
pop \
|
||||
tstfsz STKPTR,ACCESS \
|
||||
SMARTJUMP _rtos_S2 \
|
||||
_rtos_s3: \
|
||||
movwf POSTDEC2,ACCESS \
|
||||
; \
|
||||
; Next the value for ucCriticalNesting used by the \
|
||||
; task is stored on the stack. When \
|
||||
; (ucInterruptForced == portINTERRUPTS_FORCED), we save \
|
||||
; it as 0 (portNO_CRITICAL_SECTION_NESTING). \
|
||||
; \
|
||||
if ucInterruptForced == portINTERRUPTS_FORCED \
|
||||
clrf POSTDEC2,ACCESS \
|
||||
else \
|
||||
movff ucCriticalNesting,POSTDEC2 \
|
||||
endif \
|
||||
; \
|
||||
; Save the new top of the software stack in the TCB. \
|
||||
; \
|
||||
movff pxCurrentTCB,FSR0L \
|
||||
movff pxCurrentTCB+1,FSR0H \
|
||||
movff FSR2L,POSTINC0 \
|
||||
movff FSR2H,POSTINC0 \
|
||||
_Pragma("asmend") \
|
||||
} while(0)
|
||||
; is modified in the save-loop by executing pop's. \
|
||||
; After the loop the W - register is stored on the \
|
||||
; stack, too. \
|
||||
; \
|
||||
movf STKPTR, W, ACCESS \
|
||||
bz _rtos_s3 \
|
||||
_rtos_S2: \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff TOSU, POSTDEC2 \
|
||||
endif \
|
||||
movff TOSH, POSTDEC2 \
|
||||
movff TOSL, POSTDEC2 \
|
||||
pop \
|
||||
tstfsz STKPTR, ACCESS \
|
||||
SMARTJUMP _rtos_S2 \
|
||||
_rtos_s3: \
|
||||
movwf POSTDEC2, ACCESS \
|
||||
; \
|
||||
; Next the value for ucCriticalNesting used by the \
|
||||
; task is stored on the stack.When \
|
||||
; ( ucInterruptForced == portINTERRUPTS_FORCED ), we save \
|
||||
; it as 0 ( portNO_CRITICAL_SECTION_NESTING ). \
|
||||
; \
|
||||
if ucInterruptForced == portINTERRUPTS_FORCED \
|
||||
clrf POSTDEC2, ACCESS \
|
||||
else{ \
|
||||
movff ucCriticalNesting, POSTDEC2 \
|
||||
endif \
|
||||
; } \
|
||||
; Save the new top of the software stack in the TCB. \
|
||||
; \
|
||||
movff pxCurrentTCB, FSR0L \
|
||||
movff pxCurrentTCB + 1, FSR0H \
|
||||
movff FSR2L, POSTINC0 \
|
||||
movff FSR2H, POSTINC0 \
|
||||
_Pragma( "asmend" ) \
|
||||
} while( 0 )
|
||||
|
||||
/************************************************************/
|
||||
|
||||
/*
|
||||
* This is the reverse of portSAVE_CONTEXT.
|
||||
*/
|
||||
#define portRESTORE_CONTEXT() \
|
||||
do \
|
||||
{ \
|
||||
_Pragma("asm") \
|
||||
; \
|
||||
; Set FSR0 to point to pxCurrentTCB->pxTopOfStack. \
|
||||
; \
|
||||
movff pxCurrentTCB,FSR0L \
|
||||
movff pxCurrentTCB+1,FSR0H \
|
||||
; \
|
||||
; De-reference FSR0 to set the address it holds into \
|
||||
; FSR2 (i.e. *( pxCurrentTCB->pxTopOfStack ) ). FSR2 \
|
||||
; is used by wizC as stackpointer. \
|
||||
; \
|
||||
movff POSTINC0,FSR2L \
|
||||
movff POSTINC0,FSR2H \
|
||||
; \
|
||||
; Next, the value for ucCriticalNesting used by the \
|
||||
; task is retrieved from the stack. \
|
||||
; \
|
||||
movff PREINC2,ucCriticalNesting \
|
||||
; \
|
||||
; Rebuild the pic call/return-stack. The number of \
|
||||
; return addresses is the next item on the task stack. \
|
||||
; Save this number in PRODL. Then fetch the addresses \
|
||||
; and store them on the hardwarestack. \
|
||||
; The datasheets say we can't use movff here... \
|
||||
#define portRESTORE_CONTEXT() \
|
||||
do \
|
||||
{ \
|
||||
_Pragma( "asm" ) \
|
||||
; \
|
||||
; Set FSR0 to point to pxCurrentTCB->pxTopOfStack. \
|
||||
; \
|
||||
movff pxCurrentTCB, FSR0L \
|
||||
movff pxCurrentTCB + 1, FSR0H \
|
||||
; \
|
||||
; De - reference FSR0 to set the address it holds into \
|
||||
; FSR2( i.e. *( pxCurrentTCB->pxTopOfStack ) ).FSR2 \
|
||||
; is used by wizC as stackpointer. \
|
||||
; \
|
||||
movff POSTINC0, FSR2L \
|
||||
movff POSTINC0, FSR2H \
|
||||
; \
|
||||
; Next, the value for ucCriticalNesting used by the \
|
||||
; task is retrieved from the stack. \
|
||||
; \
|
||||
movff PREINC2, ucCriticalNesting \
|
||||
; \
|
||||
; Rebuild the pic call / return -stack.The number of \
|
||||
; return addresses is the next item on the task stack. \
|
||||
; Save this number in PRODL.Then fetch the addresses \
|
||||
; and store them on the hardwarestack. \
|
||||
; The datasheets say we can 't use movff here... \
|
||||
; \
|
||||
movff PREINC2,PRODL // Use PRODL as tempregister \
|
||||
clrf STKPTR,ACCESS \
|
||||
|
@ -331,18 +331,18 @@ extern uint16_t usCalcMinStackSize;
|
|||
decfsz PRODL,F,ACCESS \
|
||||
SMARTJUMP _rtos_R1 \
|
||||
; \
|
||||
; Restore the compiler's working storage area to page 0 \
|
||||
; \
|
||||
movlw OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE \
|
||||
movwf FSR0L,ACCESS \
|
||||
clrf FSR0H,ACCESS \
|
||||
_rtos_R2: \
|
||||
decf FSR0L,F,ACCESS \
|
||||
movff PREINC2,INDF0 \
|
||||
tstfsz FSR0L,ACCESS \
|
||||
SMARTJUMP _rtos_R2 \
|
||||
; \
|
||||
; Restore the sfr's forming the tasks context. \
|
||||
; Restore the compiler's working storage area to page 0 \
|
||||
; \
|
||||
movlw OVERHEADPAGE0 - LOCOPTSIZE + MAXLOCOPTSIZE \
|
||||
movwf FSR0L, ACCESS \
|
||||
clrf FSR0H, ACCESS \
|
||||
_rtos_R2: \
|
||||
decf FSR0L, F, ACCESS \
|
||||
movff PREINC2, INDF0 \
|
||||
tstfsz FSR0L, ACCESS \
|
||||
SMARTJUMP _rtos_R2 \
|
||||
; \
|
||||
; Restore the sfr 's forming the tasks context. \
|
||||
; We cannot yet restore bsr, w and status because \
|
||||
; we need these registers for a final test. \
|
||||
; \
|
||||
|
@ -373,8 +373,8 @@ extern uint16_t usCalcMinStackSize;
|
|||
; retfie instruction because we need the \
|
||||
; interrupt-enabling and the return to the restored \
|
||||
; task to be uninterruptable. \
|
||||
; Because bsr, status and W are affected by the test \
|
||||
; they are restored after the test. \
|
||||
; Because bsr, status and W are affected by the test \
|
||||
; they are restored after the test. \
|
||||
; \
|
||||
movlb ucCriticalNesting>>8 \
|
||||
tstfsz ucCriticalNesting,BANKED \
|
||||
|
@ -407,7 +407,7 @@ extern void vPortYield( void );
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define portTASK_FUNCTION( xFunction, pvParameters ) \
|
||||
#define portTASK_FUNCTION( xFunction, pvParameters ) \
|
||||
void pointed xFunction( void *pvParameters ) \
|
||||
_Pragma(asmfunc xFunction)
|
||||
|
||||
|
@ -420,3 +420,4 @@ extern void vPortYield( void );
|
|||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue