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

📄 semtest.s43

📁 MSP430 IAR project with FreeRTOS port.
💻 S43
📖 第 1 页 / 共 2 页
字号:
//////////////////////////////////////////////////////////////////////////////
//                                                                           /
// IAR MSP430 C/C++ Compiler V3.41A/W32                22/Apr/2006  00:25:16 /
// Copyright 1996-2006 IAR Systems. All rights reserved.                     /
//                                                                           /
//    __rt_version  =  2                                                     /
//    __double_size =  32                                                    /
//    __reg_r4      =  free                                                  /
//    __reg_r5      =  free                                                  /
//    __pic         =  no                                                    /
//    __core        =  64kb                                                  /
//    Source file   =  C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\Common\Mini /
//                     mal\semtest.c                                         /
//    Command line  =  C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\Common\Mini /
//                     mal\semtest.c -D ROWLEY_MSP430 -D IAR_MSP430 -lC      /
//                     C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\List\ -lA  /
//                     C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\List\      /
//                     --remarks -o C:\MSP430F169_Eval_Port\FreeRTOSv401\Deb /
//                     ug\Obj\ -s2 --no_cse --no_unroll --no_inline          /
//                     --no_code_motion --no_tbaa --debug -e                 /
//                     --migration_preprocessor_extensions --double=32 -I    /
//                     C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\Common\Incl /
//                     ude\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Source\I /
//                     nclude\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\ /
//                     MSP430_IAR\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\S /
//                     ource\portable\msp430f1611\ -I "C:\Program Files\IAR  /
//                     Systems\Embedded Workbench 4.0\430\INC\" -I           /
//                     "C:\Program Files\IAR Systems\Embedded Workbench      /
//                     4.0\430\INC\CLIB\"                                    /
//    List file     =  C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\List\semte /
//                     st.s43                                                /
//                                                                           /
//                                                                           /
//////////////////////////////////////////////////////////////////////////////

        NAME semtest

        RTMODEL "__core", "64kb"
        RTMODEL "__double_size", "32"
        RTMODEL "__pic", "no"
        RTMODEL "__reg_r4", "free"
        RTMODEL "__reg_r5", "free"
        RTMODEL "__rt_version", "2"

        RSEG CSTACK:DATA:SORT:NOROOT(1)

        EXTERN ?Epilogue7
        EXTERN ?Epilogue4
        EXTERN ?DivMod16u
        EXTERN ?cstart_init_zero
        EXTERN ?longjmp_r4
        EXTERN ?longjmp_r5
        EXTERN ?setjmp_r4
        EXTERN ?setjmp_r5

        PUBWEAK ?setjmp_save_r4
        PUBWEAK ?setjmp_save_r5
        FUNCTION prvSemaphoreTest,021603H
        LOCFRAME CSTACK, 22, STACK
        PUBLIC vStartSemaphoreTasks
        FUNCTION vStartSemaphoreTasks,021203H
        LOCFRAME CSTACK, 26, STACK
        PUBLIC xAreSemaphoreTasksStillRunning
        FUNCTION xAreSemaphoreTasksStillRunning,0203H
        LOCFRAME CSTACK, 4, STACK
        
        CFI Names cfiNames0
        CFI StackFrame CFA SP DATA
        CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
        CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 2
        CFI DataAlign 2
        CFI ReturnAddress PC CODE
        CFI CFA SP+2
        CFI PC Frame(CFA, -2)
        CFI SR Undefined
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI R8 SameValue
        CFI R9 SameValue
        CFI R10 SameValue
        CFI R11 SameValue
        CFI R12 Undefined
        CFI R13 Undefined
        CFI R14 Undefined
        CFI R15 Undefined
        CFI EndCommon cfiCommon0
        
        EXTERN usCriticalNesting
        EXTERN xQueueReceive
        FUNCTION xQueueReceive,0202H
        EXTERN xQueueSend
        FUNCTION xQueueSend,0202H
        EXTERN vTaskDelay
        FUNCTION vTaskDelay,0202H
        EXTERN vPortYield
        FUNCTION vPortYield,0202H
        EXTERN pvPortMalloc
        FUNCTION pvPortMalloc,0202H
        EXTERN xQueueCreate
        FUNCTION xQueueCreate,0202H
        EXTERN xTaskCreate
        FUNCTION xTaskCreate,0202H

