首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

清蒸,豉汁,砂仁,哪个好吃点?

清蒸,豉汁,砂仁,哪个好吃点?

一 前言   
       很多人使用keil的时候感觉keil的configuration wizard 很神奇,用起来特别方便,但是苦于不知道怎么去编写自己的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 0x83
5.<o>选择或者输入数字
          //        <o> this is a 32bit input
uint32 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=> 2
uint32 tmp32=0x01;
当选择2的时候把1赋给了后面的tmp32

那么指定位置呢?
当然也是可以的。

uint32 tmp32=0x01;
//        <o.0> this is a 32bit input bit0
//         <0=> 1      <1=> 2
uint32 tmp32=0x01;
//        <o.0..7> this is a 32bit input bit0-7
//         <0=> 1      <1=> 2  <255=> 3
uint32 tmp32=0xFF;
6.字符串输入<s>

//         <s> this is a string input
uint32 buf[]="hello";
如果要想要限制字符串输入的长度可以用:<s:limt>
//         <s.10> this is a string input
uint32 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  1
uint32 tmp32=0x15;
uint32 tmp32=0x00;
uint32 tmp32=0x01;
uint32 tmp32=0xFF;
uint32 buf[]="hello";                 
uint32 buf[]="hello12345";
返回列表