mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Style: uncrusitfy
This commit is contained in:
parent
a5dbc2b1de
commit
718178c68a
406 changed files with 108795 additions and 106323 deletions
|
@ -1,23 +1,25 @@
|
|||
#include "FreeRTOSConfig.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static long brk_siz = 0;
|
||||
// #if configTOTAL_HEAP_SIZE != 0
|
||||
typedef int _heep_t;
|
||||
#define ROUNDUP(s) (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))
|
||||
static _heep_t _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];
|
||||
#define _heep_size ROUNDUP(configTOTAL_HEAP_SIZE)
|
||||
static long brk_siz = 0;
|
||||
/* #if configTOTAL_HEAP_SIZE != 0 */
|
||||
typedef int _heep_t;
|
||||
#define ROUNDUP( s ) ( ( ( s ) + sizeof( _heep_t ) - 1 ) & ~( sizeof( _heep_t ) - 1 ) )
|
||||
static _heep_t _heep[ ROUNDUP( configTOTAL_HEAP_SIZE ) / sizeof( _heep_t ) ];
|
||||
#define _heep_size ROUNDUP( configTOTAL_HEAP_SIZE )
|
||||
|
||||
/* #else
|
||||
extern char *_heep;
|
||||
extern long _heep_size;
|
||||
#endif
|
||||
*/
|
||||
extern char *sbrk(int size)
|
||||
{
|
||||
if (brk_siz + size > _heep_size || brk_siz + size < 0)
|
||||
|
||||
return((char*)-1);
|
||||
brk_siz += size;
|
||||
return( (char*)_heep + brk_siz - size);
|
||||
}
|
||||
* extern char *_heep;
|
||||
* extern long _heep_size;
|
||||
#endif
|
||||
*/
|
||||
extern char * sbrk( int size )
|
||||
{
|
||||
if( ( brk_siz + size > _heep_size ) || ( brk_siz + size < 0 ) )
|
||||
{
|
||||
return( ( char * ) -1 );
|
||||
}
|
||||
|
||||
brk_siz += size;
|
||||
return( ( char * ) _heep + brk_siz - size );
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* We require the address of the pxCurrentTCB variable, but don't want to know
|
||||
any details of its type. */
|
||||
* any details of its type. */
|
||||
typedef void TCB_t;
|
||||
extern volatile TCB_t * volatile pxCurrentTCB;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
#pragma asm
|
||||
#macro SaveContext
|
||||
ORCCR #0x20 ;Switch to user stack
|
||||
|
@ -45,21 +45,21 @@ extern volatile TCB_t * volatile pxCurrentTCB;
|
|||
STM1 (R14,R13,R12,R11,R10,R9,R8) ;Store R14-R8
|
||||
ST MDH, @-R15 ;Store MDH
|
||||
ST MDL, @-R15 ;Store MDL
|
||||
|
||||
|
||||
ANDCCR #0xDF ;Switch back to system stack
|
||||
LD @R15+,R0 ;Store PC to R0
|
||||
ORCCR #0x20 ;Switch to user stack
|
||||
ST R0,@-R15 ;Store PC to User stack
|
||||
|
||||
|
||||
ANDCCR #0xDF ;Switch back to system stack
|
||||
LD @R15+,R0 ;Store PS to R0
|
||||
ORCCR #0x20 ;Switch to user stack
|
||||
ST R0,@-R15 ;Store PS to User stack
|
||||
|
||||
|
||||
LDI #_pxCurrentTCB, R0 ;Get pxCurrentTCB address
|
||||
LD @R0, R0 ;Get the pxCurrentTCB->pxTopOfStack address
|
||||
ST R15,@R0 ;Store USP to pxCurrentTCB->pxTopOfStack
|
||||
|
||||
|
||||
ANDCCR #0xDF ;Switch back to system stack for the rest of tick ISR
|
||||
#endm
|
||||
|
||||
|
@ -85,7 +85,7 @@ extern volatile TCB_t * volatile pxCurrentTCB;
|
|||
LDM1 (R14,R13,R12,R11,R10,R9,R8) ;Restore R14-R8
|
||||
LDM0 (R7,R6,R5,R4,R3,R2,R1,R0) ;Restore R7-R0
|
||||
LD @R15+, RP ;Restore RP
|
||||
|
||||
|
||||
ANDCCR #0xDF ;Switch back to system stack for the rest of tick ISR
|
||||
#endm
|
||||
#pragma endasm
|
||||
|
@ -98,140 +98,142 @@ extern volatile TCB_t * volatile pxCurrentTCB;
|
|||
static void prvSetupTimerInterrupt( void );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Initialise the stack of a task to look exactly as if a call to
|
||||
/*
|
||||
* Initialise the stack of a task to look exactly as if a call to
|
||||
* portSAVE_CONTEXT had been called.
|
||||
*
|
||||
*
|
||||
* See the header file portable.h.
|
||||
*/
|
||||
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
void * pvParameters )
|
||||
{
|
||||
/* Place a few bytes of known values on the bottom of the stack.
|
||||
This is just useful for debugging. */
|
||||
/* Place a few bytes of known values on the bottom of the stack.
|
||||
* This is just useful for debugging. */
|
||||
|
||||
*pxTopOfStack = 0x11111111;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x22222222;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x33333333;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x11111111;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x22222222;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x33333333;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* This is a redundant push to the stack, it may be required if
|
||||
in some implementations of the compiler the parameter to the task
|
||||
is passed on to the stack rather than in R4 register. */
|
||||
*pxTopOfStack = (StackType_t)(pvParameters);
|
||||
pxTopOfStack--;
|
||||
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000000; /* RP */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00007777; /* R7 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00006666; /* R6 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00005555; /* R5 */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* In the current implementation of the compiler the first
|
||||
parameter to the task (or function) is passed via R4 parameter
|
||||
to the task, hence the pvParameters pointer is copied into the R4
|
||||
register. See compiler manual section 4.6.2 for more information. */
|
||||
*pxTopOfStack = ( StackType_t ) (pvParameters); /* R4 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00003333; /* R3 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00002222; /* R2 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00001111; /* R1 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000001; /* R0 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000EEEE; /* R14 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000DDDD; /* R13 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000CCCC; /* R12 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000BBBB; /* R11 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000AAAA; /* R10 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00009999; /* R9 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00008888; /* R8 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x11110000; /* MDH */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x22220000; /* MDL */
|
||||
pxTopOfStack--;
|
||||
/* This is a redundant push to the stack, it may be required if
|
||||
* in some implementations of the compiler the parameter to the task
|
||||
* is passed on to the stack rather than in R4 register. */
|
||||
*pxTopOfStack = ( StackType_t ) ( pvParameters );
|
||||
pxTopOfStack--;
|
||||
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000000; /* RP */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00007777; /* R7 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00006666; /* R6 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00005555; /* R5 */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* In the current implementation of the compiler the first
|
||||
* parameter to the task (or function) is passed via R4 parameter
|
||||
* to the task, hence the pvParameters pointer is copied into the R4
|
||||
* register. See compiler manual section 4.6.2 for more information. */
|
||||
*pxTopOfStack = ( StackType_t ) ( pvParameters ); /* R4 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00003333; /* R3 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00002222; /* R2 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00001111; /* R1 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000001; /* R0 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000EEEE; /* R14 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000DDDD; /* R13 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000CCCC; /* R12 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000BBBB; /* R11 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x0000AAAA; /* R10 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00009999; /* R9 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x00008888; /* R8 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x11110000; /* MDH */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x22220000; /* MDL */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* The start of the task code. */
|
||||
*pxTopOfStack = ( StackType_t ) pxCode; /* PC */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* The start of the task code. */
|
||||
*pxTopOfStack = ( StackType_t ) pxCode; /* PC */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* PS - User Mode, USP, ILM=31, Interrupts enabled */
|
||||
*pxTopOfStack = ( StackType_t ) 0x001F0030; /* PS */
|
||||
*pxTopOfStack = ( StackType_t ) 0x001F0030; /* PS */
|
||||
|
||||
return pxTopOfStack;
|
||||
return pxTopOfStack;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xPortStartScheduler( void )
|
||||
{
|
||||
/* Setup the hardware to generate the tick. */
|
||||
prvSetupTimerInterrupt();
|
||||
/* Setup the hardware to generate the tick. */
|
||||
prvSetupTimerInterrupt();
|
||||
|
||||
/* Restore the context of the first task that is going to run. */
|
||||
#pragma asm
|
||||
/* Restore the context of the first task that is going to run. */
|
||||
#pragma asm
|
||||
RestoreContext
|
||||
#pragma endasm
|
||||
#pragma endasm
|
||||
|
||||
/* Simulate a function call end as generated by the compiler. We will now
|
||||
jump to the start of the task the context of which we have just restored. */
|
||||
__asm(" reti ");
|
||||
/* Simulate a function call end as generated by the compiler. We will now
|
||||
* jump to the start of the task the context of which we have just restored. */
|
||||
__asm( " reti " );
|
||||
|
||||
/* Should not get here. */
|
||||
return pdFAIL;
|
||||
/* Should not get here. */
|
||||
return pdFAIL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEndScheduler( void )
|
||||
{
|
||||
/* Not implemented - unlikely to ever be required as there is nothing to
|
||||
return to. */
|
||||
/* Not implemented - unlikely to ever be required as there is nothing to
|
||||
* return to. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupTimerInterrupt( void )
|
||||
{
|
||||
/* The peripheral clock divided by 32 is used by the timer. */
|
||||
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL );
|
||||
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL );
|
||||
|
||||
/* Setup RLT0 to generate a tick interrupt. */
|
||||
/* Setup RLT0 to generate a tick interrupt. */
|
||||
|
||||
TMCSR0_CNTE = 0; /* Count Disable */
|
||||
TMCSR0_CSL = 0x2; /* CLKP/32 */
|
||||
TMCSR0_MOD = 0; /* Software trigger */
|
||||
TMCSR0_RELD = 1; /* Reload */
|
||||
|
||||
TMCSR0_UF = 0; /* Clear underflow flag */
|
||||
TMRLR0 = usReloadValue;
|
||||
TMCSR0_INTE = 1; /* Interrupt Enable */
|
||||
TMCSR0_CNTE = 1; /* Count Enable */
|
||||
TMCSR0_TRG = 1; /* Trigger */
|
||||
|
||||
PORTEN = 0x3; /* Port Enable */
|
||||
TMCSR0_CNTE = 0; /* Count Disable */
|
||||
TMCSR0_CSL = 0x2; /* CLKP/32 */
|
||||
TMCSR0_MOD = 0; /* Software trigger */
|
||||
TMCSR0_RELD = 1; /* Reload */
|
||||
|
||||
TMCSR0_UF = 0; /* Clear underflow flag */
|
||||
TMRLR0 = usReloadValue;
|
||||
TMCSR0_INTE = 1; /* Interrupt Enable */
|
||||
TMCSR0_CNTE = 1; /* Count Enable */
|
||||
TMCSR0_TRG = 1; /* Trigger */
|
||||
|
||||
PORTEN = 0x3; /* Port Enable */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
|
||||
/*
|
||||
* Tick ISR for preemptive scheduler. The tick count is incremented
|
||||
* after the context is saved. Then the context is switched if required,
|
||||
* and last the context of the task which is to be resumed is restored.
|
||||
*/
|
||||
/*
|
||||
* Tick ISR for preemptive scheduler. The tick count is incremented
|
||||
* after the context is saved. Then the context is switched if required,
|
||||
* and last the context of the task which is to be resumed is restored.
|
||||
*/
|
||||
|
||||
#pragma asm
|
||||
#pragma asm
|
||||
|
||||
.global _ReloadTimer0_IRQHandler
|
||||
_ReloadTimer0_IRQHandler:
|
||||
|
@ -253,28 +255,28 @@ const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTIC
|
|||
|
||||
RETI
|
||||
|
||||
#pragma endasm
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Tick ISR for the cooperative scheduler. All this does is increment the
|
||||
* tick count. We don't need to switch context, this can only be done by
|
||||
* manual calls to taskYIELD();
|
||||
*/
|
||||
__interrupt void ReloadTimer0_IRQHandler( void )
|
||||
{
|
||||
/* Clear RLT0 interrupt flag */
|
||||
TMCSR0_UF = 0;
|
||||
xTaskIncrementTick();
|
||||
}
|
||||
#pragma endasm
|
||||
|
||||
#endif
|
||||
#else /* if configUSE_PREEMPTION == 1 */
|
||||
|
||||
/*
|
||||
* Manual context switch. We can use a __nosavereg attribute as the context
|
||||
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
|
||||
* the context of the new task is restored saved.
|
||||
* Tick ISR for the cooperative scheduler. All this does is increment the
|
||||
* tick count. We don't need to switch context, this can only be done by
|
||||
* manual calls to taskYIELD();
|
||||
*/
|
||||
__interrupt void ReloadTimer0_IRQHandler( void )
|
||||
{
|
||||
/* Clear RLT0 interrupt flag */
|
||||
TMCSR0_UF = 0;
|
||||
xTaskIncrementTick();
|
||||
}
|
||||
|
||||
#endif /* if configUSE_PREEMPTION == 1 */
|
||||
|
||||
/*
|
||||
* Manual context switch. We can use a __nosavereg attribute as the context
|
||||
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
|
||||
* the context of the new task is restored saved.
|
||||
*/
|
||||
#pragma asm
|
||||
|
||||
|
@ -300,10 +302,10 @@ const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTIC
|
|||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Manual context switch. We can use a __nosavereg attribute as the context
|
||||
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
|
||||
* the context of the new task is restored saved.
|
||||
*/
|
||||
* Manual context switch. We can use a __nosavereg attribute as the context
|
||||
* would be saved by PortSAVE_CONTEXT(). The context is switched and then
|
||||
* the context of the new task is restored saved.
|
||||
*/
|
||||
#pragma asm
|
||||
|
||||
.global _vPortYield
|
||||
|
@ -312,9 +314,8 @@ const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTIC
|
|||
SaveContext ;Save context
|
||||
CALL32 _vTaskSwitchContext,R12 ;Switch context if required
|
||||
RestoreContext ;Restore context
|
||||
|
||||
|
||||
RETI
|
||||
|
||||
#pragma endasm
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -44,65 +44,64 @@
|
|||
*/
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE uint32_t
|
||||
#define portBASE_TYPE long
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE uint32_t
|
||||
#define portBASE_TYPE long
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Critical section management. */
|
||||
#if configKERNEL_INTERRUPT_PRIORITY != 30
|
||||
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - 30 (1Eh) being the default.
|
||||
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - 30 (1Eh) being the default.
|
||||
#endif
|
||||
#define portDISABLE_INTERRUPTS() __asm(" STILM #1Eh ")
|
||||
#define portENABLE_INTERRUPTS() __asm(" STILM #1Fh ")
|
||||
#define portDISABLE_INTERRUPTS() __asm( " STILM #1Eh " )
|
||||
#define portENABLE_INTERRUPTS() __asm( " STILM #1Fh " )
|
||||
|
||||
#define portENTER_CRITICAL() \
|
||||
__asm(" ST PS,@-R15 "); \
|
||||
__asm(" ANDCCR #0xef "); \
|
||||
#define portENTER_CRITICAL() \
|
||||
__asm( " ST PS,@-R15 " ); \
|
||||
__asm( " ANDCCR #0xef " ); \
|
||||
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
__asm(" LD @R15+,PS "); \
|
||||
#define portEXIT_CRITICAL() \
|
||||
__asm( " LD @R15+,PS " ); \
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#define portNOP() __asm( " nop " );
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#define portNOP() __asm( " nop " );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* portYIELD() uses a SW interrupt */
|
||||
#define portYIELD() __asm( " INT #40H " );
|
||||
#define portYIELD() __asm( " INT #40H " );
|
||||
|
||||
/* portYIELD_FROM_ISR() uses delayed interrupt */
|
||||
#define portYIELD_FROM_ISR() DICR_DLYI = 1
|
||||
#define portYIELD_FROM_ISR() DICR_DLYI = 1
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
|
||||
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
||||
|
|
|
@ -2,27 +2,29 @@
|
|||
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
|
||||
/* ELIGIBILITY FOR ANY PURPOSES. */
|
||||
/* (C) Fujitsu Microelectronics Europe GmbH */
|
||||
/*---------------------------------------------------------------------------
|
||||
__STD_LIB_sbrk.C
|
||||
- Used by heap_3.c for memory accocation and deletion.
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------
|
||||
* __STD_LIB_sbrk.C
|
||||
* - Used by heap_3.c for memory accocation and deletion.
|
||||
*
|
||||
* /*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static long brk_siz = 0;
|
||||
typedef int _heep_t;
|
||||
#define ROUNDUP(s) (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))
|
||||
static _heep_t _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];
|
||||
#define _heep_size ROUNDUP(configTOTAL_HEAP_SIZE)
|
||||
static long brk_siz = 0;
|
||||
typedef int _heep_t;
|
||||
#define ROUNDUP( s ) ( ( ( s ) + sizeof( _heep_t ) - 1 ) & ~( sizeof( _heep_t ) - 1 ) )
|
||||
static _heep_t _heep[ ROUNDUP( configTOTAL_HEAP_SIZE ) / sizeof( _heep_t ) ];
|
||||
#define _heep_size ROUNDUP( configTOTAL_HEAP_SIZE )
|
||||
|
||||
extern char *sbrk(int size)
|
||||
{
|
||||
if (brk_siz + size > _heep_size || brk_siz + size < 0)
|
||||
|
||||
return((char*)-1);
|
||||
brk_siz += size;
|
||||
return( (char*)_heep + brk_siz - size);
|
||||
}
|
||||
extern char * sbrk( int size )
|
||||
{
|
||||
if( ( brk_siz + size > _heep_size ) || ( brk_siz + size < 0 ) )
|
||||
{
|
||||
return( ( char * ) -1 );
|
||||
}
|
||||
|
||||
brk_siz += size;
|
||||
return( ( char * ) _heep + brk_siz - size );
|
||||
}
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
#include "task.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Implementation of functions defined in portable.h for the 16FX port.
|
||||
*----------------------------------------------------------*/
|
||||
* Implementation of functions defined in portable.h for the 16FX port.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Get current value of DPR and ADB registers
|
||||
/*
|
||||
* Get current value of DPR and ADB registers
|
||||
*/
|
||||
StackType_t xGet_DPR_ADB_bank( void );
|
||||
StackType_t xGet_DPR_ADB_bank( void );
|
||||
|
||||
/*
|
||||
* Get current value of DTB and PCB registers
|
||||
/*
|
||||
* Get current value of DTB and PCB registers
|
||||
*/
|
||||
StackType_t xGet_DTB_PCB_bank( void );
|
||||
|
||||
|
@ -49,176 +49,176 @@ static void prvSetupRLT0Interrupt( void );
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* We require the address of the pxCurrentTCB variable, but don't want to know
|
||||
* any details of its type.
|
||||
* any details of its type.
|
||||
*/
|
||||
typedef void TCB_t;
|
||||
extern volatile TCB_t * volatile pxCurrentTCB;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Macro to save a task context to the task stack. This macro copies the
|
||||
* saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from the system
|
||||
* stack to task stack pointed by user stack pointer ( USP for SMALL and
|
||||
/*
|
||||
* Macro to save a task context to the task stack. This macro copies the
|
||||
* saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from the system
|
||||
* stack to task stack pointed by user stack pointer ( USP for SMALL and
|
||||
* MEDIUM memory model amd USB:USP for COMPACT and LARGE memory model ),
|
||||
* then it pushes the general purpose registers RW0-RW7 on to the task
|
||||
* stack. Finally the resultant stack pointer value is saved into the
|
||||
* task control block so it can be retrieved the next time the task
|
||||
* then it pushes the general purpose registers RW0-RW7 on to the task
|
||||
* stack. Finally the resultant stack pointer value is saved into the
|
||||
* task control block so it can be retrieved the next time the task
|
||||
* executes.
|
||||
*/
|
||||
#if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )
|
||||
*/
|
||||
#if ( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )
|
||||
|
||||
#define portSAVE_CONTEXT() \
|
||||
{ __asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
|
||||
__asm(" MOVW A, _pxCurrentTCB "); \
|
||||
__asm(" MOVW A, SP "); \
|
||||
__asm(" SWAPW "); \
|
||||
__asm(" MOVW @AL, AH "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
}
|
||||
#define portSAVE_CONTEXT() \
|
||||
{ __asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
|
||||
__asm( " MOVW A, _pxCurrentTCB " ); \
|
||||
__asm( " MOVW A, SP " ); \
|
||||
__asm( " SWAPW " ); \
|
||||
__asm( " MOVW @AL, AH " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Macro to restore a task context from the task stack. This is effecti-
|
||||
* vely the reverse of SAVE_CONTEXT(). First the stack pointer value
|
||||
* (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT and
|
||||
* LARGE memory model ) is loaded from the task control block. Next the
|
||||
* (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT and
|
||||
* LARGE memory model ) is loaded from the task control block. Next the
|
||||
* value of all the general purpose registers RW0-RW7 is retrieved. Fina-
|
||||
* lly it copies of the context ( AH:AL, DPR:ADB, DTB:PCB, PC and PS) of
|
||||
* the task to be executed upon RETI from user stack to system stack.
|
||||
* lly it copies of the context ( AH:AL, DPR:ADB, DTB:PCB, PC and PS) of
|
||||
* the task to be executed upon RETI from user stack to system stack.
|
||||
*/
|
||||
|
||||
#define portRESTORE_CONTEXT() \
|
||||
{ __asm(" MOVW A, _pxCurrentTCB "); \
|
||||
__asm(" MOVW A, @A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" MOVW SP, A "); \
|
||||
__asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
}
|
||||
|
||||
#elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
|
||||
|
||||
#define portSAVE_CONTEXT() \
|
||||
{ __asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
|
||||
__asm(" MOVL A, _pxCurrentTCB "); \
|
||||
__asm(" MOVL RL2, A "); \
|
||||
__asm(" MOVW A, SP "); \
|
||||
__asm(" MOVW @RL2+0, A "); \
|
||||
__asm(" MOV A, USB "); \
|
||||
__asm(" MOV @RL2+2, A "); \
|
||||
}
|
||||
|
||||
#define portRESTORE_CONTEXT() \
|
||||
{ __asm(" MOVL A, _pxCurrentTCB "); \
|
||||
__asm(" MOVL RL2, A "); \
|
||||
__asm(" MOVW A, @RL2+0 "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" MOVW SP, A "); \
|
||||
__asm(" MOV A, @RL2+2 "); \
|
||||
__asm(" MOV USB, A "); \
|
||||
__asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
__asm(" AND CCR,#H'DF "); \
|
||||
__asm(" POPW A "); \
|
||||
__asm(" OR CCR,#H'20 "); \
|
||||
__asm(" PUSHW A "); \
|
||||
}
|
||||
#endif
|
||||
#define portRESTORE_CONTEXT() \
|
||||
{ __asm( " MOVW A, _pxCurrentTCB " ); \
|
||||
__asm( " MOVW A, @A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " MOVW SP, A " ); \
|
||||
__asm( " POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
#elif ( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
|
||||
|
||||
/*
|
||||
#define portSAVE_CONTEXT() \
|
||||
{ __asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
|
||||
__asm( " MOVL A, _pxCurrentTCB " ); \
|
||||
__asm( " MOVL RL2, A " ); \
|
||||
__asm( " MOVW A, SP " ); \
|
||||
__asm( " MOVW @RL2+0, A " ); \
|
||||
__asm( " MOV A, USB " ); \
|
||||
__asm( " MOV @RL2+2, A " ); \
|
||||
}
|
||||
|
||||
#define portRESTORE_CONTEXT() \
|
||||
{ __asm( " MOVL A, _pxCurrentTCB " ); \
|
||||
__asm( " MOVL RL2, A " ); \
|
||||
__asm( " MOVW A, @RL2+0 " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " MOVW SP, A " ); \
|
||||
__asm( " MOV A, @RL2+2 " ); \
|
||||
__asm( " MOV USB, A " ); \
|
||||
__asm( " POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
__asm( " AND CCR,#H'DF " ); \
|
||||
__asm( " POPW A " ); \
|
||||
__asm( " OR CCR,#H'20 " ); \
|
||||
__asm( " PUSHW A " ); \
|
||||
}
|
||||
#endif /* if ( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) ) */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Functions for obtaining the current value of DPR:ADB, DTB:PCB bank registers
|
||||
*/
|
||||
|
||||
|
||||
#pragma asm
|
||||
|
||||
.GLOBAL _xGet_DPR_ADB_bank
|
||||
|
@ -253,256 +253,257 @@ _xGet_DTB_PCB_bank:
|
|||
#pragma endasm
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Initialise the stack of a task to look exactly as if a call to
|
||||
/*
|
||||
* Initialise the stack of a task to look exactly as if a call to
|
||||
* portSAVE_CONTEXT had been called.
|
||||
*
|
||||
*
|
||||
* See the header file portable.h.
|
||||
*/
|
||||
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
void * pvParameters )
|
||||
{
|
||||
/* Place a few bytes of known values on the bottom of the stack.
|
||||
This is just useful for debugging. */
|
||||
*pxTopOfStack = 0x1111;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x2222;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x3333;
|
||||
pxTopOfStack--;
|
||||
/* Place a few bytes of known values on the bottom of the stack.
|
||||
* This is just useful for debugging. */
|
||||
*pxTopOfStack = 0x1111;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x2222;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0x3333;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* Once the task is called the task would push the pointer to the
|
||||
parameter onto the stack. Hence here the pointer would be copied to the stack
|
||||
first. When using the COMPACT or LARGE memory model the pointer would be 24
|
||||
bits, and when using the SMALL or MEDIUM memory model the pointer would be 16
|
||||
bits. */
|
||||
#if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
|
||||
{
|
||||
*pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
/* Once the task is called the task would push the pointer to the
|
||||
* parameter onto the stack. Hence here the pointer would be copied to the stack
|
||||
* first. When using the COMPACT or LARGE memory model the pointer would be 24
|
||||
* bits, and when using the SMALL or MEDIUM memory model the pointer would be 16
|
||||
* bits. */
|
||||
#if ( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
|
||||
{
|
||||
*pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
|
||||
*pxTopOfStack = ( StackType_t ) ( pvParameters );
|
||||
pxTopOfStack--;
|
||||
|
||||
/* This is redundant push to the stack. This is required in order to introduce
|
||||
an offset so that the task accesses a parameter correctly that is passed on to
|
||||
the task stack. */
|
||||
#if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
|
||||
{
|
||||
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
pxTopOfStack--;
|
||||
|
||||
/* This is redundant push to the stack. This is required in order to introduce
|
||||
an offset so the task correctly accesses the parameter passed on the task stack. */
|
||||
/* This is redundant push to the stack. This is required in order to introduce
|
||||
* an offset so that the task accesses a parameter correctly that is passed on to
|
||||
* the task stack. */
|
||||
#if ( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
|
||||
{
|
||||
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This is redundant push to the stack. This is required in order to introduce
|
||||
* an offset so the task correctly accesses the parameter passed on the task stack. */
|
||||
*pxTopOfStack = ( StackType_t ) ( pxCode );
|
||||
pxTopOfStack--;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */
|
||||
*pxTopOfStack = 0xE0C0;
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = 0xE0C0;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* PC */
|
||||
*pxTopOfStack = ( StackType_t ) ( pxCode );
|
||||
pxTopOfStack--;
|
||||
|
||||
/* PC */
|
||||
*pxTopOfStack = ( StackType_t ) ( pxCode );
|
||||
pxTopOfStack--;
|
||||
|
||||
/* DTB | PCB */
|
||||
#if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT
|
||||
{
|
||||
*pxTopOfStack = xGet_DTB_PCB_bank();
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
#if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT
|
||||
{
|
||||
*pxTopOfStack = xGet_DTB_PCB_bank();
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used
|
||||
along with PC to indicate the start address of the function. */
|
||||
#if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
|
||||
{
|
||||
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
/* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used
|
||||
* along with PC to indicate the start address of the function. */
|
||||
#if ( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
|
||||
{
|
||||
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
|
||||
pxTopOfStack--;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DPR | ADB */
|
||||
*pxTopOfStack = xGet_DPR_ADB_bank();
|
||||
pxTopOfStack--;
|
||||
|
||||
/* AL */
|
||||
*pxTopOfStack = ( StackType_t ) 0x9999;
|
||||
pxTopOfStack--;
|
||||
/* DPR | ADB */
|
||||
*pxTopOfStack = xGet_DPR_ADB_bank();
|
||||
pxTopOfStack--;
|
||||
|
||||
/* AH */
|
||||
*pxTopOfStack = ( StackType_t ) 0xAAAA;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* Next the general purpose registers. */
|
||||
*pxTopOfStack = ( StackType_t ) 0x7777; /* RW7 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x6666; /* RW6 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x5555; /* RW5 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x4444; /* RW4 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x3333; /* RW3 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x2222; /* RW2 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x1111; /* RW1 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x8888; /* RW0 */
|
||||
|
||||
return pxTopOfStack;
|
||||
/* AL */
|
||||
*pxTopOfStack = ( StackType_t ) 0x9999;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* AH */
|
||||
*pxTopOfStack = ( StackType_t ) 0xAAAA;
|
||||
pxTopOfStack--;
|
||||
|
||||
/* Next the general purpose registers. */
|
||||
*pxTopOfStack = ( StackType_t ) 0x7777; /* RW7 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x6666; /* RW6 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x5555; /* RW5 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x4444; /* RW4 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x3333; /* RW3 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x2222; /* RW2 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x1111; /* RW1 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x8888; /* RW0 */
|
||||
|
||||
return pxTopOfStack;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupRLT0Interrupt( void )
|
||||
{
|
||||
/* The peripheral clock divided by 16 is used by the timer. */
|
||||
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );
|
||||
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );
|
||||
|
||||
/* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */
|
||||
TMRLR0 = usReloadValue;
|
||||
|
||||
/* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */
|
||||
TMRLR0 = usReloadValue;
|
||||
|
||||
/* prescaler 1:16, reload, interrupt enable, count enable, trigger */
|
||||
TMCSR0 = 0x041B;
|
||||
TMCSR0 = 0x041B;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xPortStartScheduler( void )
|
||||
{
|
||||
/* Setup the hardware to generate the tick. */
|
||||
prvSetupRLT0Interrupt();
|
||||
|
||||
/* Restore the context of the first task that is going to run. */
|
||||
portRESTORE_CONTEXT();
|
||||
/* Setup the hardware to generate the tick. */
|
||||
prvSetupRLT0Interrupt();
|
||||
|
||||
/* Simulate a function call end as generated by the compiler. We will now
|
||||
jump to the start of the task the context of which we have just restored. */
|
||||
__asm(" reti ");
|
||||
/* Restore the context of the first task that is going to run. */
|
||||
portRESTORE_CONTEXT();
|
||||
|
||||
/* Simulate a function call end as generated by the compiler. We will now
|
||||
* jump to the start of the task the context of which we have just restored. */
|
||||
__asm( " reti " );
|
||||
|
||||
|
||||
/* Should not get here. */
|
||||
return pdTRUE;
|
||||
/* Should not get here. */
|
||||
return pdTRUE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEndScheduler( void )
|
||||
{
|
||||
/* Not implemented - unlikely to ever be required as there is nothing to
|
||||
return to. */
|
||||
/* Not implemented - unlikely to ever be required as there is nothing to
|
||||
* return to. */
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* The interrupt service routine used depends on whether the pre-emptive
|
||||
* scheduler is being used or not.
|
||||
*/
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
|
||||
/*
|
||||
* Tick ISR for preemptive scheduler. We can use a __nosavereg attribute
|
||||
* as the context is to be saved by the portSAVE_CONTEXT() macro, not the
|
||||
* compiler generated code. The tick count is incremented after the context
|
||||
* is saved.
|
||||
*/
|
||||
__nosavereg __interrupt void prvRLT0_TICKISR( void )
|
||||
{
|
||||
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
|
||||
/* Clear RLT0 interrupt flag */
|
||||
TMCSR0_UF = 0;
|
||||
|
||||
/* Increment the tick count then switch to the highest priority task
|
||||
that is ready to run. */
|
||||
if( xTaskIncrementTick() != pdFALSE )
|
||||
{
|
||||
vTaskSwitchContext();
|
||||
}
|
||||
/*
|
||||
* Tick ISR for preemptive scheduler. We can use a __nosavereg attribute
|
||||
* as the context is to be saved by the portSAVE_CONTEXT() macro, not the
|
||||
* compiler generated code. The tick count is incremented after the context
|
||||
* is saved.
|
||||
*/
|
||||
__nosavereg __interrupt void prvRLT0_TICKISR( void )
|
||||
{
|
||||
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
}
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
|
||||
#else
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
|
||||
/*
|
||||
* Tick ISR for the cooperative scheduler. All this does is increment the
|
||||
* tick count. We don't need to switch context, this can only be done by
|
||||
* manual calls to taskYIELD();
|
||||
*/
|
||||
__interrupt void prvRLT0_TICKISR( void )
|
||||
{
|
||||
/* Clear RLT0 interrupt flag */
|
||||
TMCSR0_UF = 0;
|
||||
|
||||
xTaskIncrementTick();
|
||||
}
|
||||
/* Clear RLT0 interrupt flag */
|
||||
TMCSR0_UF = 0;
|
||||
|
||||
#endif
|
||||
/* Increment the tick count then switch to the highest priority task
|
||||
* that is ready to run. */
|
||||
if( xTaskIncrementTick() != pdFALSE )
|
||||
{
|
||||
vTaskSwitchContext();
|
||||
}
|
||||
|
||||
/* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
}
|
||||
|
||||
#else /* if configUSE_PREEMPTION == 1 */
|
||||
|
||||
/*
|
||||
* Tick ISR for the cooperative scheduler. All this does is increment the
|
||||
* tick count. We don't need to switch context, this can only be done by
|
||||
* manual calls to taskYIELD();
|
||||
*/
|
||||
__interrupt void prvRLT0_TICKISR( void )
|
||||
{
|
||||
/* Clear RLT0 interrupt flag */
|
||||
TMCSR0_UF = 0;
|
||||
|
||||
xTaskIncrementTick();
|
||||
}
|
||||
|
||||
#endif /* if configUSE_PREEMPTION == 1 */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Manual context switch. We can use a __nosavereg attribute as the context
|
||||
* is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated
|
||||
* Manual context switch. We can use a __nosavereg attribute as the context
|
||||
* is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated
|
||||
* code.
|
||||
*/
|
||||
__nosavereg __interrupt void vPortYield( void )
|
||||
{
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
|
||||
/* Switch to the highest priority task that is ready to run. */
|
||||
vTaskSwitchContext();
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT();
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
|
||||
/* Switch to the highest priority task that is ready to run. */
|
||||
vTaskSwitchContext();
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
__nosavereg __interrupt void vPortYieldDelayed( void )
|
||||
{
|
||||
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
|
||||
/* Clear delayed interrupt flag */
|
||||
__asm (" CLRB 03A4H:0 ");
|
||||
|
||||
/* Switch to the highest priority task that is ready to run. */
|
||||
vTaskSwitchContext();
|
||||
|
||||
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT();
|
||||
{
|
||||
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
}
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
|
||||
/* Clear delayed interrupt flag */
|
||||
__asm( " CLRB 03A4H:0 " );
|
||||
|
||||
/* Switch to the highest priority task that is ready to run. */
|
||||
vTaskSwitchContext();
|
||||
|
||||
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
|
||||
__DI();
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT();
|
||||
|
||||
/* Enable interrupts */
|
||||
__EI();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
#include <stddef.h>
|
||||
|
||||
/* Constants denoting the available memory models. These are used within
|
||||
FreeRTOSConfig.h to set the configMEMMODEL value. */
|
||||
#define portSMALL 0
|
||||
#define portMEDIUM 1
|
||||
#define portCOMPACT 2
|
||||
#define portLARGE 3
|
||||
* FreeRTOSConfig.h to set the configMEMMODEL value. */
|
||||
#define portSMALL 0
|
||||
#define portMEDIUM 1
|
||||
#define portCOMPACT 2
|
||||
#define portLARGE 3
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
|
@ -50,66 +50,65 @@ FreeRTOSConfig.h to set the configMEMMODEL value. */
|
|||
*/
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE uint16_t
|
||||
#define portBASE_TYPE short
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE uint16_t
|
||||
#define portBASE_TYPE short
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef short BaseType_t;
|
||||
typedef unsigned short UBaseType_t;
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef short BaseType_t;
|
||||
typedef unsigned short UBaseType_t;
|
||||
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Critical section handling. */
|
||||
#if configKERNEL_INTERRUPT_PRIORITY != 6
|
||||
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - #06H being the default.
|
||||
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - #06H being the default.
|
||||
#endif
|
||||
#define portDISABLE_INTERRUPTS() __asm(" MOV ILM, #06h ")
|
||||
#define portENABLE_INTERRUPTS() __asm(" MOV ILM, #07h ")
|
||||
#define portDISABLE_INTERRUPTS() __asm( " MOV ILM, #06h " )
|
||||
#define portENABLE_INTERRUPTS() __asm( " MOV ILM, #07h " )
|
||||
|
||||
#define portENTER_CRITICAL() \
|
||||
{ __asm(" PUSHW PS "); \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
}
|
||||
#define portENTER_CRITICAL() \
|
||||
{ __asm( " PUSHW PS " ); \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
}
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
{ __asm(" POPW PS "); \
|
||||
}
|
||||
#define portEXIT_CRITICAL() \
|
||||
{ __asm( " POPW PS " ); \
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 2
|
||||
#define portNOP() __asm( " NOP " );
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 2
|
||||
#define portNOP() __asm( " NOP " );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* portYIELD() uses SW interrupt */
|
||||
#define portYIELD() __asm( " INT #122 " );
|
||||
#define portYIELD() __asm( " INT #122 " );
|
||||
|
||||
/* portYIELD_FROM_ISR() uses delayed interrupt */
|
||||
#define portYIELD_FROM_ISR() __asm( " SETB 03A4H:0 " );
|
||||
#define portYIELD_FROM_ISR() __asm( " SETB 03A4H:0 " );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
|
||||
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue