OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [CCS4/] [MSP430X/] [port.c] - Blame information for rev 597

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 572 jeremybenn
/*
2
    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
3
 
4
    ***************************************************************************
5
    *                                                                         *
6
    * If you are:                                                             *
7
    *                                                                         *
8
    *    + New to FreeRTOS,                                                   *
9
    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
10
    *    + Looking for basic training,                                        *
11
    *    + Wanting to improve your FreeRTOS skills and productivity           *
12
    *                                                                         *
13
    * then take a look at the FreeRTOS books - available as PDF or paperback  *
14
    *                                                                         *
15
    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
16
    *                  http://www.FreeRTOS.org/Documentation                  *
17
    *                                                                         *
18
    * A pdf reference manual is also available.  Both are usually delivered   *
19
    * to your inbox within 20 minutes to two hours when purchased between 8am *
20
    * and 8pm GMT (although please allow up to 24 hours in case of            *
21
    * exceptional circumstances).  Thank you for your support!                *
22
    *                                                                         *
23
    ***************************************************************************
24
 
25
    This file is part of the FreeRTOS distribution.
26
 
27
    FreeRTOS is free software; you can redistribute it and/or modify it under
28
    the terms of the GNU General Public License (version 2) as published by the
29
    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
30
    ***NOTE*** The exception to the GPL is included to allow you to distribute
31
    a combined work that includes FreeRTOS without being obliged to provide the
32
    source code for proprietary components outside of the FreeRTOS kernel.
33
    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
34
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
36
    more details. You should have received a copy of the GNU General Public
37
    License and the FreeRTOS license exception along with FreeRTOS; if not it
38
    can be viewed here: http://www.freertos.org/a00114.html and also obtained
39
    by writing to Richard Barry, contact details for whom are available on the
40
    FreeRTOS WEB site.
41
 
42
    1 tab == 4 spaces!
43
 
44
    http://www.FreeRTOS.org - Documentation, latest information, license and
45
    contact details.
46
 
47
    http://www.SafeRTOS.com - A version that is certified for use in safety
48
    critical systems.
49
 
50
    http://www.OpenRTOS.com - Commercial support, development, porting,
51
    licensing and training services.
52
*/
53
 
54
/* Scheduler includes. */
55
#include "FreeRTOS.h"
56
#include "task.h"
57
 
58
/*-----------------------------------------------------------
59
 * Implementation of functions defined in portable.h for the MSP430X port.
60
 *----------------------------------------------------------*/
61
 
62
/* Constants required for hardware setup.  The tick ISR runs off the ACLK,
63
not the MCLK. */
64
#define portACLK_FREQUENCY_HZ                   ( ( portTickType ) 32768 )
65
#define portINITIAL_CRITICAL_NESTING    ( ( unsigned short ) 10 )
66
#define portFLAGS_INT_ENABLED                   ( ( portSTACK_TYPE ) 0x08 )
67
 
68
/* We require the address of the pxCurrentTCB variable, but don't want to know
69
any details of its type. */
70
typedef void tskTCB;
71
extern volatile tskTCB * volatile pxCurrentTCB;
72
 
73
/* Each task maintains a count of the critical section nesting depth.  Each
74
time a critical section is entered the count is incremented.  Each time a
75
critical section is exited the count is decremented - with interrupts only
76
being re-enabled if the count is zero.
77
 
78
usCriticalNesting will get set to zero when the scheduler starts, but must
79
not be initialised to zero as this will cause problems during the startup
80
sequence. */
81
volatile unsigned short usCriticalNesting = portINITIAL_CRITICAL_NESTING;
82
/*-----------------------------------------------------------*/
83
 
84
 
85
/*
86
 * Sets up the periodic ISR used for the RTOS tick.  This uses timer 0, but
87
 * could have alternatively used the watchdog timer or timer 1.
88
 */
89
void vPortSetupTimerInterrupt( void );
90
/*-----------------------------------------------------------*/
91
 
92
/*
93
 * Initialise the stack of a task to look exactly as if a call to
94
 * portSAVE_CONTEXT had been called.
95
 *
96
 * See the header file portable.h.
97
 */
