⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 artx_config.lst

📁 LPC2142用演示ARTX的LED显示例程及KEY按键处理的演示程序.
💻 LST
📖 第 1 页 / 共 4 页
字号:
ARM COMPILER V2.42,  ARTX_Config                                                           17/01/06  16:24:22  PAGE 1   


ARM COMPILER V2.42, COMPILATION OF MODULE ARTX_Config
OBJECT MODULE PLACED IN .\OBJ\ARTX_Config.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe ARTX_Config.c THUMB BROWSE DEBUG TABS(4) OBJECT(.\OBJ\ARTX_Config.obj) 

stmt  level    source

    1          /*----------------------------------------------------------------------------
    2           *      A R T X  -  K e r n e l
    3           *----------------------------------------------------------------------------
    4           *      Name:    ARTX_CONFIG.C
    5           *      Purpose: Configuration of ARTX Kernel for Philips LPC21xx
    6           *      Rev.:    V2.00 / 19-oct-2005
    7           *----------------------------------------------------------------------------
    8           *      This code is part of the ARTX-ARM kernel package of Keil Software.
    9           *      Copyright (c) 2004-2005 Keil Software. All rights reserved. 
   10           *---------------------------------------------------------------------------*/
   11          
   12          #pragma INTERWORK
   13          #define NOFRAME    __arm __task
   14          
   15          #include <LPC21xx.H>                     /* LPC21xx definitions              */
   16          #include <ARTX_Config.h>                 /* ARTX user configuration header   */
   17          
   18          /*----------------------------------------------------------------------------
   19           *      ARTX User configuration part BEGIN
   20           *---------------------------------------------------------------------------*/
   21          
   22          //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
   23          //
   24          // <h>Task Definitions
   25          // ===================
   26          //
   27          //   <o>Number of concurrent running tasks <0-250>
   28          //   <i> Define max. number of tasks that will run at the same time.
   29          //   <i> Default: 6
   30          #ifndef OS_TASKCNT
   31           #define OS_TASKCNT     4
   32          #endif
   33          
   34          //   <o>Number of tasks with user-provided stack <0-250>
   35          //   <i> Define the number of tasks that will use a bigger stack.
   36          //   <i> The memory space for the stack is provided by the user.
   37          //   <i> Default: 0
   38          #ifndef OS_PRIVCNT
   39           #define OS_PRIVCNT     0
   40          #endif
   41          
   42          //   <o>Task stack size [bytes] <20-4096:4><#/4>
   43          //   <i> Set the stack size for tasks which is assigned by the system.
   44          //   <i> Default: 200
   45          #ifndef OS_STKSIZE
   46           #define OS_STKSIZE     50
   47          #endif
   48          
   49          // <q>Check for the stack overflow
   50          // ===============================
   51          // <i> Include the stack checking code for a stack overflow.
   52          // <i> Note that additional code reduces the Kernel performance.
   53          #ifndef OS_STKCHECK
   54           #define OS_STKCHECK    1
   55          #endif
   56          
   57          //   <o>Number of user timers <0-250>
   58          //   <i> Define max. number of user timers that will run at the same time.
   59          //   <i> Default: 0  (User timers disabled)
