Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API color_pixels mbed-src-nrf51822 nRF51822
Fork of BLE_LoopbackUART by
unified_driver/led.cpp
- Committer:
- yihui
- Date:
- 2014-11-06
- Revision:
- 9:84cb66d0375d
File content as of revision 9:84cb66d0375d:
#include "unified_driver.h" #include "mbed.h" int led_init(void *obj, void *params) { int pin = *(int *)params; *((PwmOut **)obj) = new PwmOut((PinName)pin); return 0; } int led_read(void *obj, void *data) { PwmOut *output = *(PwmOut **)obj; *(float *)data = output->read(); return 0; } int led_write(void *obj, void *data) { PwmOut *pwm = *(PwmOut **)obj; float pulse_width = *(float *)data; float period = *((float *)data + 1); pwm->write(pulse_width); if (0 != period) { pwm->period(period); } return 0; } int led_fini(void *obj) { PwmOut *ptr = *(PwmOut **)obj; delete ptr; return 0; } driver_t led_driver = { "led", 1, led_init, led_read, led_write, led_fini, };