[英]Read from GPIO Pin on CC2530
I am working on a task to read in the values produced from sensors soldered to the GPIO pins on the cc2530 battery board. 我正在执行一项任务,以读取焊接到cc2530电池板上GPIO引脚的传感器产生的值。 Three different type of sensors are soldered onto it ;
三种不同类型的传感器焊接在上面; temperature (analogue, out voltage), Light(analogue, out frequency) and barometer(analogue).
温度(模拟,输出电压),光(模拟,输出频率)和气压计(模拟)。
I have been able to successfully read the temperature and display the figures correctly (the example was provided in the contiki git repo) but i am unable to manually configure the GPIO pins to read from the photodiode. 我已经能够成功读取温度并正确显示数字(该示例在contiki git repo中提供),但是我无法手动配置GPIO引脚以从光电二极管读取。
Any help please 任何帮助请
P0SEL &= ~0x04; /* Set as GPIO */
P0DIR &= ~0x04; /* Set as Input */
P0INP |= 0x04; /* Set as tri-state */
Found it. 找到了。
Here a sample code to read from pin on cc2530 : 这是从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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.