static void zclSampleLight_HandleKeys( byte shift, byte keys ) {if ( keys & HAL_KEY_SW_1 ){}if ( keys & HAL_KEY_SW_2 ){}if ( keys & HAL_KEY_SW_3 ){}if ( keys & HAL_KEY_SW_4 ){}if ( shift && ( keys & HAL_KEY_SW_5 ) ){}else if ( keys & HAL_KEY_SW_5 ){} }
user5367314:
想基于zstack开关灯的例子做,CC2530的,通过检测2530某几个IO的输入电平,分析后再IO输出,
考虑到IO引脚可能被复用了,我们准备把按键的IO用作输入,LED的IO用作输出,
可是查了半天也没看出来按键和LED连到哪个IO,请问在哪里查找?hal_board_cfg.h里面没有定义
1.HAL_KEY_SW_1到5可以用作IO去检测外部输入电平的高低吗?读输入IO的电平用哪个函数?
2.HAL_LED_1到4是否可以用作输出高低电平?
Susan Yang:
/* 1 - Green */ #define LED1_BVBV(0) #define LED1_SBITP1_0 #define LED1_DDRP1DIR #define LED1_POLARITYACTIVE_HIGH#if defined (HAL_BOARD_CC2530EB_REV17)/* 2 - Red */#define LED2_BVBV(1)#define LED2_SBITP1_1#define LED2_DDRP1DIR#define LED2_POLARITYACTIVE_HIGH/* 3 - Yellow */#define LED3_BVBV(4)#define LED3_SBITP1_4#define LED3_DDRP1DIR#define LED3_POLARITYACTIVE_HIGH #endif/* ------------------------------------------------------------------------------------------------*Push Button Configuration* ------------------------------------------------------------------------------------------------*/#define ACTIVE_LOW! #define ACTIVE_HIGH!!/* double negation forces result to be '1' *//* S1 */ #define PUSH1_BVBV(1) #define PUSH1_SBITP0_1#if defined (HAL_BOARD_CC2530EB_REV17)#define PUSH1_POLARITYACTIVE_HIGH #elif defined (HAL_BOARD_CC2530EB_REV13)#define PUSH1_POLARITYACTIVE_LOW #else#error Unknown Board Indentifier #endif/* Joystick Center Press */ #define PUSH2_BVBV(0) #define PUSH2_SBITP2_0 #define PUSH2_POLARITYACTIVE_HIGH上述程序中说明了LED和按键占用的IO,您可以看一下
user5367314:
回复 Susan Yang:
谢谢,那个我看了,总共是3个LED和2个按键,但是
HAL_KEY_SW_1到HAL_KEY_SW_5总共5个按键,IO分配的非别是?
HAL_LED_1 到HAL_LED_14总共4个LED,对应的IO分别是?
YiKai Chen:
1. 按键的程序在hal_key.c
2. LED IO引脚就是定義在hal_board_cfg.h
YiKai Chen:
sw1-4是透過ADC去讀SmartRF05EB上的搖桿值來判定,SW5沒有對應,具體你可以去參考hal_key.c