98
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
99
{
100
unsigned short *pusTopOfStack;
101
unsigned long *pulTopOfStack;
102
 
103
        /*
104
                Place a few bytes of known values on the bottom of the stack.
105
                This is just useful for debugging and can be included if required.
106
 
107
                *pxTopOfStack = ( portSTACK_TYPE ) 0x1111;
108
                pxTopOfStack--;
109
                *pxTopOfStack = ( portSTACK_TYPE ) 0x2222;
110
                pxTopOfStack--;
111
                *pxTopOfStack = ( portSTACK_TYPE ) 0x3333;
112
                pxTopOfStack--;
113
        */
114
 
115
        /* Data types are need either 16 bits or 32 bits depending on the data
116
        and code model used. */
117
        if( sizeof( pxCode ) == sizeof( unsigned short ) )
118
        {
119
                pusTopOfStack = ( unsigned short * ) pxTopOfStack;
120
                *pusTopOfStack = ( unsigned short ) pxCode;
121
        }
122
        else
123
        {
124
                /* Make room for a 20 bit value stored as a 32 bit value. */
125
                pusTopOfStack = ( unsigned short * ) pxTopOfStack;
126
                pusTopOfStack--;
127
                pulTopOfStack = ( unsigned long * ) pusTopOfStack;
128
                *pulTopOfStack = ( unsigned long ) pxCode;
129
                pusTopOfStack = ( unsigned short * ) pulTopOfStack;
130
        }
131
 
132
        pusTopOfStack--;
133
        *pusTopOfStack = portFLAGS_INT_ENABLED;
134
        pusTopOfStack -= ( sizeof( portSTACK_TYPE ) / 2 );
135
 
136
        /* From here on the size of stacked items depends on the memory model. */
137
        pxTopOfStack = ( portSTACK_TYPE * ) pusTopOfStack;
138
 
139
        /* Next the general purpose registers. */
140
        #ifdef PRELOAD_REGISTER_VALUES
141
                *pxTopOfStack = ( portSTACK_TYPE ) 0xffff;
142
                pxTopOfStack--;
143
                *pxTopOfStack = ( portSTACK_TYPE ) 0xeeee;
144
                pxTopOfStack--;
145
                *pxTopOfStack = ( portSTACK_TYPE ) 0xdddd;
146
                pxTopOfStack--;
147
                *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;
148
                pxTopOfStack--;
149
                *pxTopOfStack = ( portSTACK_TYPE ) 0xbbbb;
150
                pxTopOfStack--;
151
                *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaa;
152
                pxTopOfStack--;
153
                *pxTopOfStack = ( portSTACK_TYPE ) 0x9999;
154
                pxTopOfStack--;
155
                *pxTopOfStack = ( portSTACK_TYPE ) 0x8888;
156
                pxTopOfStack--;
157
                *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;
158
                pxTopOfStack--;
159
                *pxTopOfStack = ( portSTACK_TYPE ) 0x6666;
160
                pxTopOfStack--;
161
                *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;
162
                pxTopOfStack--;
163
                *pxTopOfStack = ( portSTACK_TYPE ) 0x4444;
164
                pxTopOfStack--;
165
        #else
166
                pxTopOfStack -= 3;
167
                *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;
168
                pxTopOfStack -= 9;
169
        #endif
170
 
171
        /* A variable is used to keep track of the critical section nesting.
172
        This variable has to be stored as part of the task context and is
173
        initially set to zero. */
174
        *pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;
175
 
176
        /* Return a pointer to the top of the stack we have generated so this can
177
        be stored in the task control block for the task. */
178
        return pxTopOfStack;
179
}
180
/*-----------------------------------------------------------*/
181
 
182
void vPortEndScheduler( void )
183
{
184
        /* It is unlikely that the MSP430 port will get stopped.  If required simply
185
        disable the tick interrupt here. */
186
}
187
/*-----------------------------------------------------------*/
188
 
189
/*
190
 * Hardware initialisation to generate the RTOS tick.
191
 */
192
void vPortSetupTimerInterrupt( void )
193
{
194
        vApplicationSetupTimerInterrupt();
195
}
196
/*-----------------------------------------------------------*/
197
 
198
#pragma vector=configTICK_VECTOR
199
interrupt void vTickISREntry( void )
200
{
201
extern void vPortTickISR( void );
202
 
203
        #if configUSE_PREEMPTION == 1
204
                extern void vPortPreemptiveTickISR( void );
205
                vPortPreemptiveTickISR();
206
        #else
207
                extern void vPortCooperativeTickISR( void );
208
                vPortCooperativeTickISR();
209
        #endif
210
}
211
 
212
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.