// C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\Common\Minimal\semtest.c
//    1 /*
//    2 	FreeRTOS V4.0.1 - Copyright (C) 2003-2006 Richard Barry.
//    3 
//    4 	This file is part of the FreeRTOS distribution.
//    5 
//    6 	FreeRTOS is free software; you can redistribute it and/or modify
//    7 	it under the terms of the GNU General Public License as published by
//    8 	the Free Software Foundation; either version 2 of the License, or
//    9 	(at your option) any later version.
//   10 
//   11 	FreeRTOS is distributed in the hope that it will be useful,
//   12 	but WITHOUT ANY WARRANTY; without even the implied warranty of
//   13 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   14 	GNU General Public License for more details.
//   15 
//   16 	You should have received a copy of the GNU General Public License
//   17 	along with FreeRTOS; if not, write to the Free Software
//   18 	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//   19 
//   20 	A special exception to the GPL can be applied should you wish to distribute
//   21 	a combined work that includes FreeRTOS, without being obliged to provide
//   22 	the source code for any proprietary components.  See the licensing section 
//   23 	of http://www.FreeRTOS.org for full details of how and when the exception
//   24 	can be applied.
//   25 
//   26 	***************************************************************************
//   27 	See http://www.FreeRTOS.org for documentation, latest information, license 
//   28 	and contact details.  Please ensure to read the configuration and relevant 
//   29 	port sections of the online documentation.
//   30 	***************************************************************************
//   31 */
//   32 
//   33 /*
//   34  * Creates two sets of two tasks.  The tasks within a set share a variable, access 
//   35  * to which is guarded by a semaphore.
//   36  * 
//   37  * Each task starts by attempting to obtain the semaphore.  On obtaining a 
//   38  * semaphore a task checks to ensure that the guarded variable has an expected 
//   39  * value.  It then clears the variable to zero before counting it back up to the 
//   40  * expected value in increments of 1.  After each increment the variable is checked 
//   41  * to ensure it contains the value to which it was just set. When the starting 
//   42  * value is again reached the task releases the semaphore giving the other task in 
//   43  * the set a chance to do exactly the same thing.  The starting value is high 
//   44  * enough to ensure that a tick is likely to occur during the incrementing loop.
//   45  *
//   46  * An error is flagged if at any time during the process a shared variable is 
//   47  * found to have a value other than that expected.  Such an occurrence would 
//   48  * suggest an error in the mutual exclusion mechanism by which access to the 
//   49  * variable is restricted.
//   50  *
//   51  * The first set of two tasks poll their semaphore.  The second set use blocking 
//   52  * calls.
//   53  *
//   54  */
//   55 
//   56 
//   57 #include <stdlib.h>
//   58 
//   59 /* Scheduler include files. */
//   60 #include "FreeRTOS.h"
//   61 #include "task.h"
//   62 #include "semphr.h"
//   63 
//   64 /* Demo app include files. */
//   65 #include "semtest.h"
//   66 
//   67 /* The value to which the shared variables are counted. */
//   68 #define semtstBLOCKING_EXPECTED_VALUE		( ( unsigned portLONG ) 0xfff )
//   69 #define semtstNON_BLOCKING_EXPECTED_VALUE	( ( unsigned portLONG ) 0xff  )
//   70 
//   71 #define semtstSTACK_SIZE			configMINIMAL_STACK_SIZE
//   72 
//   73 #define semtstNUM_TASKS				( 4 )
//   74 
//   75 #define semtstDELAY_FACTOR			( ( portTickType ) 10 )
//   76 
//   77 /* The task function as described at the top of the file. */
//   78 static portTASK_FUNCTION_PROTO( prvSemaphoreTest, pvParameters );
//   79 
//   80 /* Structure used to pass parameters to each task. */
//   81 typedef struct SEMAPHORE_PARAMETERS
//   82 {
//   83 	xSemaphoreHandle xSemaphore;
//   84 	volatile unsigned portLONG *pulSharedVariable;
//   85 	portTickType xBlockTime;
//   86 } xSemaphoreParameters;
//   87 
//   88 /* Variables used to check that all the tasks are still running without errors. */

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//   89 static volatile portSHORT sCheckVariables[ semtstNUM_TASKS ] = { 0 };
sCheckVariables:
        DS8 8

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//   90 static volatile portSHORT sNextCheckVariable = 0;
sNextCheckVariable:
        DS8 2
