?? portmacro.h
字號:
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)
/************************************************************/
/*
* 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... \
; \
movff PREINC2,PRODL // Use PRODL as tempregister \
clrf STKPTR,ACCESS \
_rtos_R1: \
push \
movf PREINC2,W,ACCESS \
movwf TOSL,ACCESS \
movf PREINC2,W,ACCESS \
movwf TOSH,ACCESS \
if __ROMSIZE > 0x8000 \
movf PREINC2,W,ACCESS \
movwf TOSU,ACCESS \
else \
clrf TOSU,ACCESS \
endif \
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. \
; We cannot yet restore bsr, w and status because \
; we need these registers for a final test. \
; \
movff PREINC2,PCLATH \
if __ROMSIZE > 0x8000 \
movff PREINC2,PCLATU \
else \
clrf PCLATU,ACCESS \
endif \
movff PREINC2,TBLPTRL \
movff PREINC2,TBLPTRH \
if __ROMSIZE > 0x8000 \
movff PREINC2,TBLPTRU \
else \
clrf TBLPTRU,ACCESS \
endif \
movff PREINC2,TABLAT \
movff PREINC2,FSR1L \
movff PREINC2,FSR1H \
movff PREINC2,FSR0L \
movff PREINC2,FSR0H \
movff PREINC2,PRODL \
movff PREINC2,PRODH \
; \
; The return from portRESTORE_CONTEXT() depends on \
; the value of ucCriticalNesting. When it is zero, \
; interrupts need to be enabled. This is done via a \
; 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. \
; \
movlb ucCriticalNesting>>8 \
tstfsz ucCriticalNesting,BANKED \
SMARTJUMP _rtos_R4 \
_rtos_R3: \
movff PREINC2,BSR \
movff PREINC2,WREG \
movff PREINC2,STATUS \
retfie 0 ; Return enabling interrupts \
_rtos_R4: \
movff PREINC2,BSR \
movff PREINC2,WREG \
movff PREINC2,STATUS \
return 0 ; Return without affecting interrupts \
_Pragma("asmend") \
} while(0)
/*-----------------------------------------------------------*/
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
/*-----------------------------------------------------------*/
extern void vPortYield( void );
#define portYIELD() vPortYield()
#define portNOP() _Pragma("asm") \
nop \
_Pragma("asmend")
/*-----------------------------------------------------------*/
#define portTASK_FUNCTION( xFunction, pvParameters ) \
void pointed xFunction( void *pvParameters ) \
_Pragma(asmfunc xFunction)
#define portTASK_FUNCTION_PROTO portTASK_FUNCTION
/*-----------------------------------------------------------*/
#define volatile
#define register
#endif /* PORTMACRO_H */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -