📄 portext.s43
字号:
; FreeRTOS V4.0.1 - Copyright (C) 2003 - 2006 Richard Barry.
;
#include "..\..\App\FreeRTOSConfig_asm.h"
; #include "portmacro.h"
; reference externals
; EXTERN _pxCurrentTCB
; NAME portSAVE_CONTEXT
EXTERN usCriticalNesting
EXTERN pxCurrentTCB
EXTERN vTaskIncrementTick
EXTERN vTaskSwitchContext
EXTERN prvSetupTimerInterrupt
PUBLIC vTickISR
PUBLIC vPortYield
PUBLIC xPortStartScheduler
portSAVE_CONTEXT MACRO
push r4
push r5
push r6
push r7
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
mov.w &usCriticalNesting, r14
push r14
mov.w &pxCurrentTCB, r12
mov.w r1, 0(r12)
ENDM
; mov.w &_usCriticalNesting, r14
// XXX: Check to see if someone needs R12... R12 is a GP register...
; mov.w &_pxCurrentTCB, r12
; this mode isn't allowed by the TI MSP430 instruction set...
; indirect register mode for the destination isn't allowed
; use substitution as pointed out in UG...
; mov.w r1, @r12
; // mov.w r1, &_pxCurrentTCB
/*-----------------------------------------------------------*/
// ; NAME portRESTORE_CONTEXT
portRESTORE_CONTEXT MACRO
mov.w &pxCurrentTCB, r12
mov.w @r12, r1
pop r15
mov.w r15, &usCriticalNesting
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop r7
pop r6
pop r5
pop r4
reti
ENDM
; mov.w &_pxCurrentTCB, r12
; mov.w r15, &_usCriticalNesting
/*-----------------------------------------------------------*/
/* .CODE */ /* xxx CHECK TO MAKE SURE THIS IS FIXED UP */
; RSEG CODE
; locate this in a 'conveniently available' section of memory
ORG 0F500h
/*
* The RTOS tick ISR.
*
* If the cooperative scheduler is in use this simply increments the tick
* count.
*
* If the preemptive scheduler is in use a context switch can also occur.
*/
vTickISR
portSAVE_CONTEXT
call #vTaskIncrementTick
#if configUSE_PREEMPTION == 1
call #vTaskSwitchContext
#endif
portRESTORE_CONTEXT
/*-----------------------------------------------------------*/
/*
* Manual context switch called by the portYIELD() macro.
*/
vPortYield:
/* Mimic an interrupt by pushing the SR. */
push SR
/* Now the SR is stacked we can disable interrupts. */
dint
/* Save the context of the current task. */
portSAVE_CONTEXT
/* Switch to the highest priority task that is ready to run. */
call #vTaskSwitchContext
/* Restore the context of the new task. */
portRESTORE_CONTEXT
/*-----------------------------------------------------------*/
/*
* Start off the scheduler by initialising the RTOS tick timer, then restoring
* the context of the first task.
*/
xPortStartScheduler:
/* Setup the hardware to generate the tick. Interrupts are disabled
when this function is called. */
; call #timer_A_init ; call timer A 'clock'
call #prvSetupTimerInterrupt
/* Restore the context of the first task that is going to run. */
portRESTORE_CONTEXT
/*-----------------------------------------------------------*/
/* Place the tick ISR in the correct vector. */
/* .VECTORS
.KEEP
*/
COMMON INTVEC:CODE:ROOT(1)
ORG TIMERA0_VECTOR
DW vTickISR
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -