CooCox 1.1.4 on mbed with simple blinky example

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arch.c Source File

arch.c

Go to the documentation of this file.
00001 /**
00002  *******************************************************************************
00003  * @file      arch.c
00004  * @version    V1.1.4    
00005  * @date       2011.04.20
00006  * @brief     This file provides InitTaskContext() and SysTick_Handler().
00007  *******************************************************************************
00008  * @copy
00009  *    WRITE COPY INFORMATION USE CAPITAL LETTER
00010  *
00011  * <h2><center>&copy; COPYRIGHT 2009 CooCox </center></h2>
00012  *******************************************************************************
00013  */  
00014 
00015 /*---------------------------- Include ---------------------------------------*/
00016 #include <coocox.h>
00017 U64     OSTickCnt  = 0;                  /*!< Current system tick counter      */                                                                              
00018 
00019 /**
00020  ******************************************************************************
00021  * @brief      Initial task context      
00022  * @param[in]  task    Entry point of task.
00023  * @param[in]  param   The parameter pass to task.    
00024  * @param[in]  pstk    The pointer to stack top.     
00025  * @param[out] None  
00026  * @retval     Returns location of new stack top.         
00027  *
00028  * @par Description
00029  * @details    This function is called to initialize the stack frame of the 
00030  *             task being created.
00031  ******************************************************************************
00032  */
00033 OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk)
00034 {
00035     OS_STK *context;
00036     context  = pstk;
00037     *(context--) = (U32)0x01000000L;      /* xPSR            */
00038     *(context--) = (U32)task;             /* Entry point of task.                         */
00039     *(context)   = (U32)0xFFFFFFFEL;
00040     context      = context - 5;
00041     *(context)   = (U32)param;            /* R0: argument */
00042     context      = context - 8;
00043       
00044     return (context);                   /* Returns location of new stack top. */
00045 }
00046 
00047 
00048  
00049 /**
00050  *******************************************************************************
00051  * @brief      System tick interrupt handler.             
00052  * @param[in]  None     
00053  * @param[out] None       
00054  * @retval     None
00055  *         
00056  * @par Description
00057  * @details    This is system tick interrupt headler.         
00058  * @note       CoOS may schedule when exiting this ISR. 
00059  *******************************************************************************
00060  */ 
00061 extern "C" void SysTick_Handler(void)
00062 {
00063     OSSchedLock ++;                  /* Lock scheduler.                        */
00064     OSTickCnt ++;                    /* Increment systerm time.                */
00065 #if CFG_TASK_WAITTING_EN >0    
00066     if(DlyList  != Co_NULL)             /* Have task in delay list?               */
00067     {
00068         if(DlyList ->delayTick  > 1)  /* Delay time > 1?                        */
00069         {
00070             DlyList ->delayTick --;   /* Decrease delay time of the list head.  */         
00071         }
00072         else
00073         {
00074             DlyList ->delayTick  = 0;
00075             isr_TimeDispose();       /* Call hander for delay time list        */
00076         }
00077     }
00078 #endif
00079     
00080 #if CFG_TMR_EN > 0    
00081     if(TmrList  != Co_NULL)             /* Have timer in working?                 */
00082     {
00083         if(TmrList ->tmrCnt  > 1)     /* Timer time > 1?                        */
00084         {
00085             TmrList ->tmrCnt --;      /* Decrease timer time of the list head.  */        
00086         }
00087         else
00088         {
00089             TmrList ->tmrCnt  = 0;
00090             isr_TmrDispose();         /* Call hander for timer list             */
00091         }
00092     }    
00093 #endif
00094     TaskSchedReq = Co_TRUE;
00095     OsSchedUnlock();
00096 }