2828
2929
3030/*-----------------------------------------------------------
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+ *----------------------------------------------------------*/
3434
3535/* Library includes. */
3636#include <embedded.h>
4242#include "portasm.h"
4343
4444/* 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 )
4646
4747/* From the RDC data sheet. */
48- #define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe001
48+ #define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe001
4949
5050/* Interrupt control. */
51- #define portEIO_REGISTER 0xff22
52- #define portCLEAR_INTERRUPT 0x0008
51+ #define portEIO_REGISTER 0xff22
52+ #define portCLEAR_INTERRUPT 0x0008
5353
5454/* Setup the hardware to generate the required tick frequency. */
5555static void prvSetupTimerInterrupt ( void );
5656
5757/* 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. */
6362 static void __interrupt __far prvPreemptiveTick ( void );
6463#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. */
6866 static void __interrupt __far prvNonPreemptiveTick ( void );
6967#endif
7068
7169/* Trap routine used by taskYIELD() to manually cause a context switch. */
7270static void __interrupt __far prvYieldProcessor ( void );
7371
7472/* 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. */
7775static void __interrupt __far prvDummyISR ( void );
7876
7977/*-----------------------------------------------------------*/
8078/* 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 )
8480{
85- StackType_t DS_Reg = 0 ;
81+ StackType_t DS_Reg = 0 ;
8682
8783 /* 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. */
8985
9086 * pxTopOfStack = 0x1111 ;
9187 pxTopOfStack -- ;
@@ -95,8 +91,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
9591 pxTopOfStack -- ;
9692
9793 /* 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. */
10096
10197 * pxTopOfStack = FP_SEG ( pvParameters );
10298 pxTopOfStack -- ;
@@ -116,8 +112,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
116112 pxTopOfStack -- ;
117113
118114 /* 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. */
121117 * pxTopOfStack = ( StackType_t ) 0xAAAA ; /* AX */
122118 pxTopOfStack -- ;
123119 * pxTopOfStack = ( StackType_t ) 0xBBBB ; /* BX */
@@ -130,11 +126,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
130126 pxTopOfStack -- ;
131127
132128 /* We need the true data segment. */
133- __asm {
134- MOV DS_Reg , DS
135- };
129+ __asm{ MOV DS_Reg , DS };
136130
137- * pxTopOfStack = DS_Reg ; /* DS */
131+ * pxTopOfStack = DS_Reg ; /* DS */
138132 pxTopOfStack -- ;
139133 * pxTopOfStack = ( StackType_t ) 0x0123 ; /* SI */
140134 pxTopOfStack -- ;
@@ -151,7 +145,7 @@ BaseType_t xPortStartScheduler( void )
151145 /* This is called with interrupts already disabled. */
152146
153147 /* Put our manual switch (yield) function on a known
154- * vector. */
148+ vector. */
155149 setvect ( portSWITCH_INT_NUMBER , prvYieldProcessor );
156150
157151 /* Setup the tick interrupt. */
@@ -168,15 +162,15 @@ BaseType_t xPortStartScheduler( void )
168162static void __interrupt __far prvDummyISR ( void )
169163{
170164 /* 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. */
173167 outport ( portEIO_REGISTER , portCLEAR_INTERRUPT );
174168}
175169/*-----------------------------------------------------------*/
176170
177171/* 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 )
180174 static void __interrupt __far prvPreemptiveTick ( void )
181175 {
182176 /* Get the scheduler to update the task states following the tick. */
@@ -189,17 +183,17 @@ static void __interrupt __far prvDummyISR( void )
189183 /* Reset interrupt. */
190184 outport ( portEIO_REGISTER , portCLEAR_INTERRUPT );
191185 }
192- #else /* if ( configUSE_PREEMPTION == 1 ) */
186+ #else
193187 static void __interrupt __far prvNonPreemptiveTick ( void )
194188 {
195189 /* 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. */
197191 xTaskIncrementTick ();
198192
199193 /* Reset interrupt. */
200194 outport ( portEIO_REGISTER , portCLEAR_INTERRUPT );
201195 }
202- #endif /* if ( configUSE_PREEMPTION == 1 ) */
196+ #endif
203197/*-----------------------------------------------------------*/
204198
205199static void __interrupt __far prvYieldProcessor ( void )
@@ -217,25 +211,23 @@ void vPortEndScheduler( void )
217211
218212static void prvSetupTimerInterrupt ( void )
219213{
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 ;
222216
223217 /* Configure the timer, the dummy handler is used here as the init
224- * function leaves interrupts enabled. */
218+ function leaves interrupts enabled. */
225219 t2_init ( usTimerAMode , usTimerACompare , prvDummyISR );
226220
227221 /* Disable interrupts again before installing the real handlers. */
228222 portDISABLE_INTERRUPTS ();
229223
230- #if ( configUSE_PREEMPTION == 1 )
231-
224+ #if ( configUSE_PREEMPTION == 1 )
232225 /* Tick service routine used by the scheduler when preemptive scheduling is
233- * being used. */
226+ being used. */
234227 setvect ( usT2_IRQ , prvPreemptiveTick );
235228 #else
236-
237229 /* Tick service routine used by the scheduler when cooperative scheduling is
238- * being used. */
230+ being used. */
239231 setvect ( usT2_IRQ , prvNonPreemptiveTick );
240232 #endif
241233}
0 commit comments