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

📄 artx_conf_sam7s.lst

📁 Keil UV3中自带操作系统ARTX的应用例程
💻 LST
📖 第 1 页 / 共 4 页
字号:
ARM COMPILER V2.42,  ARTX_Conf_SAM7S                                                       20/02/06  16:27:40  PAGE 1   


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

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 Atmel AT91SAM7S
    6           *      Rev.:    V2.01 / 20-jan-2006
    7           *----------------------------------------------------------------------------
    8           *      This code is part of the ARTX-ARM kernel package of Keil Software.
    9           *      Copyright (c) 2004-2006 Keil Software. All rights reserved. 
   10           *---------------------------------------------------------------------------*/
   11          
   12          #pragma INTERWORK
   13          #define NOFRAME    __arm __task
   14          
   15          #include <AT91SAM7S64.H>
   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.
   59          //   <i> Default: 0  (User timers disabled)
ARM COMPILER V2.42,  ARTX_Conf_SAM7S                                                       20/02/06  16:27:40  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 <0=> PIT
   68          //   <i> Define the ARM timer used as a system tick timer.
   69          //   <i> Default: PIT
   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: 3000000  (3MHz at 48MHz MCLK and prescaler by 16)
   77          #ifndef OS_CLOCK
   78           #define OS_CLOCK       3000000
   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)                                   /* PIT              */
  112            #define OS_TIM_       (1 << AT91C_ID_SYS)             /*  Interrupt Mask  */
  113            #define OS_TRV        ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
  114            #define OS_TVAL       (*AT91C_PITC_PIIR & 0x000FFFFF) /*  Timer Value     */
  115            #define OS_TOVF       (*AT91C_PITC_PISR & 1)          /*  Overflow Flag   */
  116            #define OS_TREL()     ;                               /*  Timer Reload    */
  117            #define OS_TFIRQ()    *AT91C_AIC_ISCR  = OS_TIM_;     /*  Force Interrupt */
  118            #define OS_TIACK()    *AT91C_AIC_EOICR = *AT91C_PITC_PIVR;                   \
  119                                  *AT91C_AIC_ICCR  = OS_TIM_;     /*  Interrupt Ack   */
  120            #define OS_TINIT()    *AT91C_PITC_PIMR = OS_TRV |     /*  Initialization  */ \
  121                                    AT91C_PITC_PITIEN | AT91C_PITC_PITEN;                \
  122                                  *(AT91C_AIC_SPU) = (U32)os_def_interrupt;              \
  123                                  *(AT91C_AIC_SVR + AT91C_ID_SYS) =                      \
  124                                    (U32)os_clock_interrupt;                             \
  125                                  *(AT91C_AIC_SMR + AT91C_ID_SYS) =                      \
