傻大方


首页 > 知识库 > >

移植|移植μCOSII中英文翻译资料( 四 )


按关键词阅读: 移植 COSII 资料 翻译 中英文


/* 开始多任务 */T4 在不正确的位置启动节拍中断Porting C/OS-IIThis article describes in general terms what needs to be done in order to adapt C/OS-II to different processors. Adapting a real-time kernel to a microprocessor or a microcont 。

23、roller is called a port. Most of C/OS-II is written in C for portability, however, it is still necessary to write some processor specific code in C and assembly language. Specifically, C/OS-II manipulates processor registers which can only be done through assembly language. Porting C/OS-II to differ 。

24、ent processors is relatively easy because C/OS-II was designed to be portable. A processor can run C/OS-II if it satisfies the following general requirements:(1) You must have a C compiler for the processor and the C compiler must be able to produce reentrant code. (2) You must be able to disable an 。

25、d enable interrupts from C.(3) The processor must support interrupts and you need to provide an interrupt that occurs at regular intervals (typically between 10 to 100 Hz).(4) The processor must support a hardware stack, and the processor must be able to store a fair amount of data on the stack (pos 。

26、sibly many Kbytes).(5) The processor must have instructions to load and store the stack pointer and other CPU registers either on the stack or in memory.Porting C/OS-II is actually quite straightforward once you understand the subtleties of the target processor and the C compiler you will be using.。

27、Depending on the processor, a port can consist of writing or changing between 50 and 300 lines of code! Porting C/OS-II could take you anywhere between a few hours to about a week.Once you have a port of C/OS-II for your processor, you will need to verify its operation. Testing a multitasking real-t 。

28、ime kernel such as C/OS-II is not as complicated as you may think. You should test your port without application code. In other words, test the operations of the kernel by itself. There are two reasons to do this. First, you dont want to complicate things anymore than they need to be. Second, if som 。

29、ething doesnt work, you know that the problem lies in the port as opposed to your application. Start with a couple of simple tasks and only the ticker interrupt service routine. Once you get multitasking going, its quite simple to add your application tasks.1.1 Development ToolsAs previously stated, 。

30、 you need a C compiler for the processor you intend to use in order to port C/OS-II. Because C/OS-II is a preemptive kernel, you should only use a C compiler that generates reentrant code. Your C compiler must also be able to support assembly language programming. Most C compiler designed for embedd 。

31、ed systems will, in fact, also include an assembler, a linker, and a locator. The linker is used to combine object files (compiled and assembled files) from different modules while the locator will allow you to place the code and data anywhere in the memory map of the target processor. Your C compil 。

32、er must also provide a mechanism to disable and enable interrupts from C. Some compilers will allow you to insert in-line assembly language statements in your C source code. This makes it quite easy to insert the proper processor instructions to enable and disable interrupts. 1.2 Files(1) INCLUDES.H 。

33、 INCLUDES.H is a MASTER include file and is found at the top of all .C files as follows:# include “includes.h”INCLUDES.H allows every .C file in your project to be written without concerns about which header file will actually be needed. The only drawback to having a master include file is that INCL 。

34、UDES.H may include header files that are not pertinent to the actual .C file being compiled. This means that each file will require extra time to compile. This inconvenience is offset by code portability. You can edit INCLUDES.H to add your own header files but, your header files should be added at。

35、the end of the list.(2) OS_CPU.HOS_CPU.H contains processor and implementation specific #defines constants, macros, and typedefs. The general layout of OS_CPU.H is shown in listing #ifdef OS_CPU_GLOBALS#define OS_CPU_EXT#else#define OS_CPU_EXT extern#endiftypedef unsigned char BOOLEAN;
typedef unsign 。

36、ed char INT8U;
/* Unsigned 8 bit quantity*/ (1)typedef signed char INT8S;
/* Signed 8 bit quantity*/typedef unsigned int INT16U;
/* Unsigned 16 bit quantity*/typedef signed int INT16S;
/* Signed 16 bit quantity*/typedef unsigned long INT32U;
/* Unsigned 32 bit quantity*/typedef signed long INT32S;
/* Sign 。

37、ed 32 bit quantity*/typedef float FP32;
/*Single precision floating point*/ (2)typedef double FP64;
/* Double precision floating point */typedef unsignedint OS_STK;
/*Each stack entryis 16-bit wide*/#define OS_ENTER_CRITICAL() ? /* Disable interrupts*/ (3)#define OS_EXIT_CRITICAL() ? /* Enable interrup 。


来源:(未知)

【学习资料】网址:/a/2021/0406/0021864430.html

标题:移植|移植μCOSII中英文翻译资料( 四 )


上一篇:2021|2021年公司办公室文员办公室实习报告范文

下一篇:农村信用社|某农村信用社信息科技风险管理经验交流