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

📄 artx_config.lst

📁 can bus 源代码
💻 LST
📖 第 1 页 / 共 4 页
字号:
ARM COMPILER V2.32a,  ARTX_Config                                                          15/03/07  08:58:24  PAGE 1   


ARM COMPILER V2.32a, 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 OPTIMIZE(7,SPEED) DEBUG CODE PRINT(.\LST\ARTX_CONFIG.LST
                    -) TABS(3) 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     6
   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.
ARM COMPILER V2.32a,  ARTX_Config                                                          15/03/07  08:58:24  PAGE 2   

   59          //   <i> Default: 0  (User timers disabled)
   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       0
   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        10000
   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       1
   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          */
  112            #define OS_TID_       4                               /*  Timer ID        */
  113            #define OS_TIM_       (1 << OS_TID_)                  /*  Interrupt Mask  */
  114            #define OS_TRV        ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
  115            #define OS_TVAL       T0TC                            /*  Timer Value     */
  116            #define OS_TOVF       (T0IR & 1)                      /*  Overflow Flag   */
  117            #define OS_TREL()     ;                               /*  Timer Reload    */
  118            #define OS_TFIRQ()    VICSoftInt   |= OS_TIM_;        /*  Force Interrupt */
  119            #define OS_TIACK()    T0IR = 1;                       /*  Interrupt Ack   */ \
  120                                  VICSoftIntClr = OS_TIM_;                               \
  121                                  VICVectAddr   = 0;
  122            #define OS_TINIT()    T0MR0 = OS_TRV;                 /*  Initialization  */ \
  123                                  T0MCR = 3;                                             \
  124                                  T0TCR = 1;                                             \
ARM COMPILER V2.32a,  ARTX_Config                                                          15/03/07  08:58:24  PAGE 3   

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

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

  257   1              SUB     R0,R0,#0x4                  ; Write back problem !!
  258   1              STMDB   R0!,{R2-R12}                ; Push R12-R2
  259   1              LDMIA   SP!,{R2-R3}
  260   1              STMDB   R0!,{R2-R3}                 ; Push R1-R0
  261   1      
  262   1              LDR     R1,=os_runtask              ; os_runtask
  263   1              LDR     R1,[R1,#0x0]                ; os_runtask
  264   1              STR     R0,[R1,#TCB_TSTACK]         ; os_runtask->tsk_stack
  265   1         }
  266   1         OS_TIACK();
  267   1         tsk_lock ();
  268   1         os_runtask->full_ctx = __TRUE;
  269   1         os_runtask->state  = READY;
  270   1         os_put_rdy_first (os_runtask);
  271   1         os_runtask = &os_clock_TCB;
  272   1         os_clock_TCB.state = RUNNING;
  273   1         __asm {
  274   1              LDR     R0,=os_runtask              ; os_runtask
  275   1              LDR     R0,[R0,#0x0]                ; os_runtask
  276   1              LDR     R0,[R0,#TCB_TSTACK]         ; os_runtask->tsk_stack
  277   1      
  278   1              LDMIA   R0!,{R4-R8,R12}
  279   1              MSR     SPSR_cxsf,R8
  280   1              STMDB   SP,{R0}                     ; Set User SP
  281   1              LDMDB   SP,{SP}^
  282   1              MOVS    PC,R12                      ; RETI
  283   1         }
  284   1      } /* end of os_clock_interrupt */
  285          
  286          /*--------------------------- os_def_interrupt ------------------------------*/
  287          
  288          void os_def_interrupt (void) __irq  {
  289   1         /* Default Interrupt Function: may be called when timer ISR is disabled */
  290   1      }
  291          
  292          /*--------------------------- os_tmr_init -----------------------------------*/
  293          
  294          void os_tmr_init (void) {
  295   1         /* Initialize hardware timer as system tick timer. This function is     */
  296   1         /* called at the system startup.                                        */
  297   1         OS_TINIT();
  298   1      #if (OS_ROBIN == 1)
  299   1         os_robin_time = OS_ROBINTOUT;
  300   1      #endif
  301   1      } /* end of os_tmr_init */
  302          
  303          /*--------------------------- os_tmr_reload ---------------------------------*/
  304          
  305          void os_tmr_reload (void) {
  306   1         /* Reload system timer for next period if a timer requires reload.        */
  307   1         OS_TREL();
  308   1      } /* end of os_tmr_reload */
  309          
  310          /*--------------------------- os_tmr_force_irq ------------------------------*/
  311          

⌨️ 快捷键说明

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