ARM COMPILER V2.42,  ARTX_Config                                                           17/01/06  16:24:22  PAGE 2   

   60          #ifndef OS_TIMERCNT
   61           #define OS_TIMERCNT    0
   62          #endif
   63          
   64          // </h>
   65          // <h>System Timer Configuration
   66          // =============================
   67          //   <o>ARTX Kernel timer number <0=> Timer 0 <1=> Timer 1
   68          //   <i> Define the ARM timer used as a system tick timer.
   69          //   <i> Default: Timer 0
   70          #ifndef OS_TIMER
   71           #define OS_TIMER       1
   72          #endif
   73          
   74          //   <o>Timer clock value [Hz] <1-1000000000>
   75          //   <i> Set the timer clock value for selected timer.
   76          //   <i> Default: 15000000  (15MHz at 60MHz CCLK and VPBDIV = 4)
   77          #ifndef OS_CLOCK
   78           #define OS_CLOCK       60000000
   79          #endif
   80          
   81          //   <o>Timer tick value [us] <1-1000000>
   82          //   <i> Set the timer tick value for selected timer.
   83          //   <i> Default: 10000  (10ms)
   84          #ifndef OS_TICK
   85           #define OS_TICK        2000
   86          #endif
   87          
   88          // </h>
   89          // <e>Round-Robin Task switching
   90          // =============================
   91          // <i> Enable Round-Robin Task switching.
   92          #ifndef OS_ROBIN
   93           #define OS_ROBIN       0
   94          #endif
   95          
   96          //   <o>Round-Robin Timeout [ticks] <1-1000>
   97          //   <i> Define how long a task will execute before a task switch.
   98          //   <i> Default: 5
   99          #ifndef OS_ROBINTOUT
  100           #define OS_ROBINTOUT   5
  101          #endif
  102          
  103          // </e>
  104          
  105          //------------- <<< end of configuration section >>> -----------------------
  106          
  107          /*----------------------------------------------------------------------------
  108           *      ARTX User configuration part END
  109           *---------------------------------------------------------------------------*/
  110          
  111          #if   (OS_TIMER == 0)                                   /* Timer 0          */
                 #define OS_TID_       4                               /*  Timer ID        */
                 #define OS_TIM_       (1 << OS_TID_)                  /*  Interrupt Mask  */
                 #define OS_TRV        ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
                 #define OS_TVAL       T0TC                            /*  Timer Value     */
                 #define OS_TOVF       (T0IR & 1)                      /*  Overflow Flag   */
                 #define OS_TREL()     ;                               /*  Timer Reload    */
                 #define OS_TFIRQ()    VICSoftInt   |= OS_TIM_;        /*  Force Interrupt */
                 #define OS_TIACK()    T0IR = 1;                       /*  Interrupt Ack   */ \
                                       VICSoftIntClr = OS_TIM_;                               \
                                       VICVectAddr   = 0;
                 #define OS_TINIT()    T0MR0 = OS_TRV;                 /*  Initialization  */ \
                                       T0MCR = 3;                                             \
                                       T0TCR = 1;                                             \
                                       VICDefVectAddr = (U32)os_def_interrupt;                \
