The firmware of the Grove Node

Dependencies:   BLE_API color_pixels mbed-src-nrf51822 nRF51822

Fork of BLE_LoopbackUART by Bluetooth Low Energy

Revision:
10:f34ff4e47741
diff -r 84cb66d0375d -r f34ff4e47741 udriver/analog_sensor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/udriver/analog_sensor.cpp	Thu Jun 04 09:34:13 2015 +0000
@@ -0,0 +1,45 @@
+
+#include "udriver.h"
+#include "mbed.h"
+
+int analog_sensor_init(void *obj, void *params)
+{
+    int pin = *(int *)params;
+    AnalogIn *probe = new AnalogIn((PinName)pin);
+    *((AnalogIn **)obj) = probe;
+    
+    return 0;
+}
+    
+
+int analog_sensor_read(void *obj, void *data)
+{
+    AnalogIn *probe = *(AnalogIn **)obj;
+    
+    *(float *)data = probe->read() * 100;
+    
+    return 0;
+}
+
+int analog_sensor_write(void *obj, void *data)
+{
+    return 0;
+}
+
+int analog_sensor_fini(void *obj)
+{
+    AnalogIn *ptr = *(AnalogIn **)obj;
+    delete ptr;
+    
+    return 0;
+}
+
+driver_t analog_sensor_driver = 
+{
+    .init  = analog_sensor_init,
+    .read  = analog_sensor_read,
+    .write = analog_sensor_write,
+    .fini  = analog_sensor_fini,
+    
+    .d     = 1,
+};