📄 semtest.lst
字号:
##############################################################################
# #
# 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\Minim #
# al\semtest.c #
# Command line = C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\Common\Minim #
# al\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\Debu #
# g\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\Inclu #
# de\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Source\Inc #
# lude\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\MSP #
# 430_IAR\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Sourc #
# e\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\semtes #
# t.lst #
# Object file = C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\Obj\semtest #
# .r43 #
# #
# #
##############################################################################
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. */
\ In segment DATA16_Z, align 2, align-sorted
\ 000000 REQUIRE ?cstart_init_zero
89 static volatile portSHORT sCheckVariables[ semtstNUM_TASKS ] = { 0 };
\ sCheckVariables:
\ 000000 DS8 8
\ In segment DATA16_Z, align 2, align-sorted
\ 000000 REQUIRE ?cstart_init_zero
90 static volatile portSHORT sNextCheckVariable = 0;
\ sNextCheckVariable:
\ 000000 DS8 2
91
92 /*-----------------------------------------------------------*/
93
\ In segment CODE, align 2
94 void vStartSemaphoreTasks( unsigned portBASE_TYPE uxPriority )
\ vStartSemaphoreTasks:
95 {
\ 000000 0A12 PUSH.W R10
\ 000002 0B12 PUSH.W R11
\ 000004 0812 PUSH.W R8
\ 000006 0912 PUSH.W R9
\ 000008 0A4C MOV.W R12, R10
96 xSemaphoreParameters *pxFirstSemaphoreParameters, *pxSecondSemaphoreParameters;
97 const portTickType xBlockTime = ( portTickType ) 100;
\ 00000A 39406400 MOV.W #0x64, R9
98
99 /* Create the structure used to pass parameters to the first two tasks. */
100 pxFirstSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
\ 00000E 3C400600 MOV.W #0x6, R12
\ 000012 B012.... CALL #pvPortMalloc
\ 000016 0B4C MOV.W R12, R11
101
102 if( pxFirstSemaphoreParameters != NULL )
\ 000018 0B93 CMP.W #0x0, R11
\ 00001A 3824 JEQ ??vStartSemaphoreTasks_0
103 {
104 /* Create the semaphore used by the first two tasks. */
105 vSemaphoreCreateBinary( pxFirstSemaphoreParameters->xSemaphore );
\ 00001C 0E43 MOV.W #0x0, R14
\ 00001E 1C43 MOV.W #0x1, R12
\ 000020 B012.... CALL #xQueueCreate
\ 000024 8B4C0000 MOV.W R12, 0(R11)
\ 000028 8B930000 CMP.W #0x0, 0(R11)
\ 00002C 0624 JEQ ??vStartSemaphoreTasks_1
\ 00002E 0312 PUSH.W #0x0
\ 000030 0E43 MOV.W #0x0, R14
\ 000032 2C4B MOV.W @R11, R12
\ 000034 B012.... CALL #xQueueSend
\ 000038 2153 ADD.W #0x2, SP
106
107 if( pxFirstSemaphoreParameters->xSemaphore != NULL )
\ ??vStartSemaphoreTasks_1:
\ 00003A 8B930000 CMP.W #0x0, 0(R11)
\ 00003E 2624 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 ) );
\ 000040 2C42 MOV.W #0x4, R12
\ 000042 B012.... CALL #pvPortMalloc
\ 000046 8B4C0200 MOV.W R12, 0x2(R11)
111
112 /* Initialise the share variable to the value the tasks expect. */
113 *( pxFirstSemaphoreParameters->pulSharedVariable ) = semtstNON_BLOCKING_EXPECTED_VALUE;
\ 00004A 1F4B0200 MOV.W 0x2(R11), R15
\ 00004E BF40FF000000 MOV.W #0xff, 0(R15)
\ 000054 8F430200 MOV.W #0x0, 0x2(R15)
114
115 /* The first two tasks do not block on semaphore calls. */
116 pxFirstSemaphoreParameters->xBlockTime = ( portTickType ) 0;
\ 000058 8B430400 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 );
\ 00005C 0312 PUSH.W #0x0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -