⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 semtest.s43

📁 MSP430 IAR project with FreeRTOS port.
💻 S43
📖 第 1 页 / 共 2 页
字号:
        MOV.W   #0x4, R12
        CALL    #pvPortMalloc
        MOV.W   R12, 0x2(R8)
//  134 			*( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE;
        MOV.W   0x2(R8), R15
        MOV.W   #0xfff, 0(R15)
        MOV.W   #0x0, 0x2(R15)
//  135 			pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_RATE_MS;
        MOV.W   R9, R12
        MOV.W   #0x1, R14
        CALL    #?DivMod16u
        MOV.W   R12, 0x4(R8)
//  136 
//  137 			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "BlkSEM1", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( xTaskHandle * ) NULL );
        PUSH.W  #0x0
        CFI CFA SP+12
        PUSH.W  R10
        CFI CFA SP+14
        PUSH.W  R8
        CFI CFA SP+16
        PUSH.W  #0x40
        CFI CFA SP+18
        MOV.W   #`?<Constant "BlkSEM1">`, R14
        MOV.W   #prvSemaphoreTest, R12
        CALL    #xTaskCreate
//  138 			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "BlkSEM2", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( xTaskHandle * ) NULL );
        PUSH.W  #0x0
        CFI CFA SP+20
        PUSH.W  R10
        CFI CFA SP+22
        PUSH.W  R8
        CFI CFA SP+24
        PUSH.W  #0x40
        CFI CFA SP+26
        MOV.W   #`?<Constant "BlkSEM2">`, R14
        MOV.W   #prvSemaphoreTest, R12
        CALL    #xTaskCreate
        ADD.W   #0x10, SP
        CFI CFA SP+10
//  139 		}
//  140 	}
//  141 }
??vStartSemaphoreTasks_2:
        BR      #?Epilogue4
        CFI EndBlock cfiBlock0
//  142 /*-----------------------------------------------------------*/
//  143 

        RSEG CODE:CODE:REORDER:NOROOT(1)
//  144 static portTASK_FUNCTION( prvSemaphoreTest, pvParameters )
prvSemaphoreTest:
        CFI Block cfiBlock1 Using cfiCommon0
        CFI Function prvSemaphoreTest
//  145 {
        FUNCALL prvSemaphoreTest, xQueueReceive
        LOCFRAME CSTACK, 22, STACK
        FUNCALL prvSemaphoreTest, xQueueSend
        LOCFRAME CSTACK, 22, STACK
        FUNCALL prvSemaphoreTest, vTaskDelay
        LOCFRAME CSTACK, 20, STACK
        FUNCALL prvSemaphoreTest, vPortYield
        LOCFRAME CSTACK, 20, STACK
        PUSH.W  R10
        CFI R10 Frame(CFA, -4)
        CFI CFA SP+4
        PUSH.W  R11
        CFI R11 Frame(CFA, -6)
        CFI CFA SP+6
        PUSH.W  R8
        CFI R8 Frame(CFA, -8)
        CFI CFA SP+8
        PUSH.W  R9
        CFI R9 Frame(CFA, -10)
        CFI CFA SP+10
        PUSH.W  R6
        CFI R6 Frame(CFA, -12)
        CFI CFA SP+12
        PUSH.W  R7
        CFI R7 Frame(CFA, -14)
        CFI CFA SP+14
        PUSH.W  R4
        CFI R4 Frame(CFA, -16)
        CFI CFA SP+16
        SUB.W   #0x4, SP
        CFI CFA SP+20
        MOV.W   R12, R8
//  146 xSemaphoreParameters *pxParameters;
//  147 volatile unsigned portLONG *pulSharedVariable, ulExpectedValue;
//  148 unsigned portLONG ulCounter;
//  149 portSHORT sError = pdFALSE, sCheckVariableToUse;
        MOV.W   #0x0, R7
//  150 
//  151 	/* See which check variable to use.  sNextCheckVariable is not semaphore 
//  152 	protected! */
//  153 	portENTER_CRITICAL();
        DINT
        NOP
        ADD.W   #0x1, &usCriticalNesting
//  154 		sCheckVariableToUse = sNextCheckVariable;
        MOV.W   &sNextCheckVariable, R4
//  155 		sNextCheckVariable++;
        ADD.W   #0x1, &sNextCheckVariable
//  156 	portEXIT_CRITICAL();
        CMP.W   #0x0, &usCriticalNesting
        JEQ     ??prvSemaphoreTest_2
        ADD.W   #0xffff, &usCriticalNesting
        CMP.W   #0x0, &usCriticalNesting
        JNE     ??prvSemaphoreTest_2
        EINT
//  157 
//  158 	/* A structure is passed in as the parameter.  This contains the shared 
//  159 	variable being guarded. */
//  160 	pxParameters = ( xSemaphoreParameters * ) pvParameters;
??prvSemaphoreTest_2:
        MOV.W   R8, R9
//  161 	pulSharedVariable = pxParameters->pulSharedVariable;
        MOV.W   0x2(R9), R6
