uC/OS - III 移植 IAR平台

关于移植uC/OS-III 网上已经有很多教程了此处只是做个记录

首先下载源码然后解压得到下面的文件:

uC/OS - III 移植 IAR平台

然后在模版工程里新建各种文件夹:

最后全部都添加进工程:

uC/OS - III 移植 IAR平台

OK了,编译一下,惊呆了,竟然 0错误 0 警告

然后修改下文件 startup_stm32f40xx.s

        DCD     DebugMon_Handler          ; Debug Monitor Handler

        DCD     0                         ; Reserved

        ;DCD     PendSV_Handler            ; PendSV Handler

        ;DCD     SysTick_Handler           ; SysTick Handler

        IMPORT  OS_CPU_PendSVHandler

        DCD     OS_CPU_PendSVHandler

        IMPORT  OS_CPU_SysTickHandler 

        DCD     OS_CPU_SysTickHandler

 OS_CFG.H

#ifndef OS_CFG_H

#define OS_CFG_H





                                             /* ---------------------------- MISCELLANEOUS -------------------------- */

#define OS_CFG_APP_HOOKS_EN             1u   /* Enable (1) or Disable (0) application specific hooks                  */

#define OS_CFG_ARG_CHK_EN               1u   /* Enable (1) or Disable (0) argument checking                           */

#define OS_CFG_CALLED_FROM_ISR_CHK_EN   1u   /* Enable (1) or Disable (0) check for called from ISR                   */

#define OS_CFG_DBG_EN                   1u   /* Enable (1) debug code/variables                                       */

#define OS_CFG_ISR_POST_DEFERRED_EN     0u   /* Enable (1) or Disable (0) Deferred ISR posts                          */

#define OS_CFG_OBJ_TYPE_CHK_EN          1u   /* Enable (1) or Disable (0) object type checking                        */

#define OS_CFG_TS_EN                    0u   /* Enable (1) or Disable (0) time stamping                               */



#define OS_CFG_PEND_MULTI_EN            0u   /* Enable (1) or Disable (0) code generation for multi-pend feature      */



#define OS_CFG_PRIO_MAX                64u   /* Defines the maximum number of task priorities (see OS_PRIO data type) */



#define OS_CFG_SCHED_LOCK_TIME_MEAS_EN  0u   /* Include code to measure scheduler lock time                           */

#define OS_CFG_SCHED_ROUND_ROBIN_EN     0u   /* Include code for Round-Robin scheduling                               */

#define OS_CFG_STK_SIZE_MIN            64u   /* Minimum allowable task stack size                                     */





                                             /* ----------------------------- EVENT FLAGS --------------------------- */

#define OS_CFG_FLAG_EN                  1u   /* Enable (1) or Disable (0) code generation for EVENT FLAGS             */

#define OS_CFG_FLAG_DEL_EN              1u   /*     Include code for OSFlagDel()                                      */

#define OS_CFG_FLAG_MODE_CLR_EN         1u   /*     Include code for Wait on Clear EVENT FLAGS                        */

#define OS_CFG_FLAG_PEND_ABORT_EN       1u   /*     Include code for OSFlagPendAbort()                                */





                                             /* -------------------------- MEMORY MANAGEMENT ------------------------ */

#define OS_CFG_MEM_EN                   1u   /* Enable (1) or Disable (0) code generation for MEMORY MANAGER          */





                                             /* --------------------- MUTUAL EXCLUSION SEMAPHORES ------------------- */

#define OS_CFG_MUTEX_EN                 1u   /* Enable (1) or Disable (0) code generation for MUTEX                   */

#define OS_CFG_MUTEX_DEL_EN             1u   /*     Include code for OSMutexDel()                                     */

#define OS_CFG_MUTEX_PEND_ABORT_EN      1u   /*     Include code for OSMutexPendAbort()                               */





                                             /* --------------------------- MESSAGE QUEUES -------------------------- */

#define OS_CFG_Q_EN                     1u   /* Enable (1) or Disable (0) code generation for QUEUES                  */

#define OS_CFG_Q_DEL_EN                 1u   /*     Include code for OSQDel()                                         */

#define OS_CFG_Q_FLUSH_EN               1u   /*     Include code for OSQFlush()                                       */

#define OS_CFG_Q_PEND_ABORT_EN          1u   /*     Include code for OSQPendAbort()                                   */





                                             /* ----------------------------- SEMAPHORES ---------------------------- */

#define OS_CFG_SEM_EN                   1u   /* Enable (1) or Disable (0) code generation for SEMAPHORES              */

#define OS_CFG_SEM_DEL_EN               1u   /*    Include code for OSSemDel()                                        */

#define OS_CFG_SEM_PEND_ABORT_EN        1u   /*    Include code for OSSemPendAbort()                                  */

