打印

expected a "{"怎么回事

[复制链接]
5990|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
pipixiong999|  楼主 | 2010-7-17 18:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
TE, ST, TI, se, AN
U8                                   CloseBit=0;                                //当为1时,指示进入关机状态,如果未松手,黑屏

static  U8     KeyBuf[KEY_BUF_SIZE];    /* Keyboard buffer                                         */
static  U8     KeyBufInIx;              /* Index into key buf where next scan code will be inserted*/
static  U8     KeyBufOutIx;             /* Index into key buf where next scan code will be removed */
static  U16    KeyDownTmr;              /* Counts how long key has been pressed                    */
static  U8     KeyNRead;                /* Number of keys read from the keyboard                   */

static  U8     KeyRptStartDlyCtr;       /* Number of scan times before auto repeat is started      */
static  U8     KeyRptDlyCtr;            /* Number of scan times before auto repeat executes again  */

static  U8     KeyScanState;            /* Current state of key scanning function                  */

static  U32 KeyScanTaskStk[KEY_SCAN_TASK_STK_SIZE/4];  /* Keyboard scanning task stack             */

static  OS_SEM  KeySemPtr;              /* Pointer to keyboard semaphore                            */

OS_TID TIDKeySTask;

U8 const UserKeyMapTbl[]={
        3,2,1,12,0xff,
        6,5,4,13,18,
        9,8,7,14,17,
        10,0,11,15,16
};
void   KeyBufIn(U8 code);                       /* Insert scan code into keyboard buffer                   */
static  U8     KeyDecode(void);         /* Get scan code from current key pressed                  */
static  BOOL   KeyIsKeyDown(void);      /* See if key has been pressed                             */
void   KeyScanTask(void);                /* Keyboard scanning task                                  */
void  KeyInit (void)
{
    KeySelRow(KEY_ALL_ROWS);                     /* Select all row                                     */
    KeyScanState = KEY_STATE_UP;                 /* Keyboard should not have a key pressed             */
    KeyNRead     = 0;                            /* Clear the number of keys read                      */
    KeyDownTmr   = 0;
    KeyBufInIx   = 0;                            /* Key codes inserted at  the beginning of the buffer */
    KeyBufOutIx  = 0;                            /* Key codes removed from the beginning of the buffer */
    os_sem_init (KeySemPtr,0);                   /* Initialize the keyboard semaphore                  */
    KeyInitPort();                               /* Initialize I/O ports used in keyboard driver       */

    TIDKeySTask=os_tsk_create_user (KeyScanTask, KEY_SCAN_TASK_PRIO, &KeyScanTaskStk, sizeof(KeyScanTaskStk));
}
void KeyScanTask (void) __task{     出错位置
   
        U8 code;
        U8 CloseCnt;
        U8 OpenBit=0;                                                //初始化为0,只有松手后,才置1,关机只有1后有效
        U32 Buf;
        //增加关机检测功能
        FIO0DIR |= (1 << 0);                       //P0.0 初始化为输出
        FIO0SET = (1 << 0);                                        //上电强制拉高
        CloseCnt=0;
    for (;;) {
            //增加关机检测
                Buf=FIO2PIN;                                        //读IO口
                if((Buf&(1 << 13))==0){
                        if(CloseCnt<200) CloseCnt++;
                        if((CloseCnt>8)&&OpenBit){        //当大于8时,且不是开机按键未松手,给关机标志
                                CloseBit=1;
                        }                                                        //当大于10时,给关机标志
                }
                else {
                        CloseCnt=0;                                        //一松手,就清0
                        OpenBit=1;                                        //只有松手,才能关机
                }
        os_dly_wait (KEY_SCAN_TASK_DLY);                   /* Delay between keyboard scans             */
        switch (KeyScanState) {
            case KEY_STATE_UP:                             /* See if need to look for a key pressed    */
                 KeyDownTmr   = 0;                         /* Reset key down timer                     */
                                                                                                    //当没有键时,自动清0,相当于记录正在按下键的时间
                 if (KeyIsKeyDown()) {                     /* See if key is pressed                    */
                     KeyScanState = KEY_STATE_DEBOUNCE;    /* Next call we will have debounced the key */
                 }
                 break;

            case KEY_STATE_DEBOUNCE:                       /* Key pressed, get scan code and buffer    */
                 if (KeyIsKeyDown()) {                     /* See if key is pressed                    */
                     code              = KeyDecode();      /* Determine the key scan code              */
                     KeyBufIn(code);                       /* Input scan code in buffer                */
                     KeyRptStartDlyCtr = KEY_RPT_START_DLY;/* Start delay to auto-repeat function      */
                     KeyScanState      = KEY_STATE_RPT_START_DLY;
                 } else {
                     KeySelRow(KEY_ALL_ROWS);              /* Select all row                           */
                     KeyScanState      = KEY_STATE_UP;     /* Key was not pressed after all!           */
                 }
                 break;

            case KEY_STATE_RPT_START_DLY:
                 if (KeyIsKeyDown()) {                     /* See if key is still pressed              */
                     if (KeyRptStartDlyCtr > 0) {          /* See if we need to delay before auto rpt  */
                         KeyRptStartDlyCtr--;              /* Yes, decrement counter to start of rpt   */
                         if (KeyRptStartDlyCtr == 0) {     /* If delay to auto repeat is completed ... */
                             code         = KeyDecode();   /* Determine the key scan code              */
                             KeyBufIn(code);               /* Input scan code in buffer                */
                             KeyRptDlyCtr = KEY_RPT_DLY;   /* Load delay before next repeat            */
                             KeyScanState = KEY_STATE_RPT_DLY;
                         }
                     }
                 } else {
                     KeyScanState = KEY_STATE_DEBOUNCE;    /* Key was not pressed after all            */
                 }
                 break;

            case KEY_STATE_RPT_DLY:
                 if (KeyIsKeyDown()) {                     /* See if key is still pressed              */
                     if (KeyRptDlyCtr > 0) {               /* See if we need to wait before repeat key */
                         KeyRptDlyCtr--;                   /* Yes, dec. wait time to next key repeat   */
                         if (KeyRptDlyCtr == 0) {          /* See if it's time to repeat key           */
                             code         = KeyDecode();   /* Determine the key scan code              */
                             KeyBufIn(code);               /* Input scan code in buffer                */
                             KeyRptDlyCtr = KEY_RPT_DLY;   /* Reload delay counter before auto repeat  */
                         }
                     }
                 } else {
                     KeyScanState = KEY_STATE_DEBOUNCE;    /* Key was not pressed after all            */
                 }
                 break;
        }

    }

}

