CC2640中,矩阵键盘问题
时间:10-02
整理:3721RD
点击:
使用2640的片子,
首先我开启了矩阵键盘读回行相应IO口的中断:
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_ROW0 | PIN_IRQ_BOTHEDGES); PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_ROW1 | PIN_IRQ_BOTHEDGES); PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_ROW2 | PIN_IRQ_BOTHEDGES); PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_ROW3 | PIN_IRQ_BOTHEDGES);
然后,在Board_key.c中的中断处理函数:Board_keyCallback中添加获取健值的代码,使用单列拉高的方式,
COL0 { PIN_setOutputValue(hKeyPins, Board_KEY_COL1, 1); PIN_setOutputValue(hKeyPins, Board_KEY_COL2, 1); PIN_setOutputValue(hKeyPins, Board_KEY_COL0, 0); //拉低0列; PAW_Delay_ms(25); if(PIN_getInputValue(Board_KEY_ROW1) == 0) { keysPressed |= KEY_UP; } if(PIN_getInputValue(Board_KEY_ROW2) == 0) { keysPressed |= KEY_LEFT; } if(PIN_getInputValue(Board_KEY_ROW3) == 0) { keysPressed |= KEY_DOWN; } } //COL1 { PIN_setOutputValue(hKeyPins, Board_KEY_COL0, 1); PIN_setOutputValue(hKeyPins, Board_KEY_COL2, 1); PIN_setOutputValue(hKeyPins, Board_KEY_COL1, 0); //拉低0列; PAW_Delay_ms(25); if(PIN_getInputValue(Board_KEY_ROW2) == 0) { keysPressed |= KEY_SELECT; } if(PIN_getInputValue(Board_KEY_ROW3) == 0) { keysPressed |= KEY_RIGHT; } } //COL2 { PIN_setOutputValue(hKeyPins, Board_KEY_COL0, 1); PIN_setOutputValue(hKeyPins, Board_KEY_COL1, 1); PIN_setOutputValue(hKeyPins, Board_KEY_COL2, 0); PAW_Delay_ms(25); if(PIN_getInputValue(Board_KEY_ROW1) == 0) { keysPressed |= KEY_MUTE; } if(PIN_getInputValue(Board_KEY_ROW2) == 0) { keysPressed |= KEY_VOLUME_UP; } if(PIN_getInputValue(Board_KEY_ROW3) == 0) { keysPressed |= KEY_VOLUME_DOWN; }
但是 并没有成功。
请问2640的按键中断处理函数中是否能添加引脚处理?
可以,按键本身就是中断输入判断
hi,
我在Board_keyCallback;函数中开启了一个SWI定时器:Util_constructClock(&keyReadClock, Board_keyReadHandler,100, 0, false, 0);
static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId) { keysPressed = 0; Util_startClock(&keyReadClock); if(value == 0x01) keysPressed |= KEY_UP; if(value == 0x02) keysPressed |= KEY_LEFT; if(value == 0x03) keysPressed |= KEY_DOWN; if(value == 0x12) keysPressed |= KEY_SELECT; if(value == 0x13) keysPressed |= KEY_RIGHT; if(value == 0x21) keysPressed |= KEY_DOWN; if(value == 0x22) keysPressed |= KEY_RIGHT; if(value == 0x23) keysPressed |= KEY_DOWN; Util_startClock(&keyChangeClock); }
之后在Board_keyReadHandler;函数中使用轮询的方式读取矩阵键值:
static void Board_keyReadHandler(UArg a0) { value = keyread(); }
现在问题是,只有第一次能发送健值;而之后都不会进入中断处理函数static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId)了,
请问是什么原因呢?