//  162 
//  163 	/* If we are blocking we use a much higher count to ensure loads of context
//  164 	switches occur during the count. */
//  165 	if( pxParameters->xBlockTime > ( portTickType ) 0 )
        CMP.W   #0x0, 0x4(R9)
        JEQ     ??prvSemaphoreTest_3
//  166 	{
//  167 		ulExpectedValue = semtstBLOCKING_EXPECTED_VALUE;
        MOV.W   #0xfff, 0x0(SP)
        MOV.W   #0x0, 0x2(SP)
        JMP     ??prvSemaphoreTest_1
//  168 	}
//  169 	else
//  170 	{
//  171 		ulExpectedValue = semtstNON_BLOCKING_EXPECTED_VALUE;
??prvSemaphoreTest_3:
        MOV.W   #0xff, 0x0(SP)
        MOV.W   #0x0, 0x2(SP)
//  172 	}
//  173 
//  174 	for( ;; )
//  175 	{
//  176 		/* Try to obtain the semaphore. */
//  177 		if( xSemaphoreTake( pxParameters->xSemaphore, pxParameters->xBlockTime ) == pdPASS )
??prvSemaphoreTest_1:
        PUSH.W  0x4(R9)
        CFI CFA SP+22
        MOV.W   #0x0, R14
        MOV.W   @R9, R12
        CALL    #xQueueReceive
        ADD.W   #0x2, SP
        CFI CFA SP+20
        CMP.W   #0x1, R12
        JNE     ??prvSemaphoreTest_4
//  178 		{
//  179 			/* We have the semaphore and so expect any other tasks using the
//  180 			shared variable to have left it in the state we expect to find
//  181 			it. */
//  182 			if( *pulSharedVariable != ulExpectedValue )
        CMP.W   0x0(SP), 0x0(R6)
        JNE     ??prvSemaphoreTest_5
        CMP.W   0x2(SP), 0x2(R6)
        JEQ     ??prvSemaphoreTest_6
//  183 			{
//  184 				sError = pdTRUE;
??prvSemaphoreTest_5:
        MOV.W   #0x1, R7
//  185 			}
//  186 			
//  187 			/* Clear the variable, then count it back up to the expected value
//  188 			before releasing the semaphore.  Would expect a context switch or
//  189 			two during this time. */
//  190 			for( ulCounter = ( unsigned portLONG ) 0; ulCounter <= ulExpectedValue; ulCounter++ )
??prvSemaphoreTest_6:
        MOV.W   #0x0, R10
        MOV.W   #0x0, R11
??prvSemaphoreTest_0:
        CMP.W   R11, 0x2(SP)
        JNC     ??prvSemaphoreTest_7
        JNE     ??prvSemaphoreTest_8
        CMP.W   R10, 0x0(SP)
        JNC     ??prvSemaphoreTest_7
//  191 			{
//  192 				*pulSharedVariable = ulCounter;
??prvSemaphoreTest_8:
        MOV.W   R10, 0(R6)
        MOV.W   R11, 0x2(R6)
//  193 				if( *pulSharedVariable != ulCounter )
        CMP.W   R10, 0x0(R6)
        JNE     ??prvSemaphoreTest_9
        CMP.W   R11, 0x2(R6)
        JEQ     ??prvSemaphoreTest_10
//  194 				{
//  195 					sError = pdTRUE;
??prvSemaphoreTest_9:
        MOV.W   #0x1, R7
//  196 				}
//  197 			}
??prvSemaphoreTest_10:
        ADD.W   #0x1, R10
        ADDC.W  #0x0, R11
        JMP     ??prvSemaphoreTest_0
//  198 
//  199 			/* Release the semaphore, and if no errors have occurred increment the check
//  200 			variable. */
//  201 			if(	xSemaphoreGive( pxParameters->xSemaphore ) == pdFALSE )
??prvSemaphoreTest_7:
        PUSH.W  #0x0
        CFI CFA SP+22
        MOV.W   #0x0, R14
        MOV.W   @R9, R12
        CALL    #xQueueSend
        ADD.W   #0x2, SP
        CFI CFA SP+20
        CMP.W   #0x0, R12
        JNE     ??prvSemaphoreTest_11
//  202 			{
//  203 				sError = pdTRUE;
        MOV.W   #0x1, R7
//  204 			}
//  205 
//  206 			if( sError == pdFALSE )
??prvSemaphoreTest_11:
        CMP.W   #0x0, R7
        JNE     ??prvSemaphoreTest_12
//  207 			{
//  208 				if( sCheckVariableToUse < semtstNUM_TASKS )
        CMP.W   #0x4, R4
        JGE     ??prvSemaphoreTest_12
//  209 				{
//  210 					( sCheckVariables[ sCheckVariableToUse ] )++;
        MOV.W   R4, R15
        RLA.W   R15
        ADD.W   #0x1, sCheckVariables(R15)
