27
27
*/
28
28
29
29
/*
30
- * Changes from V1.00:
31
- *
32
- + Call to taskYIELD() from within tick ISR has been replaced by the more
33
- + efficient portSWITCH_CONTEXT().
34
- + ISR function definitions renamed to include the prv prefix.
35
- +
36
- + Changes from V2.6.1
37
- +
38
- + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION
39
- + macro to be consistent with the later ports.
40
- */
30
+ Changes from V1.00:
31
+
32
+ + Call to taskYIELD() from within tick ISR has been replaced by the more
33
+ efficient portSWITCH_CONTEXT().
34
+ + ISR function definitions renamed to include the prv prefix.
35
+
36
+ Changes from V2.6.1
37
+
38
+ + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION
39
+ macro to be consistent with the later ports.
40
+ */
41
41
42
42
/*-----------------------------------------------------------
43
- * Implementation of functions defined in portable.h for the Flashlite 186
44
- * port.
45
- *----------------------------------------------------------*/
43
+ * Implementation of functions defined in portable.h for the Flashlite 186
44
+ * port.
45
+ *----------------------------------------------------------*/
46
46
47
47
#include <dos.h>
48
48
#include <stdlib.h>
54
54
55
55
/*lint -e950 Non ANSI reserved words okay in this file only. */
56
56
57
- #define portTIMER_EOI_TYPE ( 8 )
58
- #define portRESET_PIC () portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE )
59
- #define portTIMER_INT_NUMBER 0x12
57
+ #define portTIMER_EOI_TYPE ( 8 )
58
+ #define portRESET_PIC () portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE )
59
+ #define portTIMER_INT_NUMBER 0x12
60
60
61
61
#define portTIMER_1_CONTROL_REGISTER ( ( uint16_t ) 0xff5e )
62
62
#define portTIMER_0_CONTROL_REGISTER ( ( uint16_t ) 0xff56 )
@@ -69,16 +69,14 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz );
69
69
static void prvExitFunction ( void );
70
70
71
71
/* The ISR used depends on whether the preemptive or cooperative scheduler
72
- * is being used. */
73
- #if ( configUSE_PREEMPTION == 1 )
74
-
75
- /* Tick service routine used by the scheduler when preemptive scheduling is
76
- * being used. */
72
+ is being used. */
73
+ #if ( configUSE_PREEMPTION == 1 )
74
+ /* Tick service routine used by the scheduler when preemptive scheduling is
75
+ being used. */
77
76
static void __interrupt __far prvPreemptiveTick ( void );
78
77
#else
79
-
80
- /* Tick service routine used by the scheduler when cooperative scheduling is
81
- * being used. */
78
+ /* Tick service routine used by the scheduler when cooperative scheduling is
79
+ being used. */
82
80
static void __interrupt __far prvNonPreemptiveTick ( void );
83
81
#endif
84
82
@@ -91,9 +89,9 @@ static void __interrupt __far prvYieldProcessor( void );
91
89
static BaseType_t xSchedulerRunning = pdFALSE ;
92
90
93
91
/* Points to the original routine installed on the vector we use for manual
94
- * context switches. This is then used to restore the original routine during
95
- * prvExitFunction(). */
96
- static void ( __interrupt __far * pxOldSwitchISR )();
92
+ context switches. This is then used to restore the original routine during
93
+ prvExitFunction(). */
94
+ static void ( __interrupt __far * pxOldSwitchISR )();
97
95
98
96
/* Used to restore the original DOS context when the scheduler is ended. */
99
97
static jmp_buf xJumpBuf ;
@@ -106,14 +104,14 @@ BaseType_t xPortStartScheduler( void )
106
104
/* This is called with interrupts already disabled. */
107
105
108
106
/* Remember what was on the interrupts we are going to use
109
- * so we can put them back later if required. */
107
+ so we can put them back later if required. */
110
108
pxOldSwitchISR = _dos_getvect ( portSWITCH_INT_NUMBER );
111
109
112
110
/* Put our manual switch (yield) function on a known
113
- * vector. */
111
+ vector. */
114
112
_dos_setvect ( portSWITCH_INT_NUMBER , prvYieldProcessor );
115
113
116
- #if ( configUSE_PREEMPTION == 1 )
114
+ #if ( configUSE_PREEMPTION == 1 )
117
115
{
118
116
/* Put our tick switch function on the timer interrupt. */
119
117
_dos_setvect ( portTIMER_INT_NUMBER , prvPreemptiveTick );
@@ -146,8 +144,8 @@ BaseType_t xPortStartScheduler( void )
146
144
/*-----------------------------------------------------------*/
147
145
148
146
/* The ISR used depends on whether the preemptive or cooperative scheduler
149
- * is being used. */
150
- #if ( configUSE_PREEMPTION == 1 )
147
+ is being used. */
148
+ #if ( configUSE_PREEMPTION == 1 )
151
149
static void __interrupt __far prvPreemptiveTick ( void )
152
150
{
153
151
/* Get the scheduler to update the task states following the tick. */
@@ -160,15 +158,15 @@ BaseType_t xPortStartScheduler( void )
160
158
/* Reset the PIC ready for the next time. */
161
159
portRESET_PIC ();
162
160
}
163
- #else /* if ( configUSE_PREEMPTION == 1 ) */
161
+ #else
164
162
static void __interrupt __far prvNonPreemptiveTick ( void )
165
163
{
166
164
/* Same as preemptive tick, but the cooperative scheduler is being used
167
- * so we don't have to switch in the context of the next task. */
165
+ so we don't have to switch in the context of the next task. */
168
166
xTaskIncrementTick ();
169
167
portRESET_PIC ();
170
168
}
171
- #endif /* if ( configUSE_PREEMPTION == 1 ) */
169
+ #endif
172
170
/*-----------------------------------------------------------*/
173
171
174
172
static void __interrupt __far prvYieldProcessor ( void )
@@ -181,31 +179,30 @@ static void __interrupt __far prvYieldProcessor( void )
181
179
void vPortEndScheduler ( void )
182
180
{
183
181
/* Jump back to the processor state prior to starting the
184
- * scheduler. This means we are not going to be using a
185
- * task stack frame so the task can be deleted. */
182
+ scheduler. This means we are not going to be using a
183
+ task stack frame so the task can be deleted. */
186
184
longjmp ( xJumpBuf , 1 );
187
185
}
188
186
/*-----------------------------------------------------------*/
189
187
190
188
static void prvExitFunction ( void )
191
189
{
192
- const uint16_t usTimerDisable = 0x0000 ;
193
- uint16_t usTimer0Control ;
190
+ const uint16_t usTimerDisable = 0x0000 ;
191
+ uint16_t usTimer0Control ;
194
192
195
193
/* Interrupts should be disabled here anyway - but no
196
- * harm in making sure. */
194
+ harm in making sure. */
197
195
portDISABLE_INTERRUPTS ();
198
-
199
196
if ( xSchedulerRunning == pdTRUE )
200
197
{
201
198
/* Put back the switch interrupt routines that was in place
202
- * before the scheduler started. */
199
+ before the scheduler started. */
203
200
_dos_setvect ( portSWITCH_INT_NUMBER , pxOldSwitchISR );
204
201
}
205
202
206
203
/* Disable the timer used for the tick to ensure the scheduler is
207
- * not called before restoring interrupts. There was previously nothing
208
- * on this timer so there is no old ISR to restore. */
204
+ not called before restoring interrupts. There was previously nothing
205
+ on this timer so there is no old ISR to restore. */
209
206
portOUTPUT_WORD ( portTIMER_1_CONTROL_REGISTER , usTimerDisable );
210
207
211
208
/* Restart the DOS tick. */
@@ -220,18 +217,18 @@ static void prvExitFunction( void )
220
217
221
218
static void prvSetTickFrequency ( uint32_t ulTickRateHz )
222
219
{
223
- const uint16_t usMaxCountRegister = 0xff5a ;
224
- const uint16_t usTimerPriorityRegister = 0xff32 ;
225
- const uint16_t usTimerEnable = 0xC000 ;
226
- const uint16_t usRetrigger = 0x0001 ;
227
- const uint16_t usTimerHighPriority = 0x0000 ;
228
- uint16_t usTimer0Control ;
220
+ const uint16_t usMaxCountRegister = 0xff5a ;
221
+ const uint16_t usTimerPriorityRegister = 0xff32 ;
222
+ const uint16_t usTimerEnable = 0xC000 ;
223
+ const uint16_t usRetrigger = 0x0001 ;
224
+ const uint16_t usTimerHighPriority = 0x0000 ;
225
+ uint16_t usTimer0Control ;
229
226
230
227
/* ( CPU frequency / 4 ) / clock 2 max count [inpw( 0xff62 ) = 7] */
231
228
232
- const uint32_t ulClockFrequency = ( uint32_t ) 0x7f31a0UL ;
229
+ const uint32_t ulClockFrequency = ( uint32_t ) 0x7f31a0UL ;
233
230
234
- uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz ;
231
+ uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz ;
235
232
236
233
portOUTPUT_WORD ( portTIMER_1_CONTROL_REGISTER , usTimerEnable | portTIMER_INTERRUPT_ENABLE | usRetrigger );
237
234
portOUTPUT_WORD ( usMaxCountRegister , ( uint16_t ) ulTimerCount );
0 commit comments