X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=inline;f=server%2Fsensor.c;h=8e4773f1bd5c184b9233edb3d9d6719877575750;hb=b53d860c11d5a56b1fe929581f5c5a537b4cba91;hp=98896e8b44aaac34002fefdd6eb88081b3a22921;hpb=da26b105275a40e6947b58d1786bc73378c7c233;p=matches%2FMCTX3420.git diff --git a/server/sensor.c b/server/sensor.c index 98896e8..8e4773f 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -45,13 +45,13 @@ void Sensor_Init() Data_Init(&(g_sensors[i].data_file)); } - // Get the ADCs - ADC_Export(); + // Get the required ADCs + ADC_Export(0); // GPIO1_28 used as a pulse for sampling - GPIO_Export(GPIO1_28); + //GPIO_Export(GPIO1_28); // GPIO0_30 toggled during sampling - GPIO_Export(GPIO0_30); + //GPIO_Export(GPIO0_30); } /** @@ -175,16 +175,19 @@ bool Sensor_Read(Sensor * s, DataPoint * d) // Read value based on Sensor Id switch (s->id) { - case ANALOG_REALTEST: + case 2: { static bool set = false; - - GPIO_Set(GPIO0_30, true); - d->value = 0;//(double)ADC_Read(ADC0); //ADC #0 on the Beaglebone + int raw_adc = 0; + //GPIO_Set(GPIO0_30, true); + ADC_Read(ADC0, &raw_adc); + d->value = (double)raw_adc; //ADC #0 on the Beaglebone //Log(LOGDEBUG, "Got value %f from ADC0", d->value); - GPIO_Set(GPIO0_30, false); + //GPIO_Set(GPIO0_30, false); set = !set; - GPIO_Set(GPIO1_28, set); + //GPIO_Set(GPIO1_28, set); + + usleep(100000); break; } @@ -249,6 +252,11 @@ bool Sensor_Read(Sensor * s, DataPoint * d) s->newest_data.time_stamp = d->time_stamp; s->newest_data.value = d->value; } + +#ifdef _BBB + //Not all cases have usleep, easiest here. + usleep(1000000); +#endif return result; }