程序有点多,粘了部分出错的地方,可能是加RL的原因,本来已经是很老的程序了,调的还剩这句,大家法眼过一下
SRC\KEY.C(358): error:  #130: expected a "{"

相关帖子

沙发
hgjinwei| | 2010-7-18 09:22 | 只看该作者
在程序开始出加上
#define  __task
应该可以通过编译。

使用特权

评论回复
板凳
pipixiong999|  楼主 | 2010-7-19 16:23 | 只看该作者
本帖最后由 pipixiong999 于 2010-7-19 16:31 编辑

是KEIL的版本问题,而且感觉跟RTL.H和RTL.LIB.C两个文件有关,最近还在调,KEIL3.2版的还是编不过去,
错误为D:\Keil323\ARM\RV31\INC\RTX_lib.c(56): error:  #20: identifier "OS_TCB_SIZE" is undefined,
KEIL3.7的能编过,调的时候又卡在如下位置  
358: PAbt_Handler    B       PAbt_Handler
0x00000044  EAFFFFFE  B         0x00000044

使用特权

评论回复
地板
wangqy21ic| | 2010-7-24 23:23 | 只看该作者
2楼好像不对哦,加了就这个宏,就不是RL内核的任务了。

回lz,一般__task都是放在函数的最前面吧……
__task void KeyScanTask (void) {
    ...
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:多思者敏,善交者乐

0

主题

6

帖子

1

粉丝