* Implementation of functions defined in portable.h for the 16FX port.\r
*----------------------------------------------------------*/\r
\r
-/* ------- Memory models --------- default address size */\r
- /* data code */\r
-#define SMALL 0 /* 16 Bit 16 Bit */\r
-#define MEDIUM 1 /* 16 Bit 24 Bit */\r
-#define COMPACT 2 /* 24 Bit 16 Bit */\r
-#define LARGE 3 /* 24 Bit 24 Bit */\r
-\r
/* \r
* The below define should be same as the option selected by the Memory \r
* Model (Project->Setup Project->C Compiler->Catagory->Target Depend ) \r
*/\r
-#define MEMMODEL MEDIUM\r
+#define configMEMMODEL portMEDIUM\r
\r
/*-----------------------------------------------------------*/\r
\r
+/* \r
+ * Get current value of DPR and ADB registers \r
+ */\r
+portSTACK_TYPE xGet_DPR_ADB_bank( void ); \r
+\r
+/* \r
+ * Get current value of DTB and PCB registers \r
+ */\r
+portSTACK_TYPE xGet_DTB_PCB_bank( void );\r
+\r
+/* \r
+ * Get current register pointer \r
+ */ \r
+portCHAR xGet_RP( void ); \r
+\r
+/*\r
+ * Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but\r
+ * can be done using any given RLT.\r
+ */\r
+static void prvSetupRLT0Interrupt( void );\r
+\r
+/*-----------------------------------------------------------*/ \r
+\r
/* \r
* We require the address of the pxCurrentTCB variable, but don't want to know\r
* any details of its type. \r
typedef void tskTCB;\r
extern volatile tskTCB * volatile pxCurrentTCB;\r
\r
-/*-----------------------------------------------------------*/\r
-\r
-/* Get current value of DPR and ADB registers */\r
-portSTACK_TYPE Get_DPR_ADB_bank(void); \r
-\r
-/* Get current value of DTB and PCB registers */\r
-portSTACK_TYPE Get_DTB_PCB_bank(void);\r
-\r
-/* Get current register pointer */ \r
-portCHAR Get_RP(void); \r
+/* Constants required to handle critical sections. */\r
+#define portNO_CRITICAL_NESTING ( ( unsigned portBASE_TYPE ) 0x1234 )\r
+volatile unsigned portBASE_TYPE uxCriticalNesting = 9999UL;\r
\r
-/*-----------------------------------------------------------*/ \r
+/*-----------------------------------------------------------*/\r
\r
/* \r
* Macro to save a task context to the task stack. This macro copies the \r
* executes.\r
*/\r
\r
-#if (MEMMODEL == SMALL || MEMMODEL == MEDIUM) \r
-#define portSAVE_CONTEXT() \\r
- { __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
- __asm(" MOVW A, _pxCurrentTCB "); \\r
- __asm(" MOVW A, SP "); \\r
- __asm(" SWAPW "); \\r
- __asm(" MOVW @AL, AH "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- }\r
+#if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )\r
+\r
+ #define portSAVE_CONTEXT() \\r
+ { __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
+ __asm(" MOVW A, _pxCurrentTCB "); \\r
+ __asm(" MOVW A, SP "); \\r
+ __asm(" SWAPW "); \\r
+ __asm(" MOVW @AL, AH "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ }\r
\r
-/* \r
- * Macro to restore a task context from the task stack. This is effecti-\r
- * vely the reverse of portSAVE_CONTEXT(). First the stack pointer value\r
- * (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT and \r
- * LARGE memory model ) is loaded from the task control block. Next the \r
- * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
- * lly it copies of the context ( AH:AL, DPR:ADB, DTB:PCB, PC and PS) of \r
- * the task to be executed upon RETI from user stack to system stack. \r
- */\r
+ /* \r
+ * Macro to restore a task context from the task stack. This is effecti-\r
+ * vely the reverse of SAVE_CONTEXT(). First the stack pointer value\r
+ * (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT and \r
+ * LARGE memory model ) is loaded from the task control block. Next the \r
+ * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
+ * lly it copies of the context ( AH:AL, DPR:ADB, DTB:PCB, PC and PS) of \r
+ * the task to be executed upon RETI from user stack to system stack. \r
+ */\r
\r
-#define portRESTORE_CONTEXT() \\r
- { __asm(" MOVW A, _pxCurrentTCB "); \\r
- __asm(" MOVW A, @A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" MOVW SP, A "); \\r
- __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- }\r
+ #define portRESTORE_CONTEXT() \\r
+ { __asm(" MOVW A, _pxCurrentTCB "); \\r
+ __asm(" MOVW A, @A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" MOVW SP, A "); \\r
+ \\r
+ /* Load the saves uxCriticalNesting value into RW0. */ \\r
+ __asm(" POPW (RW0) "); \\r
+ \\r
+ /* Save the loaded value into the uxCriticalNesting variable. */ \\r
+ __asm(" MOVW _uxCriticalNesting, RW0 "); \\r
+ \\r
+ __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ }\r
\r
-#elif (MEMMODEL == COMPACT || MEMMODEL == LARGE) \r
-#define portSAVE_CONTEXT() \\r
- { __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" POPW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
- __asm(" MOVL A, _pxCurrentTCB "); \\r
- __asm(" MOVL RL2, A "); \\r
- __asm(" MOVW A, SP "); \\r
- __asm(" MOVW @RL2+0, A "); \\r
- __asm(" MOV A, USB "); \\r
- __asm(" MOV @RL2+2, A "); \\r
- } \r
+#elif (configMEMMODEL == portCOMPACT || configMEMMODEL == portLARGE) \r
+\r
+ #define portSAVE_CONTEXT() \\r
+ { __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
+ __asm(" MOVL A, _pxCurrentTCB "); \\r
+ __asm(" MOVL RL2, A "); \\r
+ __asm(" MOVW A, SP "); \\r
+ __asm(" MOVW @RL2+0, A "); \\r
+ __asm(" MOV A, USB "); \\r
+ __asm(" MOV @RL2+2, A "); \\r
+ } \r
\r
-#define portRESTORE_CONTEXT() \\r
- { __asm(" MOVL A, _pxCurrentTCB "); \\r
- __asm(" MOVL RL2, A "); \\r
- __asm(" MOVW A, @RL2+0 "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" MOVW SP, A "); \\r
- __asm(" MOV A, @RL2+2 "); \\r
- __asm(" MOV USB, A "); \\r
- __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- __asm(" AND CCR,#H'DF "); \\r
- __asm(" POPW A "); \\r
- __asm(" OR CCR,#H'20 "); \\r
- __asm(" PUSHW A "); \\r
- }\r
+ #define portRESTORE_CONTEXT() \\r
+ { __asm(" MOVL A, _pxCurrentTCB "); \\r
+ __asm(" MOVL RL2, A "); \\r
+ __asm(" MOVW A, @RL2+0 "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" MOVW SP, A "); \\r
+ __asm(" MOV A, @RL2+2 "); \\r
+ __asm(" MOV USB, A "); \\r
+ __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ __asm(" AND CCR,#H'DF "); \\r
+ __asm(" POPW A "); \\r
+ __asm(" OR CCR,#H'20 "); \\r
+ __asm(" PUSHW A "); \\r
+ }\r
#endif\r
\r
/*-----------------------------------------------------------*/ \r
*/\r
\r
#pragma asm\r
- .GLOBAL _Get_DPR_ADB_bank\r
- .GLOBAL _Get_DTB_PCB_bank\r
- .GLOBAL _Get_RP\r
+\r
+ .GLOBAL _xGet_DPR_ADB_bank\r
+ .GLOBAL _xGet_DTB_PCB_bank\r
+ .GLOBAL _xGet_RP\r
.SECTION CODE, CODE, ALIGN=1\r
-_Get_DPR_ADB_bank:\r
+\r
+_xGet_DPR_ADB_bank:\r
+\r
MOV A, DPR\r
SWAP\r
MOV A, ADB\r
ORW A\r
-#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
- RETP\r
-#elif MEMMODEL == SMALL || MEMMODEL == COMPACT \r
- RET\r
-#endif \r
+ #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
+ RETP\r
+ #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT \r
+ RET\r
+ #endif \r
+\r
+\r
+_xGet_DTB_PCB_bank:\r
\r
-_Get_DTB_PCB_bank:\r
MOV A, DTB\r
SWAP\r
MOV A, PCB\r
ORW A\r
-#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
- RETP\r
-#elif MEMMODEL == SMALL || MEMMODEL == COMPACT \r
- RET\r
-#endif \r
+ #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
+ RETP\r
+ #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT \r
+ RET\r
+ #endif \r
+\r
+\r
+_xGet_RP:\r
\r
-_Get_RP:\r
PUSHW PS\r
POPW A\r
SWAP\r
ANDW A,#0x1f\r
- #if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
- RETP\r
-#elif MEMMODEL == SMALL || MEMMODEL == COMPACT \r
- RET\r
-#endif \r
-#pragma endasm\r
-/*-----------------------------------------------------------*/\r
+ #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
+ RETP\r
+ #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT \r
+ RET\r
+ #endif \r
\r
-/*\r
- * Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but\r
- * can be done using any given RLT.\r
- */\r
-static void prvSetupRLT0Interrupt( void );\r
+\r
+#pragma endasm\r
/*-----------------------------------------------------------*/\r
\r
/* \r
{\r
/* Place a few bytes of known values on the bottom of the stack. \r
This is just useful for debugging. */\r
-\r
*pxTopOfStack = 0x1111;\r
pxTopOfStack--;\r
*pxTopOfStack = 0x2222;\r
*pxTopOfStack = 0x3333;\r
pxTopOfStack--;\r
\r
- /* Once the task is called the called would push the pointer to the\r
+ /* Once the task is called the task would push the pointer to the\r
parameter on to the stack. Hence here the pointer would be copied first\r
to the stack. In case of COMPACT or LARGE memory model such pointer \r
would be 24 bit and in case of SMALL or MEDIUM memory model such pointer \r
would be 16 bit */ \r
-#if MEMMODEL == COMPACT || MEMMODEL == LARGE\r
- *pxTopOfStack = (portSTACK_TYPE)((portLONG)(pvParameters)>>16);\r
- pxTopOfStack--; \r
-#endif\r
+ #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
+ {\r
+ *pxTopOfStack = ( portSTACK_TYPE ) ( ( unsigned portLONG ) ( pvParameters ) >> 16 );\r
+ pxTopOfStack--; \r
+ }\r
+ #endif\r
\r
- *pxTopOfStack = (portSTACK_TYPE)(pvParameters);\r
+ *pxTopOfStack = ( portSTACK_TYPE ) ( pvParameters );\r
pxTopOfStack--; \r
\r
/* This is redundant push to the stack. This is required in order to introduce \r
an offset so that the task accesses a parameter correctly that is passed on to \r
the task stack. */\r
-#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
- *pxTopOfStack = (Get_DTB_PCB_bank() & 0xff00) |\r
- (((portLONG)(pxCode) >>16) & 0xff); \r
- pxTopOfStack--; \r
-#endif\r
+ #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
+ {\r
+ *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff ); \r
+ pxTopOfStack--; \r
+ }\r
+ #endif\r
\r
/* This is redundant push to the stack. This is required in order to introduce \r
an offset so that the task accesses a parameter correctly that is passed on to \r
the task stack. */\r
- *pxTopOfStack = ( portSTACK_TYPE )(pxCode);\r
+ *pxTopOfStack = ( portSTACK_TYPE ) ( pxCode );\r
pxTopOfStack--; \r
\r
/* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */\r
*pxTopOfStack = 0xE0C0; \r
pxTopOfStack--; \r
\r
- /* PC */\r
- *pxTopOfStack = ( portSTACK_TYPE )(pxCode); \r
+ /* PC */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) ( pxCode ); \r
pxTopOfStack--; \r
\r
- /* DTB | PCB */\r
-#if MEMMODEL == SMALL || MEMMODEL == COMPACT\r
- *pxTopOfStack = Get_DTB_PCB_bank(); \r
- pxTopOfStack--;\r
-#endif\r
+ /* DTB | PCB */\r
+ #if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT\r
+ {\r
+ *pxTopOfStack = xGet_DTB_PCB_bank(); \r
+ pxTopOfStack--;\r
+ }\r
+ #endif\r
\r
- /* DTB | PCB, in case of MEDIUM or LARGE memory model PCB would be used\r
+ /* DTB | PCB, in case of portMEDIUM or portLARGE memory model PCB would be used\r
along with PC to indicate the start address of the functiom */\r
-#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
- *pxTopOfStack = (Get_DTB_PCB_bank() & 0xff00) |\r
- (((portLONG)(pxCode) >>16) & 0xff); \r
- pxTopOfStack--; \r
-#endif\r
+ #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
+ {\r
+ *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );\r
+ pxTopOfStack--; \r
+ }\r
+ #endif\r
\r
- /* DPR | ADB */\r
- *pxTopOfStack = Get_DPR_ADB_bank(); \r
+ /* DPR | ADB */\r
+ *pxTopOfStack = xGet_DPR_ADB_bank(); \r
pxTopOfStack--;\r
\r
- /* AL */\r
+ /* AL */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x9999; \r
pxTopOfStack--;\r
\r
- /* AH */\r
+ /* AH */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0xAAAA; \r
pxTopOfStack--;\r
\r
- /* Next the general purpose registers. */\r
+ /* Next the general purpose registers. */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x7777; /* RW7 */\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x6666; /* RW6 */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111; /* RW1 */\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x8888; /* RW0 */\r
+ pxTopOfStack--;\r
+\r
+ /* The task starts with its uxCriticalNesting variable set to 0, interrupts\r
+ being enabled. */\r
+ *pxTopOfStack = portNO_CRITICAL_NESTING;\r
\r
return pxTopOfStack;\r
}\r
/*-----------------------------------------------------------*/\r
-/*\r
- * Setup RLT0 to generate a tick interrupt.\r
- */\r
+\r
static void prvSetupRLT0Interrupt( void )\r
{\r
/* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
TMCSR0 = 0x041B; \r
}\r
/*-----------------------------------------------------------*/\r
-/*\r
- * Start the scheduler.\r
- */\r
+\r
portBASE_TYPE xPortStartScheduler( void )\r
{\r
/* Setup the hardware to generate the tick. */\r
\r
void vPortEndScheduler( void )\r
{\r
- /* It is unlikely that the AVR port will get stopped. If required simply\r
- disable the tick interrupt here. */\r
+ /* Not implemented - unlikely to ever be required as there is nothing to\r
+ return to. */\r
}\r
\r
/*-----------------------------------------------------------*/\r
\r
vTaskIncrementTick();\r
}\r
+\r
#endif\r
\r
/*-----------------------------------------------------------*/\r
/* Restore the context of the new task. */\r
portRESTORE_CONTEXT();\r
}\r
+/*-----------------------------------------------------------*/\r
\r
__nosavereg __interrupt void vPortYieldDelayed( void )\r
{ \r
/* Enable interrupts */\r
__EI();\r
} \r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEnterCritical( void )\r
+{\r
+ /* Disable interrupts */\r
+ portDISABLE_INTERRUPTS();\r
+\r
+ /* Now interrupts are disabled uxCriticalNesting can be accessed\r
+ directly. Increment uxCriticalNesting to keep a count of how many times\r
+ portENTER_CRITICAL() has been called. */\r
+ uxCriticalNesting++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortExitCritical( void )\r
+{\r
+ if( uxCriticalNesting > portNO_CRITICAL_NESTING )\r
+ {\r
+ uxCriticalNesting--;\r
+ if( uxCriticalNesting == portNO_CRITICAL_NESTING )\r
+ {\r
+ /* Enable all interrupt/exception. */\r
+ portENABLE_INTERRUPTS();\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r