ARM COMPILER V2.42,  ARTX_Conf_SAM7S                                                       20/02/06  16:27:40  PAGE 3   

  126                                    AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED | 0;            \
  127                                  *(AT91C_AIC_IECR) = OS_TIM_;
  128          #else
                 #error OS_TIMER invalid
               #endif
  131          
  132          #define OS_IACK()       *AT91C_AIC_EOICR = 0;           /* Interrupt Ack    */
  133          
  134          #define OS_LOCK()       *AT91C_AIC_IDCR = OS_TIM_;      /* Lock             */
  135          #define OS_UNLOCK()     *AT91C_AIC_IECR = OS_TIM_;      /* Unlock           */
  136          
  137          /* WARNING ! Do not use IDLE mode if you are using a JTAG interface  */
  138          /*           for debugging your application.                         */
  139          #define _idle_()        *AT91C_PMC_SCDR = 1;
  140          #define INITIAL_CPSR    0x40000010
  141          #define MAGIC_WORD      0xE25A2EA5
  142          
  143          /*----------------------------------------------------------------------------
  144           *      Global Variables
  145           *---------------------------------------------------------------------------*/
  146          
  147          extern P_TCB os_runtask;
  148          extern struct OS_XCB os_rdy;
  149          extern struct OS_TCB os_clock_TCB;
  150          extern U16 os_time;
  151          U16 const os_maxtaskrun = OS_TASKCNT;
  152          /* Export following defines to uVision debugger. */
  153          U32 const os_stackinfo = (OS_STKCHECK<<24) | (OS_PRIVCNT<<16) | (OS_STKSIZE*4);
  154          U32 const os_clockrate  = OS_TICK;
  155          U32 const os_timernum   = (OS_TIMER << 16) | OS_TIMERCNT;
  156          U32 const os_rrobin     = (OS_ROBIN << 16) | OS_ROBINTOUT;
  157          
  158          /*----------------------------------------------------------------------------
  159           *      Local Variables
  160           *---------------------------------------------------------------------------*/
  161          /* Memory pool for TCB allocation    */
  162          static U32 m_tcb[(sizeof(struct OS_TCB) * OS_TASKCNT)/4 + 3];
  163          
  164          /* Memory pool for System stack allocation. Need to allocate 2 additional  */
  165          /* entries for 'os_clock_demon()' and 'os_idle_demon()'.                   */
  166          static U32 m_stk[OS_STKSIZE * (OS_TASKCNT-OS_PRIVCNT+2) + 3];
  167          
  168          /* An array of Active task pointers.                                       */
  169          P_TCB os_active_TCB[OS_TASKCNT];
  170          
  171          #if (OS_ROBIN == 1)
  172            static U16  os_robin_time;
  173            static P_TCB os_tsk_robin;
  174          #endif
  175          
  176          #if (OS_TIMERCNT != 0)
                 /* Memory pool for User Timer allocation                                 */
                 static U32 m_tmr[(sizeof(struct OS_TMR) * OS_TIMERCNT)/4 + 3];
               #endif
  180          
  181          #if (OS_STKCHECK == 1)
  182            static BIT os_del_flag;
  183          #endif
  184          
  185          /*----------------------------------------------------------------------------
  186           *      Global Functions
  187           *---------------------------------------------------------------------------*/
  188          
  189          /*--------------------------- os_idle_demon ---------------------------------*/
  190          
  191          void os_idle_demon (void) __task {
ARM COMPILER V2.42,  ARTX_Conf_SAM7S                                                       20/02/06  16:27:40  PAGE 4   

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

  258   1              LDR     R0,=os_runtask              ; os_runtask
  259   1              LDR     R0,[R0,#0x0]                ; os_runtask
  260   1              LDR     R0,[R0,#TCB_TSTACK]         ; os_runtask->tsk_stack
  261   1      
  262   1              LDMIA   R0!,{R4-R8,R12}
  263   1              MSR     SPSR_cxsf,R8
  264   1              STMDB   SP,{R0}                     ; Set User SP
  265   1              LDMDB   SP,{SP}^
  266   1              MOVS    PC,R12                      ; RETI
  267   1         }
  268   1      } /* end of os_clock_interrupt */
  269          
  270          /*--------------------------- os_def_interrupt ------------------------------*/
  271          
  272          void os_def_interrupt (void) __irq  {
  273   1         /* Default Interrupt Function: may be called when timer ISR is disabled */
  274   1         OS_IACK();
  275   1      }
  276          
  277          /*--------------------------- os_tmr_init -----------------------------------*/
  278          
  279          void os_tmr_init (void) {
  280   1         /* Initialize hardware timer as system tick timer. This function is     */
  281   1         /* called at the system startup.                                        */
  282   1         OS_TINIT();
  283   1      #if (OS_ROBIN == 1)
  284   1         os_robin_time = OS_ROBINTOUT;
  285   1      #endif
  286   1      } /* end of os_tmr_init */
  287          
  288          /*--------------------------- os_tmr_reload ---------------------------------*/
  289          
  290          void os_tmr_reload (void) {
  291   1         /* Reload system timer for next period if a timer requires reload.        */
  292   1         OS_TREL();
  293   1      } /* end of os_tmr_reload */
  294          
  295          /*--------------------------- os_tmr_force_irq ------------------------------*/
  296          
  297          void os_tmr_force_irq (void) {
  298   1         /* Force a timer interrupt.                                               */
  299   1         OS_TFIRQ();
  300   1      } /* end of os_tmr_force_irq */
  301          
  302          /*--------------------------- os_tmr_inspect_cnt ----------------------------*/
  303          
  304          U32 os_tmr_inspect_cnt (void) {
  305   1         /* Inspect current value of rtx timer.                                    */
  306   1         return (OS_TVAL);
  307   1      } /* end of os_tmr_inspect_cnt */
  308          
  309          /*--------------------------- os_tmr_inspect_ovf ----------------------------*/
  310          

⌨️ 快捷键说明

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