//   91 
//   92 /*-----------------------------------------------------------*/
//   93 

        RSEG CODE:CODE:REORDER:NOROOT(1)
//   94 void vStartSemaphoreTasks( unsigned portBASE_TYPE uxPriority )
vStartSemaphoreTasks:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function vStartSemaphoreTasks
//   95 {
        FUNCALL vStartSemaphoreTasks, pvPortMalloc
        LOCFRAME CSTACK, 10, STACK
        FUNCALL vStartSemaphoreTasks, xQueueCreate
        LOCFRAME CSTACK, 10, STACK
        FUNCALL vStartSemaphoreTasks, xQueueSend
        LOCFRAME CSTACK, 12, STACK
        FUNCALL vStartSemaphoreTasks, pvPortMalloc
        LOCFRAME CSTACK, 10, STACK
        FUNCALL vStartSemaphoreTasks, xTaskCreate
        LOCFRAME CSTACK, 18, STACK
        FUNCALL vStartSemaphoreTasks, xTaskCreate
        LOCFRAME CSTACK, 26, STACK
        FUNCALL vStartSemaphoreTasks, pvPortMalloc
        LOCFRAME CSTACK, 10, STACK
        FUNCALL vStartSemaphoreTasks, xQueueCreate
        LOCFRAME CSTACK, 10, STACK
        FUNCALL vStartSemaphoreTasks, xQueueSend
        LOCFRAME CSTACK, 12, STACK
        FUNCALL vStartSemaphoreTasks, pvPortMalloc
        LOCFRAME CSTACK, 10, STACK
        FUNCALL vStartSemaphoreTasks, xTaskCreate
        LOCFRAME CSTACK, 18, STACK
        FUNCALL vStartSemaphoreTasks, xTaskCreate
        LOCFRAME CSTACK, 26, 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
        MOV.W   R12, R10
//   96 xSemaphoreParameters *pxFirstSemaphoreParameters, *pxSecondSemaphoreParameters;
//   97 const portTickType xBlockTime = ( portTickType ) 100;
        MOV.W   #0x64, R9
//   98 
//   99 	/* Create the structure used to pass parameters to the first two tasks. */
//  100 	pxFirstSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
        MOV.W   #0x6, R12
        CALL    #pvPortMalloc
        MOV.W   R12, R11
//  101 
//  102 	if( pxFirstSemaphoreParameters != NULL )
        CMP.W   #0x0, R11
        JEQ     ??vStartSemaphoreTasks_0
//  103 	{
//  104 		/* Create the semaphore used by the first two tasks. */
//  105 		vSemaphoreCreateBinary( pxFirstSemaphoreParameters->xSemaphore );
        MOV.W   #0x0, R14
        MOV.W   #0x1, R12
        CALL    #xQueueCreate
        MOV.W   R12, 0(R11)
        CMP.W   #0x0, 0(R11)
        JEQ     ??vStartSemaphoreTasks_1
        PUSH.W  #0x0
        CFI CFA SP+12
        MOV.W   #0x0, R14
        MOV.W   @R11, R12
        CALL    #xQueueSend
        ADD.W   #0x2, SP
        CFI CFA SP+10
