mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Tidy up the port layer for the MSP430X IAR port - still a work in progress.
This commit is contained in:
parent
0a31276719
commit
c7a110a853
|
@ -97,8 +97,6 @@ void vPortSetupTimerInterrupt( void );
|
||||||
*/
|
*/
|
||||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
||||||
{
|
{
|
||||||
unsigned short usNibble;
|
|
||||||
unsigned long ulSP_PC_Combined;
|
|
||||||
unsigned short *pusTopOfStack;
|
unsigned short *pusTopOfStack;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -113,30 +111,13 @@ unsigned short *pusTopOfStack;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The msp430x automatically pushes the PC then SR onto the stack before
|
|
||||||
executing an ISR. We want the stack to look just as if this has happened
|
|
||||||
so place a pointer to the start of the task on the stack first - followed
|
|
||||||
by the flags we want the task to use when it starts up. */
|
|
||||||
|
|
||||||
/* When placed on the stack, the top four bits of the status register
|
|
||||||
contain bits 19:16 of the 20 bit return address (pxCode). */
|
|
||||||
#ifdef GENERATE_ISR_STACK_FRAME
|
|
||||||
usNibble = ( unsigned short ) ( ( ( unsigned long ) pxCode >> 15UL ) & 0x0fUL );
|
|
||||||
|
|
||||||
ulSP_PC_Combined = ( unsigned long ) pxCode;
|
|
||||||
ulSP_PC_Combined <<= 16;
|
|
||||||
ulSP_PC_Combined |= ( usNibble << 12 );
|
|
||||||
ulSP_PC_Combined |= portFLAGS_INT_ENABLED;
|
|
||||||
*pxTopOfStack = ulSP_PC_Combined;
|
|
||||||
pxTopOfStack--;
|
|
||||||
#else
|
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) pxCode;
|
*pxTopOfStack = ( portSTACK_TYPE ) pxCode;
|
||||||
pusTopOfStack = ( unsigned short * ) pxTopOfStack;
|
pusTopOfStack = ( unsigned short * ) pxTopOfStack;
|
||||||
pusTopOfStack--;
|
pusTopOfStack--;
|
||||||
*pusTopOfStack = portFLAGS_INT_ENABLED;
|
*pusTopOfStack = portFLAGS_INT_ENABLED;
|
||||||
pusTopOfStack -= 2;
|
pusTopOfStack -= 2;
|
||||||
pxTopOfStack = ( portSTACK_TYPE * ) pusTopOfStack;
|
pxTopOfStack = ( portSTACK_TYPE * ) pusTopOfStack;
|
||||||
#endif
|
|
||||||
/* Next the general purpose registers. */
|
/* Next the general purpose registers. */
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0xffffff;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0xffffff;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
@ -154,12 +135,8 @@ unsigned short *pusTopOfStack;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x888888;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x888888;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* When the task starts is will expect to find the function parameter in
|
|
||||||
R15. */
|
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x555555;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x555555;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x666666;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x666666;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x555555;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x555555;
|
||||||
|
|
|
@ -71,8 +71,13 @@
|
||||||
*
|
*
|
||||||
* If the preemptive scheduler is in use a context switch can also occur.
|
* If the preemptive scheduler is in use a context switch can also occur.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RSEG ISR_CODE
|
RSEG ISR_CODE
|
||||||
|
|
||||||
vTickISR:
|
vTickISR:
|
||||||
|
|
||||||
|
/* The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs
|
||||||
|
to save it manually before it gets modified (interrupts get disabled). */
|
||||||
push.w sr
|
push.w sr
|
||||||
portSAVE_CONTEXT
|
portSAVE_CONTEXT
|
||||||
|
|
||||||
|
@ -92,15 +97,9 @@ vTickISR:
|
||||||
*/
|
*/
|
||||||
vPortYield:
|
vPortYield:
|
||||||
|
|
||||||
/* Mimic an interrupt by combining the SR and the PC, the latter having
|
/* The sr needs saving before it is modified. */
|
||||||
already been pushed onto the stack. R14 is a scratch registers. */
|
|
||||||
// popx.a r14 /* r14 will hold the 20 bit PC. */
|
|
||||||
// push.w r14 /* Push just 16 bits of the 20bit PC back onto the stack. */
|
|
||||||
// rram.a #4, r14 /* Move the top 4 bits of the PC down ready to be combined with the SP. */
|
|
||||||
// and.w #0xf000, r14/* Ensure other bits are clear. */
|
|
||||||
// add.w sr, r14 /* Combine the top 4 bits of the PC with the SR. */
|
|
||||||
// push.w r14 /* Push the generated combined value onto the stack. */
|
|
||||||
push.w sr
|
push.w sr
|
||||||
|
|
||||||
/* Now the SR is stacked we can disable interrupts. */
|
/* Now the SR is stacked we can disable interrupts. */
|
||||||
dint
|
dint
|
||||||
nop
|
nop
|
||||||
|
@ -130,15 +129,5 @@ xPortStartScheduler:
|
||||||
portRESTORE_CONTEXT
|
portRESTORE_CONTEXT
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
/* Install vTickISR as the interrupt on the vector specified by the
|
|
||||||
application code. */
|
|
||||||
/*COMMON INTVEC *./
|
|
||||||
/*ORG 0xFF80 + configTICK_INTERRUPT_VECTOR
|
|
||||||
ORG 0xFFEC
|
|
||||||
|
|
||||||
__vTickISR__: DC16 0xabcd*/
|
|
||||||
|
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue