28
28
29
29
30
30
/*-----------------------------------------------------------
31
- * Implementation of functions defined in portable.h for the Tern EE 186
32
- * port.
33
- *----------------------------------------------------------*/
31
+ * Implementation of functions defined in portable.h for the Tern EE 186
32
+ * port.
33
+ *----------------------------------------------------------*/
34
34
35
35
/* Library includes. */
36
36
#include <embedded.h>
42
42
#include "portasm.h"
43
43
44
44
/* The timer increments every four clocks, hence the divide by 4. */
45
- #define portTIMER_COMPARE ( uint16_t ) ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) / ( uint32_t ) 4 )
45
+ #define portTIMER_COMPARE ( uint16_t ) ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) / ( uint32_t ) 4 )
46
46
47
47
/* From the RDC data sheet. */
48
- #define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe001
48
+ #define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe001
49
49
50
50
/* Interrupt control. */
51
- #define portEIO_REGISTER 0xff22
52
- #define portCLEAR_INTERRUPT 0x0008
51
+ #define portEIO_REGISTER 0xff22
52
+ #define portCLEAR_INTERRUPT 0x0008
53
53
54
54
/* Setup the hardware to generate the required tick frequency. */
55
55
static void prvSetupTimerInterrupt ( void );
56
56
57
57
/* The ISR used depends on whether the preemptive or cooperative scheduler
58
- * is being used. */
59
- #if ( configUSE_PREEMPTION == 1 )
60
-
61
- /* Tick service routine used by the scheduler when preemptive scheduling is
62
- * being used. */
58
+ is being used. */
59
+ #if ( configUSE_PREEMPTION == 1 )
60
+ /* Tick service routine used by the scheduler when preemptive scheduling is
61
+ being used. */
63
62
static void __interrupt __far prvPreemptiveTick ( void );
64
63
#else
65
-
66
- /* Tick service routine used by the scheduler when cooperative scheduling is
67
- * being used. */
64
+ /* Tick service routine used by the scheduler when cooperative scheduling is
65
+ being used. */
68
66
static void __interrupt __far prvNonPreemptiveTick ( void );
69
67
#endif
70
68
71
69
/* Trap routine used by taskYIELD() to manually cause a context switch. */
72
70
static void __interrupt __far prvYieldProcessor ( void );
73
71
74
72
/* The timer initialisation functions leave interrupts enabled,
75
- * which is not what we want. This ISR is installed temporarily in case
76
- * the timer fires before we get a change to disable interrupts again. */
73
+ which is not what we want. This ISR is installed temporarily in case
74
+ the timer fires before we get a change to disable interrupts again. */
77
75
static void __interrupt __far prvDummyISR ( void );
78
76
79
77
/*-----------------------------------------------------------*/
80
78
/* See header file for description. */
81
- StackType_t * pxPortInitialiseStack ( StackType_t * pxTopOfStack ,
82
- TaskFunction_t pxCode ,
83
- void * pvParameters )
79
+ StackType_t * pxPortInitialiseStack ( StackType_t * pxTopOfStack , TaskFunction_t pxCode , void * pvParameters )
84
80
{
85
- StackType_t DS_Reg = 0 ;
81
+ StackType_t DS_Reg = 0 ;
86
82
87
83
/* Place a few bytes of known values on the bottom of the stack.
88
- * This is just useful for debugging. */
84
+ This is just useful for debugging. */
89
85
90
86
* pxTopOfStack = 0x1111 ;
91
87
pxTopOfStack -- ;
@@ -95,8 +91,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
95
91
pxTopOfStack -- ;
96
92
97
93
/* We are going to start the scheduler using a return from interrupt
98
- * instruction to load the program counter, so first there would be the
99
- * function call with parameters preamble. */
94
+ instruction to load the program counter, so first there would be the
95
+ function call with parameters preamble. */
100
96
101
97
* pxTopOfStack = FP_SEG ( pvParameters );
102
98
pxTopOfStack -- ;
@@ -116,8 +112,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
116
112
pxTopOfStack -- ;
117
113
118
114
/* The remaining registers would be pushed on the stack by our context
119
- * switch function. These are loaded with values simply to make debugging
120
- * easier. */
115
+ switch function. These are loaded with values simply to make debugging
116
+ easier. */
121
117
* pxTopOfStack = ( StackType_t ) 0xAAAA ; /* AX */
122
118
pxTopOfStack -- ;
123
119
* pxTopOfStack = ( StackType_t ) 0xBBBB ; /* BX */
@@ -130,11 +126,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
130
126
pxTopOfStack -- ;
131
127
132
128
/* We need the true data segment. */
133
- __asm {
134
- MOV DS_Reg , DS
135
- };
129
+ __asm{ MOV DS_Reg , DS };
136
130
137
- * pxTopOfStack = DS_Reg ; /* DS */
131
+ * pxTopOfStack = DS_Reg ; /* DS */
138
132
pxTopOfStack -- ;
139
133
* pxTopOfStack = ( StackType_t ) 0x0123 ; /* SI */
140
134
pxTopOfStack -- ;
@@ -151,7 +145,7 @@ BaseType_t xPortStartScheduler( void )
151
145
/* This is called with interrupts already disabled. */
152
146
153
147
/* Put our manual switch (yield) function on a known
154
- * vector. */
148
+ vector. */
155
149
setvect ( portSWITCH_INT_NUMBER , prvYieldProcessor );
156
150
157
151
/* Setup the tick interrupt. */
@@ -168,15 +162,15 @@ BaseType_t xPortStartScheduler( void )
168
162
static void __interrupt __far prvDummyISR ( void )
169
163
{
170
164
/* The timer initialisation functions leave interrupts enabled,
171
- * which is not what we want. This ISR is installed temporarily in case
172
- * the timer fires before we get a change to disable interrupts again. */
165
+ which is not what we want. This ISR is installed temporarily in case
166
+ the timer fires before we get a change to disable interrupts again. */
173
167
outport ( portEIO_REGISTER , portCLEAR_INTERRUPT );
174
168
}
175
169
/*-----------------------------------------------------------*/
176
170
177
171
/* The ISR used depends on whether the preemptive or cooperative scheduler
178
- * is being used. */
179
- #if ( configUSE_PREEMPTION == 1 )
172
+ is being used. */
173
+ #if ( configUSE_PREEMPTION == 1 )
180
174
static void __interrupt __far prvPreemptiveTick ( void )
181
175
{
182
176
/* Get the scheduler to update the task states following the tick. */
@@ -189,17 +183,17 @@ static void __interrupt __far prvDummyISR( void )
189
183
/* Reset interrupt. */
190
184
outport ( portEIO_REGISTER , portCLEAR_INTERRUPT );
191
185
}
192
- #else /* if ( configUSE_PREEMPTION == 1 ) */
186
+ #else
193
187
static void __interrupt __far prvNonPreemptiveTick ( void )
194
188
{
195
189
/* Same as preemptive tick, but the cooperative scheduler is being used
196
- * so we don't have to switch in the context of the next task. */
190
+ so we don't have to switch in the context of the next task. */
197
191
xTaskIncrementTick ();
198
192
199
193
/* Reset interrupt. */
200
194
outport ( portEIO_REGISTER , portCLEAR_INTERRUPT );
201
195
}
202
- #endif /* if ( configUSE_PREEMPTION == 1 ) */
196
+ #endif
203
197
/*-----------------------------------------------------------*/
204
198
205
199
static void __interrupt __far prvYieldProcessor ( void )
@@ -217,25 +211,23 @@ void vPortEndScheduler( void )
217
211
218
212
static void prvSetupTimerInterrupt ( void )
219
213
{
220
- const uint16_t usTimerACompare = portTIMER_COMPARE , usTimerAMode = portENABLE_TIMER_AND_INTERRUPT ;
221
- const uint16_t usT2_IRQ = 0x13 ;
214
+ const uint16_t usTimerACompare = portTIMER_COMPARE , usTimerAMode = portENABLE_TIMER_AND_INTERRUPT ;
215
+ const uint16_t usT2_IRQ = 0x13 ;
222
216
223
217
/* Configure the timer, the dummy handler is used here as the init
224
- * function leaves interrupts enabled. */
218
+ function leaves interrupts enabled. */
225
219
t2_init ( usTimerAMode , usTimerACompare , prvDummyISR );
226
220
227
221
/* Disable interrupts again before installing the real handlers. */
228
222
portDISABLE_INTERRUPTS ();
229
223
230
- #if ( configUSE_PREEMPTION == 1 )
231
-
224
+ #if ( configUSE_PREEMPTION == 1 )
232
225
/* Tick service routine used by the scheduler when preemptive scheduling is
233
- * being used. */
226
+ being used. */
234
227
setvect ( usT2_IRQ , prvPreemptiveTick );
235
228
#else
236
-
237
229
/* Tick service routine used by the scheduler when cooperative scheduling is
238
- * being used. */
230
+ being used. */
239
231
setvect ( usT2_IRQ , prvNonPreemptiveTick );
240
232
#endif
241
233
}
0 commit comments