野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7775|回复: 6

[ucos] ucosII 按键程序,求大神帮我改下

[复制链接]
发表于 2014-3-19 10:27:23 | 显示全部楼层 |阅读模式
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3| GPIO_Pin_4 ;       
         
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;      
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
       
        GPIO_SetBits(GPIOC, GPIO_Pin_6 | GPIO_Pin_7 );         // turn off all led
        GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_2 | GPIO_Pin_3|GPIO_Pin_4 );

********************************************************************
#define K         GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_2 | GPIO_Pin_3|GPIO_Pin_4 );

********************************************************************
  while (1)
    {
       if(K==6) M=1;
           else  if(K==5) M=2;
                             else if(K==4)M=0;
          
    }
********************************************************************
..\APP\app.c(8): error:  #18: expected a ")"
..\APP\app.c:          if(K==6) M=1;
..\APP\app.c:             ^
..\APP\app.c(9): error:  #18: expected a ")"
..\APP\app.c:              else  if(K==5) M=2;
..\APP\app.c:                       ^
..\APP\app.c(10): error:  #18: expected a ")"
..\APP\app.c:                             else if(K==4)M=0;
..\APP\app.c:                                     ^
..\APP\app.c: ..\APP\app.c: 0 warnings, 3 errors
回复

使用道具 举报

发表于 2014-3-19 10:48:26 | 显示全部楼层
GPIO_ReadInputDataBit改为GPIO_ReadInputData

把#define后面的分号删除
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-19 10:52:51 | 显示全部楼层
三流电工 发表于 2014-3-19 10:48
GPIO_ReadInputDataBit改为GPIO_ReadInputData

把#define后面的分号删除

还是出现错误啊!..\BSP\led.c(43): error:  #140: too many arguments in function call
..\BSP\led.c:           GPIO_ReadInputData(GPIOE, GPIO_Pin_2 | GPIO_Pin_3|GPIO_Pin_4 );
..\BSP\led.c:                                     ^
..\BSP\led.c: ..\BSP\led.c: 0 warnings, 1 error
compiling app.c...
..\APP\app.c(8): error:  #140: too many arguments in function call
..\APP\app.c:          if(K==6) M=1;
..\APP\app.c:             ^
..\APP\app.c(9): error:  #140: too many arguments in function call
..\APP\app.c:              else  if(K==5) M=2;
..\APP\app.c:                       ^
..\APP\app.c(10): error:  #140: too many arguments in function call
..\APP\app.c:                             else if(K==4)M=0;
..\APP\app.c:                                     ^
..\APP\app.c: ..\APP\app.c: 0 warnings, 3 errors
回复 支持 反对

使用道具 举报

发表于 2014-3-19 10:58:42 | 显示全部楼层
GPIO_ReadInputData(GPIOE);
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-19 11:02:31 | 显示全部楼层
三流电工 发表于 2014-3-19 10:58
GPIO_ReadInputData(GPIOE);

..\APP\app.c(8): error:  #140: too many arguments in function call
..\APP\app.c:          if(K==6) M=1;
..\APP\app.c:             ^
..\APP\app.c(9): error:  #140: too many arguments in function call
..\APP\app.c:              else  if(K==5) M=2;
..\APP\app.c:                       ^
..\APP\app.c(10): error:  #140: too many arguments in function call
..\APP\app.c:                             else if(K==4)M=0;
..\APP\app.c:                                     ^
..\APP\app.c: ..\APP\app.c: 0 warnings, 3 errors
回复 支持 反对

使用道具 举报

发表于 2014-3-19 11:25:24 | 显示全部楼层
#define K         GPIO_ReadInputData(GPIOE)
回复 支持 反对

使用道具 举报

发表于 2016-10-12 14:46:45 | 显示全部楼层
三流电工 发表于 2014-3-19 11:25
#define K         GPIO_ReadInputData(GPIOE)

刀币好厉害
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-16 11:31 , Processed in 0.030431 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表