//  106 
//  107 		if( pxFirstSemaphoreParameters->xSemaphore != NULL )
??vStartSemaphoreTasks_1:
        CMP.W   #0x0, 0(R11)
        JEQ     ??vStartSemaphoreTasks_0
//  108 		{
//  109 			/* Create the variable which is to be shared by the first two tasks. */
//  110 			pxFirstSemaphoreParameters->pulSharedVariable = ( unsigned portLONG * ) pvPortMalloc( sizeof( unsigned portLONG ) );
        MOV.W   #0x4, R12
        CALL    #pvPortMalloc
        MOV.W   R12, 0x2(R11)
//  111 
//  112 			/* Initialise the share variable to the value the tasks expect. */
//  113 			*( pxFirstSemaphoreParameters->pulSharedVariable ) = semtstNON_BLOCKING_EXPECTED_VALUE;
        MOV.W   0x2(R11), R15
        MOV.W   #0xff, 0(R15)
        MOV.W   #0x0, 0x2(R15)
//  114 
//  115 			/* The first two tasks do not block on semaphore calls. */
//  116 			pxFirstSemaphoreParameters->xBlockTime = ( portTickType ) 0;
        MOV.W   #0x0, 0x4(R11)
//  117 
//  118 			/* Spawn the first two tasks.  As they poll they operate at the idle priority. */
//  119 			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "PolSEM1", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
        PUSH.W  #0x0
        CFI CFA SP+12
        PUSH.W  #0x0
        CFI CFA SP+14
        PUSH.W  R11
        CFI CFA SP+16
        PUSH.W  #0x40
        CFI CFA SP+18
        MOV.W   #`?<Constant "PolSEM1">`, R14
        MOV.W   #prvSemaphoreTest, R12
        CALL    #xTaskCreate
//  120 			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "PolSEM2", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
        PUSH.W  #0x0
        CFI CFA SP+20
        PUSH.W  #0x0
        CFI CFA SP+22
        PUSH.W  R11
        CFI CFA SP+24
        PUSH.W  #0x40
        CFI CFA SP+26
        MOV.W   #`?<Constant "PolSEM2">`, R14
        MOV.W   #prvSemaphoreTest, R12
        CALL    #xTaskCreate
        ADD.W   #0x10, SP
        CFI CFA SP+10
//  121 		}
//  122 	}
//  123 
//  124 	/* Do exactly the same to create the second set of tasks, only this time 
//  125 	provide a block time for the semaphore calls. */
//  126 	pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
??vStartSemaphoreTasks_0:
        MOV.W   #0x6, R12
        CALL    #pvPortMalloc
        MOV.W   R12, R8
//  127 	if( pxSecondSemaphoreParameters != NULL )
        CMP.W   #0x0, R8
        JEQ     ??vStartSemaphoreTasks_2
//  128 	{
//  129 		vSemaphoreCreateBinary( pxSecondSemaphoreParameters->xSemaphore );
        MOV.W   #0x0, R14
        MOV.W   #0x1, R12
        CALL    #xQueueCreate
        MOV.W   R12, 0(R8)
        CMP.W   #0x0, 0(R8)
        JEQ     ??vStartSemaphoreTasks_3
        PUSH.W  #0x0
        CFI CFA SP+12
        MOV.W   #0x0, R14
        MOV.W   @R8, R12
        CALL    #xQueueSend
        ADD.W   #0x2, SP
        CFI CFA SP+10
//  130 
//  131 		if( pxSecondSemaphoreParameters->xSemaphore != NULL )
??vStartSemaphoreTasks_3:
        CMP.W   #0x0, 0(R8)
        JEQ     ??vStartSemaphoreTasks_2
//  132 		{
//  133 			pxSecondSemaphoreParameters->pulSharedVariable = ( unsigned portLONG * ) pvPortMalloc( sizeof( unsigned portLONG ) );

⌨️ 快捷键说明

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