ARM COMPILER V2.42,  ARTX_Config                                                           17/01/06  16:24:22  PAGE 3   

                                       VICVectAddr15  = (U32)os_clock_interrupt;              \
                                       VICVectCntl15  = 0x20 | OS_TID_;
               #elif (OS_TIMER == 1)                                   /* Timer 1          */
  129            #define OS_TID_       5                               /*  Timer ID        */
  130            #define OS_TIM_       (1 << OS_TID_)                  /*  Interrupt Mask  */
  131            #define OS_TRV        ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
  132            #define OS_TVAL       T1TC                            /*  Timer Value     */
  133            #define OS_TOVF       (T1IR & 1)                      /*  Overflow Flag   */
  134            #define OS_TREL()     ;                               /*  Timer Reload    */
  135            #define OS_TFIRQ()    VICSoftInt   |= OS_TIM_;        /*  Force Interrupt */
  136            #define OS_TIACK()    T1IR = 1;                       /*  Interrupt Ack   */ \
  137                                  VICSoftIntClr = OS_TIM_;                               \
  138                                  VICVectAddr   = 0;
  139            #define OS_TINIT()    T1MR0 = OS_TRV;                 /*  Initialization  */ \
  140                                  T1MCR = 3;                                             \
  141                                  T1TCR = 1;                                             \
  142                                  VICDefVectAddr = (U32)os_def_interrupt;                \
  143                                  VICVectAddr15  = (U32)os_clock_interrupt;              \
  144                                  VICVectCntl15  = 0x20 | OS_TID_;
  145          #else
                 #error OS_TIMER invalid
               #endif
  148          
  149          #define OS_IACK()       VICVectAddr   = 0;              /* Interrupt Ack    */
  150          
  151          #define OS_LOCK()       VICIntEnClr   = OS_TIM_;        /* Task Lock        */
  152          #define OS_UNLOCK()     VICIntEnable |= OS_TIM_;        /* Task Unlock      */
  153          
  154          /* WARNING ! Do not use IDLE mode if you are using a JTAG interface  */
  155          /*           for debugging your application.                         */
  156          #define _idle_()        PCON = 1;
  157          #define INITIAL_CPSR    0x40000010
  158          #define MAGIC_WORD      0xE25A2EA5
  159          
  160          /*----------------------------------------------------------------------------
  161           *      Global Variables
  162           *---------------------------------------------------------------------------*/
  163          
  164          extern P_TCB os_runtask;
  165          extern struct OS_XCB os_rdy;
  166          extern struct OS_TCB os_clock_TCB;
  167          extern U16 os_time;
  168          U16 const os_maxtaskrun = OS_TASKCNT;
  169          /* Export following defines to uVision debugger. */
  170          U32 const os_stackinfo = (OS_STKCHECK<<24) | (OS_PRIVCNT<<16) | (OS_STKSIZE*4);
  171          U32 const os_clockrate  = OS_TICK;
  172          U32 const os_timernum   = (OS_TIMER << 16) | OS_TIMERCNT;
  173          U32 const os_rrobin     = (OS_ROBIN << 16) | OS_ROBINTOUT;
  174          
  175          /*----------------------------------------------------------------------------
  176           *      Local Variables
  177           *---------------------------------------------------------------------------*/
  178          /* Memory pool for TCB allocation    */
  179          static U32 m_tcb[(sizeof(struct OS_TCB) * OS_TASKCNT)/4 + 3];
  180          
  181          /* Memory pool for System stack allocation. Need to allocate 2 additional  */
  182          /* entries for 'os_clock_demon()' and 'os_idle_demon()'.                   */
  183          static U32 m_stk[OS_STKSIZE * (OS_TASKCNT-OS_PRIVCNT+2) + 3];
  184          
  185          /* An array of Active task pointers.                                       */
  186          P_TCB os_active_TCB[OS_TASKCNT];
  187          
  188          #if (OS_ROBIN == 1)
                 static U16  os_robin_time;
                 static P_TCB os_tsk_robin;
               #endif
