This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2630按键中断和轮询方式设置

Other Parts Discussed in Thread: CC2630, CC2530

1.  2630,默认设置为PIN_IRQ_NEGEDGE,这应该是中断模式吧?

2.我设置为PIN_IRQ_DIS,按下按键就识别不了了,请问是不是还有哪里需要设置?

3.我想实现的是按键为查询模式,低电平有效,但是设置为PIN_IRQ_DIS,按键无法检测到

4.PIN_BM_IRQ这个是什么模式?

Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,   
Board_KEY_UP | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
Board_KEY_DOWN | PIN_INPUT_EN | PIN_PULLUP |PIN_IRQ_NEGEDGE,

#define PIN_IRQ_DIS         (PIN_GEN|(0x0<<16)) ///< (*) Disable IRQ on pin
#define PIN_IRQ_NEGEDGE     (PIN_GEN|(0x5<<16)) ///< Enable IRQ on negative edge
#define PIN_IRQ_POSEDGE     (PIN_GEN|(0x6<<16)) ///< Enable IRQ on positive edge
#define PIN_IRQ_BOTHEDGES   (PIN_GEN|(0x7<<16)) ///< Enable IRQ on both edges
#define PIN_BM_IRQ          (0x7<<16)           ///< Bitmask for pin interrupt option

  • 1. 是的

    2. PIN_IRQ_DIS是不使能中断模式,你要用中断模式就不應該使用PIN_IRQ_DIS這個flag,如果是查询模式就要使用PIN_IRQ_DIS這個flag

    3. 按键設置为查询模式,你有定期去查詢按键腳位狀態嗎?

    4. PIN_BM_IRQ就是的中断模式設置暫存器用到的Bitmask

  • #define PIN_INV_INOUT (PIN_GEN|(1<<24)) ///< Logically invert input and output
    #define PIN_BM_INV_INOUT (1<<24) ///< Bitmask for input/output inversion option
    #define PIN_IRQ_DIS (PIN_GEN|(0x0<<16)) ///< (*) Disable IRQ on pin
    #define PIN_IRQ_NEGEDGE (PIN_GEN|(0x5<<16)) ///< Enable IRQ on negative edge
    #define PIN_IRQ_POSEDGE (PIN_GEN|(0x6<<16)) ///< Enable IRQ on positive edge
    #define PIN_IRQ_BOTHEDGES (PIN_GEN|(0x7<<16)) ///< Enable IRQ on both edges
    #define PIN_BM_IRQ (0x7<<16) ///< Bitmask for pin interrupt option

    释义见上文,PIN_IRQ_DIS是关闭中断请求,当然没反应了

    中断例程建议参考下TI RTOS for CC26XX中的pininterrupt
  • 查询模式,需要用户自己去定期检测管脚电平?这块协议栈没有做好?
    之前你好像说过2630协议栈默认的按键模式就查询模式,如果需要自己
    添加检测程序,需要加在协议栈的什么位置?
  • 按键设置为中断模式没有问题,但是怎么设置为查询模式?
    协议栈本身有没有做这一块?我自己设置的话要把定期读IO的程序放在协议栈哪里?
  • cc2530协议栈默认的按键模式才是查询模式 ,cc2630是中断模式,你可以開個定時event來做查询模式