我正在处理一项任务,即读取焊接到cc2530电池板上GPIO引脚的传感器产生的值。三种不同类型的传感器焊接在其上;温度(模拟,输出电压),光(模拟,输出频率)和气压计(模拟)。
我已经能够成功读取温度并正确显示数字(示例在contiki git repo中提供)但我无法手动配置GPIO引脚以从光电二极管读取。
请帮助
P0SEL &= ~0x04; /* Set as GPIO */
P0DIR &= ~0x04; /* Set as Input */
P0INP |= 0x04; /* Set as tri-state */
答案 0 :(得分:1)
找到它。
这里是一个从cc2530上的引脚读取的示例代码:
static void ReadLightSensor(void)
{
//select pin in hex form
P0SEL &= ~0x10; /* Set pin (sample) as GPIO */
P0DIR &= ~0x10; /* Set pin as input*/
P0INP |= 0x10; /* Set as tri-state*/
APCFG |= 0x10; /* configure ADC on pin*/
ADCCON3 = 0x34; /*This represents the paramters passed into ADCCON3*/
while (!ADCIF);
ADCIF = 0;
tv = ADCL;
tv |= (((unsigned short) ADCH) << 8);
tv >>= 4 ;
lv = tv;
PRINTF("Pin reading = 0x%04x\n\r", lv);