UCOS-II移植 os_cpu.h文件详解

os_cpu.h文件位于工程uC/OS-II Ports结构下面,主要是系统底层相关的定义(堆栈、数据类型)、声明(函数)等。


/************************ (C) COPYLEFT 2010 Leafgrass *************************


* File Name : os_cpu_c.c 
* Author : Librae
* Date : 06/10/2010
* Description : μCOS-II在STM32上的移植代码C语言部分,
*  包括任务堆栈初始化代码和钩子函数等


******************************************************************************/


#ifndef __OS_CPU_H__
#define __OS_CPU_H__


#ifdef  OS_CPU_GLOBALS
#define OS_CPU_EXT
#else
#define OS_CPU_EXT  extern
#endif


/******************************************************************************
*                    定义与编译器无关的数据类型
******************************************************************************/


typedef unsigned char  BOOLEAN;
typedef unsigned char  INT8U; /* Unsigned  8 bit quantity       */
typedef signed   char  INT8S; /* Signed    8 bit quantity       */
typedef unsigned short INT16U; /* Unsigned 16 bit quantity       */
typedef signed   short INT16S; /* Signed   16 bit quantity       */
typedef unsigned int   INT32U; /* Unsigned 32 bit quantity       */
typedef signed   int   INT32S; /* Signed   32 bit quantity       */
typedef float          FP32; /* Single precision floating point*/
typedef double         FP64; /* Double precision floating point*/


//STM32是32位位宽的,这里OS_STK和OS_CPU_SR都应该为32位数据类型
typedef unsigned int   OS_STK; /* Each stack entry is 32-bit wide*/
typedef unsigned int   OS_CPU_SR; /* Define size of CPU status register*/
/* 
*******************************************************************************
*                             Cortex M3
*                     Critical Section Management
*******************************************************************************
*/




/*
*******************************************************************************
*                          ARM Miscellaneous
*******************************************************************************
*/




//定义栈的增长方向.
//CM3中,栈是由高地址向低地址增长的,所以OS_STK_GROWTH设置为1
#define  OS_STK_GROWTH        1      /* Stack grows from HIGH to LOW memory on ARM    */
//任务切换宏,由汇编实现.
#define  OS_TASK_SW()         OSCtxSw()


/*
*******************************************************************************
*                               PROTOTYPES
*                           (see OS_CPU_A.ASM)
*******************************************************************************
*/
//OS_CRITICAL_METHOD = 1 :直接使用处理器的开关中断指令来实现宏 
//OS_CRITICAL_METHOD = 2 :利用堆栈保存和恢复CPU的状态 
//OS_CRITICAL_METHOD = 3 :利用编译器扩展功能获得程序状态字,保存在局部变量cpu_sr


#define  OS_CRITICAL_METHOD   3 //进入临界段的方法


#if OS_CRITICAL_METHOD == 3
#define  OS_ENTER_CRITICAL()  {cpu_sr = OS_CPU_SR_Save();}
#define  OS_EXIT_CRITICAL()   {OS_CPU_SR_Restore(cpu_sr);}
#endif


void       OSCtxSw(void);
void       OSIntCtxSw(void);
void       OSStartHighRdy(void);


void       OSPendSV(void);
//默认使用临界区第3模式,这个定义主要与os_cpu_a.asm文件定义OS_CPU_SR_Save()函数有关。
#if OS_CRITICAL_METHOD == 3u                      /* See OS_CPU_A.ASM                                  */
OS_CPU_SR  OS_CPU_SR_Save(void);
void       OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
#endif
OS_CPU_EXT INT32U OSInterrputSum;


#endif


/************************ (C) COPYLEFT 2010 Leafgrass ************************/

\SOFTWARE The main directory from the root where all software-related files are placed. \SOFTWARE\BLOCKS The main directory where all ‘Building Blocks’ are located. With μC/OS-II, I included a ‘building block’ that handles DOS-type compatible functions that are used by the example code. \SOFTWARE\BLOCKS\TO This directory contains the files for the TO utility (see Appendix E, TO). The source file is TO.C and is found in the \SOFTWARE\TO\SOURCE directory. The DOS executable file (TO.EXE) is found in the \SOFTWARE\TO\EXE directory. Note that TO requires a file called TO.TBL which must reside on your root directory. An example of TO.TBL is also found in the \SOFTWARE\TO\EXE directory. You will need to move TO.TBL to the root directory if you are to use TO.EXE. \SOFTWARE\uCOS-II The main directory where all μC/OS-II files are located. \SOFTWARE\uCOS-II\EX1_x86L This directory contains the source code for EXAMPLE #1 (see section 1.07, Example #1) which is intended to run under DOS (or a DOS window under Windows 95). \SOFTWARE\uCOS-II\EX2_x86L This directory contains the source code for EXAMPLE #2 (see section 1.08, Example #2) which is intended to run under DOS (or a DOS window under Windows 95). \SOFTWARE\uCOS-II\EX3_x86L This directory contains the source code for EXAMPLE #3 (see section 1.09, Example #3) which is intended to run under DOS (or a DOS window under Windows 95). \SOFTWARE\uCOS-II\Ix86L This directory contains the source code for the processor dependent code (a.k.a. the port) of μC/OS-II for an 80x86 Real-Mode, Large Model processor. \SOFTWARE\uCOS-II\SOURCE This directory contains the source code for processor independent portion of μC/OS-II. This code is fully portable to other processor architectures.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值