Keil uvision中使用配置向导简介

xiaoxiao2021-02-28  39

本文章为转载,来源不可考了,最新的来源是https://zhidao.baidu.com/question/347422920.html

一 前言 keil的configuration wizard可以将枯燥的代码转换为灵活的人机界面进行参数配置,用起来特别方便,其实keil的help文档就有,只是英文不容易明白,为此,将作下面的介绍二 基本介绍Configuration wizard 只能在keil中使用,能够可以通过菜单的方式对一些预设值进行设置,修改,配置。三.基本使用方法在文档中写入 标记开始<<< Use Configuration Wizard in Context Menu >>>当检测到以上关键字,keil就会认为这个文档里面存着Configuration Wizard,并开始搜索内容中的其他关键字。当检测到以下内容的时候,停止搜索<<< end of configuration section >>>注意: <<< Use Configuration Wizard in Context Menu >>>和<<< end of configuration section >>> 必须被“//”屏蔽 或者“;”。因为是额外的信息不能影响到文档的编译所以,必须屏蔽,但是屏蔽不可以用批量屏蔽如“/* 。。。。 */,即使“/* ”和“*/”在同一行也不可以。并且“//”或者“;”必须在行首。下面一步步完善这个例子:新建一个test.c文档作为测试文档。在文档中输入://<<< Use Configuration Wizard in Context Menu >>>//<<< end of configuration section >>>保存并且关闭,再打开 就可以看到Configuration Wizard 的选项了。点击进去可以看到选项已经出来了,只是里面的内容还是空的。命令字 1.标题命令字 <h>和</h> <h>和</h>必须成对出现,<h>表示一个段落(组)开始,</h>表示段落(组)结束,如果只有<h>没有</h>系统就会报错。 继续扩充测试代码://<<< Use Configuration Wizard in Context Menu >>>//<h> this is a heading//</h>//<<< end of configuration section >>>2.使能组<e>和</e> 和<h>类似,但是<e>确是有更大的功能,Enable。举个例子: //<<< Use Configuration Wizard in Context Menu >>>// <h> this is a heading // </h>// <e>this is an options// </e> //<<< end of configuration section >>>这里需要说明的是<e>只是一个单选的,enable or disable ,因此这里开始就想怎么跟程序结合起来了。于是在</e>的后面定义了一个8bit的tmp变量并且把他的值赋为0。//<<< Use Configuration Wizard in Context Menu >>>// <h> this is a heading // </h>// <e>this is an options// </e>uint8 tmp = 0; //<<< end of configuration section >>>当把this is an options 打上勾勾的时候,就自动变成了tmp=1:这就是想要的。通过配置菜单,进行一些配置就可以改变到编译的c文件的内容那么如果只想设置tmp的某一位,比如第三位,怎么办?通过<e.n> 命令,n表示第几位。选择前://<<< Use Configuration Wizard in Context Menu >>>// <h> this is a heading // </h>// <e.3>this is an options// </e>uint8 tmp=1; //<<< end of configuration section >>>选择后://<<< Use Configuration Wizard in Context Menu >>>// <h> this is a heading // </h>// <e.3>this is an options// </e>uint8 tmp=9; //<<< end of configuration section >>>再来扩充下视野:假设8bit的数据分成8个enable选项,应该怎么做呢?//<<< Use Configuration Wizard in Context Menu >>>// <h> this is a heading // </h>/ <e.3>this is an options bit 3// </e>// <e.2>this is an options bit 2// </e>// <e.0>this is an options bit 0// </e>uint8 tmp=9; //<<< end of configuration section >>>3.infomations命令<i> 当鼠标停留在当前的条目的时候可以显示提示信息。继续代码说明: //<<< Use Configuration Wizard in Context Menu >>>// <h> this is a heading // <i> head start form here!// </h>// <e>this is an options// </e> //<<< end of configuration section >>>4.位允许<q> 和<e>不同,<q>只是一个单选项,没有段落(组)的概念。// <h> this is a heading // <i> head start form here!// <q> this is single bitenable// </h>#define BitEnalbe 1同样也可以指定具体的某一位// <h> this is a heading // <i> head start form here!// <q.0> this is single bitenable bit 0// <q.1> this is single bitenable bit 1// <q.7> this is single bitenable bit 7// </h>#define BitEnalbe 0x835.<o>选择或者输入数字 // <o> this is a 32bit inputuint32 tmp32=0x2000;数字输入涉及的问题就很多啦。比如要限制啊,只能是一定范围啊,咋办?<min-max>// <o> this is a 32bit input // <2-30> uint32 tmp32=0x02;只能选择到极限值以内了。如果主动输入限制范围以外的数值呢?那可能会导致崩溃!<min-max>后面还可以跟一个步进:<min-max:step>,比如:// <o> this is a 32bit input // <2-30:4> uint32 tmp32=0x10;步进就变成了4了,每次点击上或者下,变化的步进就是4那么这个数字能不能做成下拉菜单呢?当然是可以的。// <o> this is a 32bit input // <0=> 1 <1=> 2uint32 tmp32=0x01;当选择2的时候把1赋给了后面的tmp32那么指定位置呢?当然也是可以的。uint32 tmp32=0x01;// <o.0> this is a 32bit input bit0 // <0=> 1 <1=> 2uint32 tmp32=0x01;// <o.0..7> this is a 32bit input bit0-7 // <0=> 1 <1=> 2 <255=> 3uint32 tmp32=0xFF;6.字符串输入<s> // <s> this is a string inputuint32 buf[]="hello";如果要想要限制字符串输入的长度可以用:<s:limt>// <s.10> this is a string inputuint32 buf[]="hello12345";这个基本功能就介绍完了,下面有个重点功能要介绍: 7.整合所有的配置项 配置项多的时候是需要整合的。整合的过程当中,必须看清楚一个功能,那就是怎么跟多个配置项的配对起来。 在一个段落中,keil是只会把数值赋给随后的第一个定义,为了区分一个段落中的不同配置项,要用后缀来区分。上例子: // <h> for multi-configuarations // <q.0> this is single bit enable bit 0// <q1.0> this is single bit enable bit 0// <o> this is a 32bit input // <2-30:4> // <o1> this is a 32bit input // <0=> 1 <1=> 2// <o2.0> this is a 32bit input bit0 // <0=> 1 <1=> 2// <o3.0..7> this is a 32bit input bit0-7 // <0=> 1 <1=> 2 <255=> 3// <s> this is a string input// <s1.10> this is a string input// </h>#define Q0 1#define Q1 1uint32 tmp32=0x15;uint32 tmp32=0x00;uint32 tmp32=0x01;uint32 tmp32=0xFF;uint32 buf[]="hello"; uint32 buf[]="hello12345";

转载请注明原文地址: https://www.6miu.com/read-1650377.html

最新回复(0)