From: Jeremy Tan Date: Fri, 27 Sep 2013 01:17:37 +0000 (+0800) Subject: Interops with non-BBB platforms X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=10a0d0813cab99327bcb7f7fcb0008c783cfc685;p=matches%2FMCTX3420.git Interops with non-BBB platforms --- diff --git a/server/bbb_pin.c b/server/bbb_pin.c index 373bbac..5fb7874 100644 --- a/server/bbb_pin.c +++ b/server/bbb_pin.c @@ -4,6 +4,7 @@ * THIS CODE IS NOT THREADSAFE */ +#define _BBB_PIN_SRC #include "bbb_pin.h" #include diff --git a/server/bbb_pin.h b/server/bbb_pin.h index ef8e1be..ce91e5a 100644 --- a/server/bbb_pin.h +++ b/server/bbb_pin.h @@ -10,6 +10,7 @@ #include "bbb_pin_defines.h" +#if defined(_BBB) || defined(_BBB_PIN_SRC) // Initialise / Deinitialise functions extern void GPIO_Export(int pin); extern void GPIO_Unexport(int pin); @@ -28,8 +29,27 @@ extern int ADC_Read(int pin); extern void PWM_Set(int pin, bool polarity, long period, long duty); // period and duty are in ns extern void PWM_Stop(int pin); +#else +//Empty defines so it compiles on any platform that's not the BBB +#define GPIO_Export(pin) +#define GPIO_Unexport(pin) +#define PWM_Export(pin) +#define PWM_Unexport(pin) +#define ADC_Export(pin) +#define ADC_Unexport(pin) + +#define GPIO_Read(pin) 0 +#define GPIO_Set(pin, value) + +#define ADC_Read(pin) 0 + +#define PWM_Set(pin, polarity, period, duty) +#define PWM_Stop(Pin) + + +#endif //_BBB #endif //_BBB_PIN_H diff --git a/server/common.h b/server/common.h index 43bb8bd..0092598 100644 --- a/server/common.h +++ b/server/common.h @@ -10,6 +10,11 @@ #define _BSD_SOURCE #define _XOPEN_SOURCE 600 +/** Determine if we're running on the BBB **/ +#ifdef __arm__ +#define _BBB +#endif + /** The current API version **/ #define API_VERSION 0 diff --git a/server/run.sh b/server/run.sh index c3e134c..98002e9 100755 Binary files a/server/run.sh and b/server/run.sh differ diff --git a/server/sensor.c b/server/sensor.c index 63e69d8..c3444bf 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -251,6 +251,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; }