×
单片机 > 单片机程序设计 > 详情

UCOS_II的移植到S3C2440 ADS 1.2

发布时间:2024-05-19 发布时间:
|

一、新建工程

1.新建一个ARM Executable Image

2.创建uCOS_II文件夹,创建两个子文件夹,分别为ARM、SOURCE

ARM存放和平台相关的文件("OS_CPU.H" "Os_cpu_a.s" "Os_cpu_c.c" )

SOURCE下存入和平台无关的文件("ucos_ii.h" "os_cfg.h" "os_core.c" "os_flag.c" "os_mbox.c" "os_mem.c" "os_mutex.c" "os_q.c" "os_sem.c" "os_task.c" "os_time.c" "os_tmr.c" )

3.创建一个S3C2440文件夹,创建两个子文件夹,分别为INC、SRC

INC存放S3C2440相关头文件("2440addr.h" "2440lib.h" "2440slib.h" "config.h" "Def1.h" "lcd.h" "mmu.h" "Option.h" "Target.h" "Timer.h" )

SRC存放S3C2440相关源文件("Timer.c" "2440init.s" "2440lib.c" "2440slib.s" "Font_Libs.c" "iphone.c" "lcd.c" "mmu.c" "nand.c" "Target.c" )

4.创建一个app文件夹(app_cfg.h、main.c、Printf.c、Printf.h)


二、工程设置Edit->DebugRel Settings下

1.Target->Target Settings,Post-linker:ARM fromELF

2.Target->Access Paths选中Always Search User Paths(ucos_ii部分文件采用#include <>包涵,不修改这里找不到文件)

3.Language Settings下ARM Assembler、ARM C Compliler、ARM C++ Complier处理器设置成ARM920T

4.Language Settings下ARM C Compliler下Errors下去掉Implicit pointer c,ARM C Compliler下Warnings下去掉Unused declaration(-O1 -g+ -cpu ARM920T -Wx -Ec)

5.ARM Linker下,Output下RO Base设置成0x30000000,Options下Image entry point设置成0x30000000,Layout下Place at beginning of image下的Object/Symbol设置成2440init.o,Section设置成Init,Listings下选勾Image map、List file设置list.txt,勾上Sizes、Totals、Unused、Veneers

6.ARM fromELF下Output file name下填写输出的二进制


三、移植文件的修改


对OS_CPU.H的修改:


view plaincopy to clipboard

/*

*********************************************************************************************************

* ARM

*

* Method #1: NOT IMPLEMENTED

* Disable/Enable interrupts using simple instructions. After critical section, interrupts

* will be enabled even if they were disabled before entering the critical section.

*

* Method #2: NOT IMPLEMENTED

* Disable/Enable interrupts by preserving the state of interrupts. In other words, if

* interrupts were disabled before entering the critical section, they will be disabled when

* leaving the critical section.

* NOT IMPLEMENTED

*

* Method #3: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you

* would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then

* disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to

* disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr'

* into the CPU's status register. This is the prefered method to disable interrupts.

*********************************************************************************************************

*/

#define OS_CRITICAL_METHOD 3

#if OS_CRITICAL_METHOD == 3

#define OS_ENTER_CRITICAL() (cpu_sr = OSCPUSaveSR()) /* Disable interrupts */

#define OS_EXIT_CRITICAL() (OSCPURestoreSR(cpu_sr)) /* Restore interrupts */

#endif

/*

*********************************************************************************************************

* ARM Miscellaneous

*********************************************************************************************************

*/

#define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory on ARM */

#define OS_TASK_SW() OSCtxSw()


对Os_cpu_c.c的修改:


view plaincopy to clipboard

/*

*********************************************************************************************************

* uC/OS-II

* The Real-Time Kernel

*

* (c) Copyright 1992-2003, Micrium, Inc., Weston, FL

* All Rights Reserved

*

* ARM9 Port

*

* File : OS_CPU_C.C

*********************************************************************************************************

*/

//#define OS_CPU_GLOBALS

#include "ucos_ii.h"

/*

*********************************************************************************************************

* INITIALIZE A TASK'S STACK

*

* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the

* stack frame of the task being created. This function is highly processor specific.

*

* Arguments : task is a pointer to the task code

*

* p_arg is a pointer to a user supplied data area that will be passed to the task

* when the task first executes.

*

* ptos is a pointer to the top of stack. It is assumed that 'ptos' points to

* a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then

* 'ptos' will contain the HIGHEST valid address of the stack. Similarly, if

* OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address

* of the stack.

*

* opt specifies options that can be used to alter the behavior of OSTaskStkInit().

* (see uCOS_II.H for OS_TASK_OPT_???).

*

* Returns : Always returns the location of the new top-of-stack' once the processor registers have

* been placed on the stack in the proper order.

*

* Note(s) : 1) Interrupts are enabled when your task starts executing.

* 2) All tasks run in SVC mode.

*********************************************************************************************************

*/

OS_STK *OSTaskStkInit (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT16U opt)

{

OS_STK *stk;

optop

[1] [2] [3] [4] [5] [6] [7]
UCOS_II移植到S3C2440ADS12

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
浅谈AVR中定时器几种工作模式