The firmware of the Grove Node
Dependencies: BLE_API color_pixels mbed-src-nrf51822 nRF51822
Fork of BLE_LoopbackUART by
udriver/analog_sensor.cpp
- Committer:
- yihui
- Date:
- 2015-06-04
- Revision:
- 11:c0885b74a63a
- Parent:
- 10:f34ff4e47741
File content as of revision 11:c0885b74a63a:
#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, };