ARM COMPILER V2.42,  ARTX_Config                                                           17/01/06  16:24:22  PAGE 4   

  192          
  193          #if (OS_TIMERCNT != 0)
                 /* Memory pool for User Timer allocation                                 */
                 static U32 m_tmr[(sizeof(struct OS_TMR) * OS_TIMERCNT)/4 + 3];
               #endif
  197          
  198          #if (OS_STKCHECK == 1)
  199            static BIT os_del_flag;
  200          #endif
  201          
  202          /*----------------------------------------------------------------------------
  203           *      Global Functions
  204           *---------------------------------------------------------------------------*/
  205          
  206          /*--------------------------- os_idle_demon ---------------------------------*/
  207          
  208          void os_idle_demon (void) __task {
  209   1         /* The idle demon is a system task. It is running when no other task is   */
  210   1         /* ready to run (idle situation). It must not terminate. Therefore it     */
  211   1         /* should contain at least an endless loop.                               */
  212   1      
  213   1         for (;;) {
  214   2         /* HERE: include here optional user code to be executed when no task runs.*/
  215   2         }
  216   1      } /* end of os_idle_demon */
  217          
  218          
  219          /*--------------------------- os_tmr_call -----------------------------------*/
  220          
  221          void os_tmr_call (U16 info) {
  222   1         /* This function is called when the user timer has expired.               */
  223   1         /* Parameter "info" is the parameter defined when the timer was created.  */
  224   1         /* HERE: include here optional user code to be executed on timeout.       */
  225   1         info = info;
  226   1      } /* end of os_tmr_call */
  227          
  228          /*--------------------------- os_stk_overflow -------------------------------*/
  229          
  230          #if (OS_STKCHECK == 1)
  231          static void os_stk_overflow (void) {
  232   1         /* This function is called when a stack overflow is detected.             */
  233   1         /*  'os_runtask' points to a TCB of a task which has a stack overflow     */
  234   1         /*  'task_id'    holds a task id for this task                            */
  235   1         /* HERE: include here optional code to be executed on stack overflow.     */
  236   1         static OS_TID task_id;
  237   1      
  238   1         /* Get a task identification for a task with stack problem to 'task_id'.*/
  239   1         task_id = os_get_TID (os_runtask);
  240   1         /* Use a uVision 'Advanced RTX' debug dialog page 'Active Tasks' to    */
  241   1         /* check which task has got a stack overflow and needs a bigger stack. */
  242   1         for (;;);
  243   1      }
  244          #endif
  245          
  246          /*--------------------------- os_clock_interrupt ----------------------------*/
  247          
  248          void os_clock_interrupt (void) NOFRAME {
  249   1         /* Do task switch to clock demon: entered upon a clock interrupt. */
  250   1         __asm {
  251   1              STMDB   SP!,{R0-R1}                 ; Save Full Context
  252   1              STMDB   SP,{SP}^                    ; User SP
  253   1              LDMDB   SP,{R0}
  254   1              MRS     R1,SPSR                     ; User CPSR
  255   1              SUB     LR,LR,#0x4
  256   1              STMDB   R0!,{R1,LR}                 ; Push PC, CPSR
  257   1              STMDB   R0,{LR}^                    ; Push User LR
ARM COMPILER V2.42,  ARTX_Config                                                           17/01/06  16:24:22  PAGE 5   

  258   1              SUB     R0,R0,#0x4                  ; Write back problem !!
  259   1              STMDB   R0!,{R2-R12}                ; Push R12-R2
  260   1              LDMIA   SP!,{R2-R3}
  261   1              STMDB   R0!,{R2-R3}                 ; Push R1-R0
  262   1      
  263   1              LDR     R1,=os_runtask              ; os_runtask
  264   1              LDR     R1,[R1,#0x0]                ; os_runtask
  265   1              STR     R0,[R1,#TCB_TSTACK]         ; os_runtask->tsk_stack
  266   1         }
  267   1         OS_TIACK();
  268   1         tsk_lock ();
  269   1         os_runtask->full_ctx = __TRUE;
  270   1         os_runtask->state  = READY;
  271   1         os_put_rdy_first (os_runtask);
  272   1         os_runtask = &os_clock_TCB;
  273   1         os_clock_TCB.state = RUNNING;
  274   1         __asm {
  275   1              LDR     R0,=os_runtask              ; os_runtask
  276   1              LDR     R0,[R0,#0x0]                ; os_runtask
  277   1              LDR     R0,[R0,#TCB_TSTACK]         ; os_runtask->tsk_stack
  278   1      
  279   1              LDMIA   R0!,{R4-R8,R12}
  280   1              MSR     SPSR_cxsf,R8
  281   1              STMDB   SP,{R0}                     ; Set User SP
  282   1              LDMDB   SP,{SP}^
  283   1              MOVS    PC,R12                      ; RETI
  284   1         }
  285   1      } /* end of os_clock_interrupt */
  286          
  287          /*--------------------------- os_def_interrupt ------------------------------*/
  288          
  289          void os_def_interrupt (void) __irq  {
  290   1         /* Default Interrupt Function: may be called when timer ISR is disabled */
  291   1         OS_IACK();
  292   1      }
  293          
  294          /*--------------------------- os_tmr_init -----------------------------------*/
  295          
  296          void os_tmr_init (void) {
  297   1         /* Initialize hardware timer as system tick timer. This function is     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -