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

📄 os_cpu_a.txt

📁 ucos在所有cpu下的移植范例
💻 TXT
📖 第 1 页 / 共 2 页
字号:
   1                     ;********************************************************************************************************
   2                     ;                                               uC/OS-II
   3                     ;                                         The Real-Time Kernel
   4                     ;
   5                     ;                         (c) Copyright 1998, Jean J. Labrosse, Plantation, FL
   6                     ;                                          All Rights Reserved
   7                     ;
   8                     ;
   9                     ;                                          68HC12 Specific code
  10                     ;                                            (COSMIC C V4.2F)
  11                     ;
  12                     ; File         : OS_CPU_A.S
  13                     ; By           : Jean J. Labrosse
  14                     ; Port Version : V1.01
  15                     ;********************************************************************************************************
  16                     
  17                     ;********************************************************************************************************
  18                     ;                                         CONFIGURATION CONSTANTS
  19                     ;********************************************************************************************************
  20                     
  21       00000007      OS_TICK_OC:       equ        7         ; We will use Output Compare #7 to generate tick interrupts
  22       00001388      OS_TICK_OC_CNTS:  equ     5000         ; 100 Hz tick rate (assumes Free Running Timer runs at 500 KHz)
  23                                                            ;        OS_TICK_OC_CNTS = CPU_FRT_FREQ / OS_TICKS_PER_SEC
  24                     
  25                     ;********************************************************************************************************
  26                     ;                                           I/O PORT ADDRESSES
  27                     ;********************************************************************************************************
  28                     
  29       0000008e      TFLG1:            equ    $008E         ; I/O port addresses.  Assumes all 68HC12 I/Os start at 0x0000
  30       00000090      TC0:              equ    $0090
  31       00000092      TC1:              equ    $0092
  32       00000094      TC2:              equ    $0094
  33       00000096      TC3:              equ    $0096
  34       00000098      TC4:              equ    $0098
  35       0000009a      TC5:              equ    $009A
  36       0000009c      TC6:              equ    $009C
  37       0000009e      TC7:              equ    $009E
  38                     
  39                     ;********************************************************************************************************
  40                     ;                                          PUBLIC DECLARATIONS
  41                     ;********************************************************************************************************
  42                        
  43                         xdef   _OSStartHighRdy
  44                         xdef   _OSCtxSw
  45                         xdef   _OSIntCtxSw
  46                         xdef   _OSTickISR
  47                         
  48                     ;********************************************************************************************************
  49                     ;                                         EXTERNAL DECLARATIONS
  50                     ;********************************************************************************************************
  51                        
  52                         xref   _OSIntExit
  53                         xref   _OSIntNesting  
  54                         xref   _OSPrioCur    
  55                         xref   _OSPrioHighRdy
  56                         xref   _OSRunning   
  57                         xref   _OSTaskSwHook 
  58                         xref   _OSTCBCur     
  59                         xref   _OSTCBHighRdy 
  60                         xref   _OSTimeTick
  61                     
  62                     ;********************************************************************************************************
  63                     ;                               START HIGHEST PRIORITY TASK READY-TO-RUN
  64                     ;
  65                     ; Description : This function is called by OSStart() to start the highest priority task that was created
  66                     ;               by your application before calling OSStart().
  67                     ;
  68                     ; Arguments   : none
  69                     ;
  70                     ; Note(s)     : 1) The stack frame is assumed to look as follows:
  71                     ;   
  72                     ;                  OSTCBHighRdy->OSTCBStkPtr +  0  -->  CCR
  73                     ;                                            +  1       B
  74                     ;                                            +  2       A
  75                     ;                                            +  3       X (H)
  76                     ;                                            +  4       X (L)
  77                     ;                                            +  5       Y (H)
  78                     ;                                            +  6       Y (L)
  79                     ;                                            +  7       PC(H)
  80                     ;                                            +  8       PC(L)
  81                     ;
  82                     ;               2) OSStartHighRdy() MUST:
  83                     ;                      a) Call OSTaskSwHook() then,
  84                     ;                      b) Set OSRunning to TRUE,
  85                     ;                      c) Switch to the highest priority task.
  86                     ;********************************************************************************************************
  87                     
  88  0000               _OSStartHighRdy:
  89  0000 160000            jsr    _OSTaskSwHook               ;  4~, Invoke user defined context switch hook            
  90  0003 720000            inc    _OSRunning                  ;  4~, Indicate that we are multitasking                  
  91                     
  92  0006 fe0000            ldx    _OSTCBHighRdy               ;  3~, Point to TCB of highest priority task ready to run 
  93  0009 ef00              lds    0,x                         ;  3~, Load SP into 68HC12                                
  94                     
  95  000b 0b                rti                                ;  8~, Run task                                           
  96                     
  97                     ;********************************************************************************************************
  98                     ;                                       TASK LEVEL CONTEXT SWITCH
  99                     ;
 100                     ; Description : This function is called when a task makes a higher priority task ready-to-run.
 101                     ;
 102                     ; Arguments   : none
 103                     ;
 104                     ; Note(s)     : 1) Upon entry, 
 105                     ;                  OSTCBCur     points to the OS_TCB of the task to suspend
 106                     ;                  OSTCBHighRdy points to the OS_TCB of the task to resume
 107                     ;
 108                     ;               2) The stack frame of the task to suspend looks as follows:
 109                     ;
 110                     ;                  SP +  0  -->  CCR
 111                     ;                     +  1       B
 112                     ;                     +  2       A
 113                     ;                     +  3       X (H)
 114                     ;                     +  4       X (L)
 115                     ;                     +  5       Y (H)
 116                     ;                     +  6       Y (L)
 117                     ;                     +  7       PC(H)
 118                     ;                     +  8       PC(L)
 119                     ;
 120                     ;               3) The stack frame of the task to resume looks as follows:
 121                     ; 
 122                     ;                  OSTCBHighRdy->OSTCBStkPtr +  0  -->  CCR

⌨️ 快捷键说明

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