在simpleBLEPeripheral 示例工程中,是以P0.1口作为按键,按键后会广播,现在想把io口改为p1.4口作为按键脚可以吗?怎么改呀,请各位大神指点
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.
在simpleBLEPeripheral 示例工程中,是以P0.1口作为按键,按键后会广播,现在想把io口改为p1.4口作为按键脚可以吗?怎么改呀,请各位大神指点
我修改了 hal_key.c 里的关于p0.1的部分, 还是不行的,代码如下
/* CPU port interrupt */
#define HAL_KEY_CPU_PORT_0_IF P0IF //改成了 P1IF
#define HAL_KEY_CPU_PORT_2_IF P2IF
#if defined ( CC2540_MINIDK )
/* SW_1 is at P0.0 */
#define HAL_KEY_SW_1_PORT P0
#define HAL_KEY_SW_1_BIT BV(0)
#define HAL_KEY_SW_1_SEL P0SEL
#define HAL_KEY_SW_1_DIR P0DIR
/* SW_2 is at P0.1 */
#define HAL_KEY_SW_2_PORT P0 //改成了 P1
#define HAL_KEY_SW_2_BIT BV(1) //改成了BV(4)
#define HAL_KEY_SW_2_SEL P0SEL //改成了 P1SEL
#define HAL_KEY_SW_2_DIR P0DIR //改成了 P1DIR
#define HAL_KEY_SW_1_IEN IEN1 /* CPU interrupt mask register */ //改成了 IEN2
#define HAL_KEY_SW_1_ICTL P0IEN /* Port Interrupt Control register */ //改成了 P1IEN
#define HAL_KEY_SW_1_ICTLBIT BV(0) /* P0IEN - P0.0 enable/disable bit */
#define HAL_KEY_SW_1_IENBIT BV(5) /* Mask bit for all of Port_0 */
#define HAL_KEY_SW_1_PXIFG P0IFG /* Interrupt flag at source */ //改成了 P1IENFG
#define HAL_KEY_SW_2_ICTL P0IEN /* Port Interrupt Control register */ //改成了 P1IEN
#define HAL_KEY_SW_2_ICTLBIT BV(1) /* P0IEN - P0.1 enable/disable bit */ //改成了BV(4)
#define HAL_KEY_SW_2_IENBIT BV(5) /* Mask bit for all of Port_0 */
#define HAL_KEY_SW_2_PXIFG P0IFG /* Interrupt flag at source */ //改成了 P1IENFG
还有其它地方需要改吗? 或者你们有没有相关资料的,我还不是很清楚这些配置要怎么改?谢谢回答
/* S2 is at P1.4 */
#define HAL_KEY_SW_2_PORT P1
#define HAL_KEY_SW_2_BIT BV(4)
#define HAL_KEY_SW_2_SEL P1SEL
#define HAL_KEY_SW_2_DIR P1DIR
#define HAL_KEY_SW_2_IEN IEN2 /* CPU interrupt mask register */
#define HAL_KEY_SW_2_ICTL P1IEN /* Port Interrupt Control register */
#define HAL_KEY_SW_2_ICTLBIT BV(4) /* P0IEN - P1.4 enable/disable bit */
#define HAL_KEY_SW_2_IENBIT BV(4) /* Mask bit for all of Port_1 */
#define HAL_KEY_SW_2_PXIFG P1IFG /* Interrupt flag at source */
#define HAL_KEY_SW_2_EDGEBIT BV(2)
按照如上更改,你只改一个按键,不需要对HAL_KEY_SW1部分进行修改。#define HAL_KEY_CPU_PORT_0_IF P0IF 这句话是定位cpu的P0口中断的,不需要修改