uCOS-iii 中定义的一些常量

uCOS-iii 中定义的一些常量

uCOS-iii 中有许多宏定义的量,这些量不需要全部记住是什么意思,因为在阅读代码的时候可以选中变量或宏定义然后右键查看定义,就可以知道它代表的什么意思。但是如果知道什么样的变量是大概是什么含义,这样会在阅读代码的时候很流畅。这是我第一天阅读代码的时候遇到的一些宏定义:

第一种是yes和no类型的:常用的TRUE,YES,ENABLE,ACTIVE,VALID,ON,SET,OK都是1的意思,反之则是0:

#define  DEF_FALSE                                         0u
#define  DEF_TRUE                                          1u

#define  DEF_NO                                            0u
#define  DEF_YES                                           1u

#define  DEF_DISABLED                                      0u
#define  DEF_ENABLED                                       1u

#define  DEF_INACTIVE                                      0u
#define  DEF_ACTIVE                                        1u

#define  DEF_INVALID                                       0u
#define  DEF_VALID                                         1u

#define  DEF_OFF                                           0u
#define  DEF_ON                                            1u

#define  DEF_CLR                                           0u
#define  DEF_SET                                           1u

#define  DEF_FAIL                                          0u
#define  DEF_OK                                            1u

第二种是常用的数字的定义。例如DEF_BIT_XX的意思就是二进制的一个1后面有XX个零,例如DEF_BIT_00代表1后面一个0,那就是1,也就是0x01u,而DEF_BIT_07就是1后面7个0,也就是二进制的10000000,这就是十六进制的0x80u。

#define  DEF_BIT_00                                     0x01u
#define  DEF_BIT_01                                     0x02u
#define  DEF_BIT_02                                     0x04u
#define  DEF_BIT_03                                     0x08u
#define  DEF_BIT_04                                     0x10u
#define  DEF_BIT_05                                     0x20u
#define  DEF_BIT_06                                     0x40u
#define  DEF_BIT_07                                     0x80u

#define  DEF_BIT_08                                   0x0100u
#define  DEF_BIT_09                                   0x0200u
#define  DEF_BIT_10                                   0x0400u
#define  DEF_BIT_11                                   0x0800u
#define  DEF_BIT_12                                   0x1000u
#define  DEF_BIT_13                                   0x2000u
#define  DEF_BIT_14                                   0x4000u
#define  DEF_BIT_15                                   0x8000u

#define  DEF_BIT_16                               0x00010000u
#define  DEF_BIT_17                               0x00020000u
#define  DEF_BIT_18                               0x00040000u
#define  DEF_BIT_19                               0x00080000u
#define  DEF_BIT_20                               0x00100000u
#define  DEF_BIT_21                               0x00200000u
#define  DEF_BIT_22                               0x00400000u
#define  DEF_BIT_23                               0x00800000u

#define  DEF_BIT_24                               0x01000000u
#define  DEF_BIT_25                               0x02000000u
#define  DEF_BIT_26                               0x04000000u
#define  DEF_BIT_27                               0x08000000u
#define  DEF_BIT_28                               0x10000000u
#define  DEF_BIT_29                               0x20000000u
#define  DEF_BIT_30                               0x40000000u
#define  DEF_BIT_31                               0x80000000u
/*$PAGE*/
#define  DEF_BIT_32                       0x0000000100000000u
#define  DEF_BIT_33                       0x0000000200000000u
#define  DEF_BIT_34                       0x0000000400000000u
#define  DEF_BIT_35                       0x0000000800000000u
#define  DEF_BIT_36                       0x0000001000000000u
#define  DEF_BIT_37                       0x0000002000000000u
#define  DEF_BIT_38                       0x0000004000000000u
#define  DEF_BIT_39                       0x0000008000000000u

#define  DEF_BIT_40                       0x0000010000000000u
#define  DEF_BIT_41                       0x0000020000000000u
#define  DEF_BIT_42                       0x0000040000000000u
#define  DEF_BIT_43                       0x0000080000000000u
#define  DEF_BIT_44                       0x0000100000000000u
#define  DEF_BIT_45                       0x0000200000000000u
#define  DEF_BIT_46                       0x0000400000000000u
#define  DEF_BIT_47                       0x0000800000000000u

#define  DEF_BIT_48                       0x0001000000000000u
#define  DEF_BIT_49                       0x0002000000000000u
#define  DEF_BIT_50                       0x0004000000000000u
#define  DEF_BIT_51                       0x0008000000000000u
#define  DEF_BIT_52                       0x0010000000000000u
#define  DEF_BIT_53                       0x0020000000000000u
#define  DEF_BIT_54                       0x0040000000000000u
#define  DEF_BIT_55                       0x0080000000000000u