//  211 				}
//  212 			}
//  213 
//  214 			/* If we have a block time then we are running at a priority higher
//  215 			than the idle priority.  This task takes a long time to complete
//  216 			a cycle	(deliberately so to test the guarding) so will be starving
//  217 			out lower priority tasks.  Block for some time to allow give lower
//  218 			priority tasks some processor time. */
//  219 			vTaskDelay( pxParameters->xBlockTime * semtstDELAY_FACTOR );
??prvSemaphoreTest_12:
        MOV.W   0x4(R9), R12
        RLA.W   R12
        MOV.W   R12, R15
        RLA.W   R12
        RLA.W   R12
        ADD.W   R15, R12
        CALL    #vTaskDelay
        JMP     ??prvSemaphoreTest_1
//  220 		}
//  221 		else
//  222 		{
//  223 			if( pxParameters->xBlockTime == ( portTickType ) 0 )
??prvSemaphoreTest_4:
        CMP.W   #0x0, 0x4(R9)
        JNE     ??prvSemaphoreTest_1
//  224 			{
//  225 				/* We have not got the semaphore yet, so no point using the
//  226 				processor.  We are not blocking when attempting to obtain the
//  227 				semaphore. */
//  228 				taskYIELD();
        CALL    #vPortYield
        JMP     ??prvSemaphoreTest_1
        CFI EndBlock cfiBlock1
//  229 			}
//  230 		}
//  231 	}
//  232 }
//  233 /*-----------------------------------------------------------*/
//  234 
//  235 /* This is called to check that all the created tasks are still running. */

        RSEG CODE:CODE:REORDER:NOROOT(1)
//  236 portBASE_TYPE xAreSemaphoreTasksStillRunning( void )
xAreSemaphoreTasksStillRunning:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function xAreSemaphoreTasksStillRunning
//  237 {
        PUSH.W  R10
        CFI R10 Frame(CFA, -4)
        CFI CFA SP+4
//  238 static portSHORT sLastCheckVariables[ semtstNUM_TASKS ] = { 0 };
//  239 portBASE_TYPE xTask, xReturn = pdTRUE;
        MOV.W   #0x1, R12
//  240 
//  241 	for( xTask = 0; xTask < semtstNUM_TASKS; xTask++ )
        MOV.W   #0x0, R14
??xAreSemaphoreTasksStillRunning_0:
        CMP.W   #0x4, R14
        JGE     ??xAreSemaphoreTasksStillRunning_1
//  242 	{
//  243 		if( sLastCheckVariables[ xTask ] == sCheckVariables[ xTask ] )
        MOV.W   R14, R13
        RLA.W   R13
        MOV.W   R14, R15
        RLA.W   R15
        CMP.W   sCheckVariables(R15), ??sLastCheckVariables(R13)
        JNE     ??xAreSemaphoreTasksStillRunning_2
//  244 		{
//  245 			xReturn = pdFALSE;
        MOV.W   #0x0, R12
//  246 		}
//  247 
//  248 		sLastCheckVariables[ xTask ] = sCheckVariables[ xTask ];
??xAreSemaphoreTasksStillRunning_2:
        MOV.W   R14, R13
        RLA.W   R13
        MOV.W   R14, R15
        RLA.W   R15
        MOV.W   sCheckVariables(R13), ??sLastCheckVariables(R15)
//  249 	}
        ADD.W   #0x1, R14
        JMP     ??xAreSemaphoreTasksStillRunning_0
//  250 
//  251 	return xReturn;
??xAreSemaphoreTasksStillRunning_1:
        POP.W   R10
        CFI R10 SameValue
        CFI CFA SP+2
        RET
        CFI EndBlock cfiBlock2
//  252 }

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
??sLastCheckVariables:
        DS8 8

        RSEG CODE:CODE:REORDER:NOROOT(1)
?setjmp_save_r4:
        REQUIRE ?setjmp_r4
        REQUIRE ?longjmp_r4

        RSEG CODE:CODE:REORDER:NOROOT(1)
?setjmp_save_r5:
        REQUIRE ?setjmp_r5
        REQUIRE ?longjmp_r5

        RSEG DATA16_C:CONST:SORT:NOROOT(0)
`?<Constant "PolSEM1">`:
        DC8 "PolSEM1"

        RSEG DATA16_C:CONST:SORT:NOROOT(0)
`?<Constant "PolSEM2">`:
        DC8 "PolSEM2"

        RSEG DATA16_C:CONST:SORT:NOROOT(0)
`?<Constant "BlkSEM1">`:
        DC8 "BlkSEM1"

        RSEG DATA16_C:CONST:SORT:NOROOT(0)
`?<Constant "BlkSEM2">`:
        DC8 "BlkSEM2"

        END
//  253 
//  254 
// 
// 562 bytes in segment CODE
//  32 bytes in segment DATA16_C
//  18 bytes in segment DATA16_Z
// 
// 562 bytes of CODE  memory
//  32 bytes of CONST memory
//  18 bytes of DATA  memory
//
//Errors: none
//Warnings: 1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -