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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/udriver/time_sensor.cpp	Thu Jun 04 09:34:13 2015 +0000
@@ -0,0 +1,56 @@
+
+#include "udriver.h"
+#include "mbed.h"
+
+uint8_t time_sensor_second = 0;
+
+
+void time_sensor_tick(void)
+{
+    time_sensor_second++;
+    if (time_sensor_second >= 60) {
+        time_sensor_second = 0;
+    }
+}
+
+int time_sensor_init(void *obj, void *params)
+{
+    Ticker *ticker = new Ticker();
+    *((Ticker **)obj) = ticker;
+    
+    ticker->attach(time_sensor_tick, 1);
+    
+    return 0;
+}
+    
+
+int time_sensor_read(void *obj, void *data)
+{
+    *(float *)data = time_sensor_second;
+    
+    return 0;
+}
+
+int time_sensor_write(void *obj, void *data)
+{
+    return 0;
+}
+
+int time_sensor_fini(void *obj)
+{
+    Ticker *ptr = *(Ticker **)obj;
+    ptr->detach();
+    delete ptr;
+    
+    return 0;
+}
+
+driver_t time_sensor_driver = 
+{
+    .init  = time_sensor_init,
+    .read  = time_sensor_read,
+    .write = time_sensor_write,
+    .fini  = time_sensor_fini,
+    
+    .d     = 1,
+};