keil的configuration wizard配置和使用

以前发现keil 的很棒的功能 今天终于会用了。 分享给大家。转载的。

一 前言
很多人使用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>系统就会报错。

 我们继续扩充我们的测试代码:

//<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

//

//<<< end of configuration section >>>

2.使能组和

     和<h>类似,但是<e>确是有更大的功能,Enable。举个例子:

      //<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

//

// this is an options

//

//<<< end of configuration section >>>

这里需要说明的是只是一个单选的,enable or disable ,因此这里开始我们就想怎么跟我们的程序结合起来了。于是我在的后面定义了一个8bit的tmp变量并且把他的值赋为0。

//<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

//

// this is an options

//

uint8 tmp = 0;

//<<< end of configuration section >>>

当我把this is an options 打上勾勾的时候,

就自动变成了tmp=1:

这就是我们想要的。通过配置菜单,进行一些配置就可以改变到编译的c文件的内容

那么如果我只想设置tmp的某一位,比如第三位,怎么办?

通过<e.n> 命令,n表示第几位。

选择前:

//<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

//

// <e.3>this is an options

//

uint8 tmp=1;

//<<< end of configuration section >>>

选择后:

//<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

//

// <e.3>this is an options

//

uint8 tmp=9;

//<<< end of configuration section >>>

我们再来扩充下视野:假设我的8bit的数据分成8个enable选项,应该怎么做呢?

//<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

//

// <e.3>this is an options bit 3

//

// <e.2>this is an options bit 2

//

// <e.0>this is an options bit 0

//

uint8 tmp=9;

//<<< end of configuration section >>>

3.infomations命令

当鼠标停留在当前的条目的时候可以显示提示信息。我们继续代码说明:

//<<< Use Configuration Wizard in Context Menu >>>

// this is a heading

// head start form here!

//

// this is an options

//

//<<< end of configuration section >>>

4.位允许

和不同,只是一个单选项,没有段落(组)的概念。

// this is a heading

// head start form here!

// this is single bitenable

//

#define BitEnalbe 1

同样也可以指定具体的某一位

// this is a heading

// 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

//

#define BitEnalbe 0x83

5.选择或者输入数字

      //        <o> this is a 32bit input

uint32 tmp32=0x2000;

数字输入涉及的问题就很多啦。比如我要限制啊,只能是一定范围啊,咋办?

// this is a 32bit input

// <2-30>

uint32 tmp32=0x02;

只能选择到极限值以内了。如果主动输入限制范围以外的数值呢?那可能会导致崩溃!

后面还可以跟一个步进:min-max:step,比如:

// this is a 32bit input

// <2-30:4>

uint32 tmp32=0x10;

步进就变成了4了,每次点击上或者下,变化的步进就是4

那么这个数字能不能做成下拉菜单呢?当然是可以的。

// 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.字符串输入

// 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

// this is a 32bit input

// <2-30:4>

// 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

// this is a string input

// <s1.10> this is a string input

//

#define Q0 1

#define Q1 1

uint32 tmp32=0x15;

uint32 tmp32=0x00;

uint32 tmp32=0x01;

uint32 tmp32=0xFF;

uint32 buf[]=“hello”;

uint32 buf[]=“hello12345”;

原文链接:https://blog.csdn.net/ropai/article/details/33719447

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sdhdwyx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值