参考2012. MESH 网络。
注意: 我们选用的是中断的方式,定义这个函数ISR_KEYINTERRUPT。
1、按键初始化,
主要配置 按键管教,中断模式(上升沿,下降压),中断标志位。
#define HAL_KEY_SW_6_PORT P0
#define HAL_KEY_SW_6_BIT BV(4)
#define HAL_KEY_SW_6_SEL P0SEL
#define HAL_KEY_SW_6_DIR P0DIR
/* edge interrupt */
#define HAL_KEY_SW_6_EDGEBIT BV(4)
#define HAL_KEY_SW_6_EDGE HAL_KEY_RISING_EDGE
/* SW_6 interrupts */
#define HAL_KEY_SW_6_IEN IEN1 /* CPU interrupt mask register */
#define HAL_KEY_SW_6_IENBIT BV(5) /* Mask bit for all of Port_0 */
#define HAL_KEY_SW_6_ICTL P0IEN /* Port Interrupt Control register */
#define HAL_KEY_SW_6_ICTLBIT BV(4) /* P0IEN - P0.1 enable/disable bit */这个注意设置中断 标志位,我设置的是P0.4
#define HAL_KEY_SW_6_PXIFG P0IFG /* Interrupt flag at source */
2、进入中断,
清楚中断标志位。这个操作。同