#define OS_CFG_SEM_SET_EN               1u   /*    Include code for OSSemSet()                                        */





                                             /* -------------------------- TASK MANAGEMENT -------------------------- */

#define OS_CFG_STAT_TASK_EN             1u   /* Enable (1) or Disable(0) the statistics task                          */

#define OS_CFG_STAT_TASK_STK_CHK_EN     1u   /* Check task stacks from statistic task                                 */



#define OS_CFG_TASK_CHANGE_PRIO_EN      1u   /* Include code for OSTaskChangePrio()                                   */

#define OS_CFG_TASK_DEL_EN              1u   /* Include code for OSTaskDel()                                          */

#define OS_CFG_TASK_Q_EN                1u   /* Include code for OSTaskQXXXX()                                        */

#define OS_CFG_TASK_Q_PEND_ABORT_EN     1u   /* Include code for OSTaskQPendAbort()                                   */

#define OS_CFG_TASK_PROFILE_EN          1u   /* Include variables in OS_TCB for profiling                             */

#define OS_CFG_TASK_REG_TBL_SIZE        1u   /* Number of task specific registers                                     */

#define OS_CFG_TASK_SEM_PEND_ABORT_EN   1u   /* Include code for OSTaskSemPendAbort()                                 */

#define OS_CFG_TASK_SUSPEND_EN          1u   /* Include code for OSTaskSuspend() and OSTaskResume()                   */





                                             /* -------------------------- TIME MANAGEMENT -------------------------- */

#define OS_CFG_TIME_DLY_HMSM_EN         1u   /*     Include code for OSTimeDlyHMSM()                                  */

#define OS_CFG_TIME_DLY_RESUME_EN       1u   /*     Include code for OSTimeDlyResume()                                */





                                             /* ------------------- TASK LOCAL STORAGE MANAGEMENT ------------------- */

#define OS_CFG_TLS_TBL_SIZE             0u   /* Include code for Task Local Storage (TLS) registers                   */





                                             /* ------------------------- TIMER MANAGEMENT -------------------------- */

#define OS_CFG_TMR_EN                   1u   /* Enable (1) or Disable (0) code generation for TIMERS                  */

#define OS_CFG_TMR_DEL_EN               1u   /* Enable (1) or Disable (0) code generation for OSTmrDel()              */



#endif

 

OS_CPU_A.ASM

删除浮点功能先关函数

;删除FPU代码段 删除开始

;#ifdef __ARMVFP__

;    PUBLIC  OS_CPU_FP_Reg_Push

;    PUBLIC  OS_CPU_FP_Reg_Pop

;#endif



;********************************************************************************************************

;                                   FLOATING POINT REGISTERS PUSH

;                             void  OS_CPU_FP_Reg_Push (CPU_STK  *stkPtr)

;

; Note(s) : 1) This function saves S0-S31, and FPSCR registers of the Floating Point Unit.

;

;           2) Pseudo-code is:

;              a) Get FPSCR register value;

;              b) Push value on process stack;

;              c) Push remaining regs S0-S31 on process stack;

;              d) Update OSTCBCurPtr->StkPtr;

;********************************************************************************************************



;#ifdef __ARMVFP__

;OS_CPU_FP_Reg_Push

;    MRS     R1, PSP                                             ; PSP is process stack pointer

;    CBZ     R1, OS_CPU_FP_nosave                                ; Skip FP register save the first time



;    VMRS    R1, FPSCR

;    STR R1, [R0, #-4]!

;    VSTMDB  R0!, {S0-S31}

;    LDR     R1, =OSTCBCurPtr

;    LDR     R2, [R1]

;    STR     R0, [R2]

;OS_CPU_FP_nosave

;    BX      LR

;#endif





;********************************************************************************************************

;                                   FLOATING POINT REGISTERS POP

;                             void  OS_CPU_FP_Reg_Pop (CPU_STK  *stkPtr)

;

; Note(s) : 1) This function restores S0-S31, and FPSCR registers of the Floating Point Unit.

;

;           2) Pseudo-code is:

;              a) Restore regs S0-S31 of new process stack;

;              b) Restore FPSCR reg value

;              c) Update OSTCBHighRdyPtr->StkPtr pointer of new proces stack;

;********************************************************************************************************



;#ifdef __ARMVFP__

;OS_CPU_FP_Reg_Pop

;    VLDMIA  R0!, {S0-S31}

;    LDMIA   R0!, {R1}

;    VMSR    FPSCR, R1

;    LDR     R1, =OSTCBHighRdyPtr

;    LDR     R2, [R1]

;    STR     R0, [R2]

;    BX      LR

;#endif



; 删除结束

 

注意这里没有使能时间戳功能,如果使能还要添加一些函数。

接下来建立任务并测试下功能

 

你可能感兴趣的:(OS)