#define  DEF_BIT_56                       0x0100000000000000u
#define  DEF_BIT_57                       0x0200000000000000u
#define  DEF_BIT_58                       0x0400000000000000u
#define  DEF_BIT_59                       0x0800000000000000u
#define  DEF_BIT_60                       0x1000000000000000u
#define  DEF_BIT_61                       0x2000000000000000u
#define  DEF_BIT_62                       0x4000000000000000u
#define  DEF_BIT_63                       0x8000000000000000u
时间: 2024-08-04 02:35:51

uCOS-iii 中定义的一些常量的相关文章

ucos III中任务之间的数据通信和任务划分

1. 如果将关系密切(比如两个任务之间需要经常收发数据)的若干功能分别用不同的任务来实现,则需要进行大量的任务之间数据通信和同步通信,这系统来说是一个很大的负担.因此应该将关系密切的若干功能组合成一个任务,相关数据为各个功能共享,因此可以节省大量的资源. 2. 任务之间的切换需要占用CPU的资源,所以用时间片对任务进行切换,那么时间片的设定是一个取舍值,太小则切换频繁占用CPU太多资源,太大则任务反应速度太慢,所以一般根据经验设定为1ms. 原文地址:https://www.cnblogs.co

C++类中定义常量的方法

好久没用过C++,本来就不太熟悉,今天突然写到一个类,需要在类中定义一个常量,居然花了很长时间. 刚开始写了static const int num = 100: 这样是不行的,因为常量只能在初始化列表中初始化,如果去掉const的话,又不能有"常量"的效果, 在类外用宏定义看起来不科学,类外const也一样,后面就大概搜索了一下,可以选择用枚举类型来替代达到 差不多的效果.具体的代码看下面: class User{ public: enum { MaxNum = 20}; } 写下来

在php中定义常量时,const与define的区别

[问]在php中定义常量时,const与define的区别? [答]使用const使得代码简单易读,const本身就是一个语言结构,而define是一个函数.另外const在编译时要比define快很多. (1).const用于类成员变量的定义,一经定义,不可修改.define不可用于类成员变量的定义,可用于全局常量. (2).const可在类中使用,define不能. (3).const不能在条件语句中定义常量. 例如: if (...){ const FOO = 'BAR';  // 无效的

Java中定义常量方法及建议(Class/Interface)

Class定义常量方法(推荐方法) //final修饰符 public final class Constants { //私有构造方法 private Constants() {} public static final int ConstantA = 100; public static final int ConstantB = 100; ...... } 采用“类.常量名”方法进行调用.需要私有化构造方法,避免创建该类的实例.同时不需让其他类继承该类. 如果多处需要访问工具类中定义的常量

【mybatis】mybatis使用java实体中定义的常量,或静态方法

mybatis使用java实体中定义的常量 示例代码: <select id="findDealerInfo" parameterType="com.pisen.cloud.luna.ms.dealer.api.beans.DealerInfoBean" resultType="com.pisen.cloud.luna.ms.dealer.api.beans.DealerInfoBean"> SELECT dea.uid uid, d

PHP中定义常量

PHP中定义常量的方式如下: define(常量名,常量值); //定义常量PUBLISHER define('PUBLISHER', "O'Reilly & Associates"); echo PUBLISHER; 注意,常量名PUBLISHER的分号是可以不用写的 原文地址:https://www.cnblogs.com/chaoguo1234/p/9538996.html

php 类中定义全局变量|php类定义变量|php类定义常量

PHP 预定义超全局数组/变量 => http://www.q3060.com/list3/list117/23295.html PHP预定义变量 - PHP 超级全局变量 => http://www.q3060.com/list3/list117/23278.html php怎么定义全局变量 => http://www.q3060.com/list3/list117/22852.html php 的全局变量与局部变量 => http://www.q3060.com/list3/l

UCOS iii 钩子函数 中断服务函数 临界区 延时函数

钩子函数 功能: 扩展任务功能,被其他任务调用  算是消息机制 1.OSIdleTaskHook(),空闲任务调用这个函数,可以用来让CPU进入低功耗模式 2.OSInitHook(), 系统初始化函数OSInit()调用此函数. 3.OSStatTaskHook(),统计任务每秒中都会调用这个函数,此函数允许你向统计任务中添加自己的应用函数. 4.OSTaskCreateHook(),任务创建的钩子函数. 5.OSTaskDelHook(), 任务删除的钩子函数. 6.OSTaskReturn

Delphi中定义了四种布尔类型:Boolean,ByteBool,WordBool和LongBool。后面三种布尔类型是为了与其他语言兼容而引入的

bool是LongBool类型. Delphi中定义了四种布尔类型:Boolean,ByteBool,WordBool和LongBool.后面三种布尔类型是为了与其他语言兼容而引入的,一般情况下建议使用Boolean类型. 这四种类型的布尔值占用内存的数量如下: Boolean 1 Byte ByteBool 1 Byte WordBool 2 Bytes(1 Word) LongBool 4 Bytes(2 Words) 对于ByteBool,WordBool和LongBool三种类型True