本帖最后由 CC2530 于 2011-3-20 17:58 编辑
//IO口宏定义
STM8S_GPIO_ASSIGN(LED_0,D,1); //LED_0:PD1,用模板定义所有LED_0操作内联函数
STM8S_GPIO_ASSIGN(LED_1,D,2); //LED_1:PD2,用模板定义所有LED_1操作内联函数
STM8S_GPIO_ASSIGN(LED_2,D,3); //LED_2:PD3,用模板定义所有LED_2操作内联函数
STM8S_GPIOS_ASSIGN(LED,D,1,3); //LED:PD1-PD3,用模板定义所有LED操作内联函数
//LED单独设置
GPIO_LED_0_MakeOutputPushPullSlow(1);
//LED_0设置为OutputPushPullSlow,初始输出1
GPIO_LED_1_MakeOutputPushPullSlow(1);
//LED_1设置为OutputPushPullSlow,初始输出1
GPIO_LED_2_MakeOutputPushPullSlow(0);
//LED_2设置为OutputPushPullSlow,初始输出0
GPIO_LED_0_Set();
//LED_0输出1
GPIO_LED_0_Clr();
//LED_0输出0
GPIO_LED_0_Toggle();
//LED_0翻转
//LED整体设置
GPIOS_LED_MakeOutputPushPullSlow(3);
//LED整体设置为OutputPushPullSlow,
//初始输出3,即LED_0初始输出1,即LED_1初始输出1,即LED_2初始输出0
GPIOS_LED_Out(5);
//LED整体输出5;即LED_0初始输出1,即LED_1初始输出0,即LED_2初始输出1
GPIOS_LED_Out(2);
//LED整体输出2;即LED_0初始输出0,即LED_1初始输出1,即LED_2初始输出0
GPIOS_LED_Toggle();
//LED整体翻转
//C语言编译汇编代码
// 12 //LED单独设置
// 13 GPIO_LED_0_MakeOutputPushPullSlow(1);
BSET L:0x500f, #0x1
BRES L:0x5011, #0x1
BRES L:0x5012, #0x1
BRES L:0x5013, #0x1
// 14 //LED_0设置为OutputPushPullSlow,初始输出1
// 15
// 16 GPIO_LED_1_MakeOutputPushPullSlow(1);
BSET L:0x500f, #0x2
BRES L:0x5011, #0x2
BRES L:0x5012, #0x2
BRES L:0x5013, #0x2
// 17 //LED_1设置为OutputPushPullSlow,初始输出1
// 18
// 19 GPIO_LED_2_MakeOutputPushPullSlow(0);
BRES L:0x500f, #0x3
BRES L:0x5011, #0x3
BRES L:0x5012, #0x3
BRES L:0x5013, #0x3
// 20 //LED_2设置为OutputPushPullSlow,初始输出0
// 21
// 22 GPIO_LED_0_Set();
BSET L:0x500f, #0x1
// 23 //LED_0输出1
// 24
// 25 GPIO_LED_0_Clr();
BRES L:0x500f, #0x1
// 26 //LED_0输出0
// 27
// 28 GPIO_LED_0_Toggle();
LD A, #0x2
XOR A, L:0x500f
LD L:0x500f, A
// 29 //LED_0翻转
// 30
// 31
// 32 //LED整体设置
// 33 GPIOS_LED_MakeOutputPushPullSlow(3);
BRES L:0x500f, #0x3
LD A, #0x6
OR A, L:0x500f
LD L:0x500f, A
LD A, #0xf1
AND A, L:0x5011
LD L:0x5011, A
LD A, #0xf1
AND A, L:0x5012
LD L:0x5012, A
LD A, #0xf1
AND A, L:0x5013
LD L:0x5013, A
// 34 //LED整体设置为OutputPushPullSlow,
// 35 //初始输出3,即LED_0初始输出1,即LED_1初始输出1,即LED_2初始输出0
// 36
// 37 GPIOS_LED_Out(5);
BRES L:0x500f, #0x2
LD A, #0xa
OR A, L:0x500f
LD L:0x500f, A
// 38 //LED整体输出5;即LED_0初始输出1,即LED_1初始输出0,即LED_2初始输出1
// 39
// 40 GPIOS_LED_Out(2);
LD A, #0xf5
AND A, L:0x500f
LD L:0x500f, A
BSET L:0x500f, #0x2
// 41 //LED整体输出2;即LED_0初始输出0,即LED_1初始输出1,即LED_2初始输出0
// 42
// 43 GPIOS_LED_Toggle();
LD A, #0xe
XOR A, L:0x500f
LD L:0x500f, A
// 44 //LED整体翻转 |
|