dfrobot
Dependencies: BLE_API mbed nRF51822
Dependents: BLE_UART_LCD_Batt_DevInfo
Fork of BLE_LoopbackUART by
Revision 9:7b3841a91548, committed 2014-10-31
- Comitter:
- jimaobian
- Date:
- Fri Oct 31 07:55:37 2014 +0000
- Parent:
- 8:5818566e1e8a
- Commit message:
- cup
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5818566e1e8a -r 7b3841a91548 main.cpp --- a/main.cpp Tue Sep 30 02:20:59 2014 +0000 +++ b/main.cpp Fri Oct 31 07:55:37 2014 +0000 @@ -19,7 +19,7 @@ #include "UARTService.h" -#define NEED_CONSOLE_OUTPUT 0 /* Set this if you need debug messages on the console; +#define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console; * it will have an impact on code-size and power consumption. */ #if NEED_CONSOLE_OUTPUT @@ -30,6 +30,8 @@ BLEDevice ble; DigitalOut led1(LED1); +DigitalOut led2(LED2); +Timer timer; UARTService *uartServicePtr; @@ -56,6 +58,10 @@ int main(void) { + + + timer.start(); + led1 = 1; Ticker ticker; ticker.attach(periodicCallback, 1); @@ -79,7 +85,39 @@ UARTService uartService(ble); uartServicePtr = &uartService; + while (true) { + static unsigned long led2timer=timer.read_ms(); + + if((unsigned long)timer.read_ms()-led2timer>1000UL) + { + led2timer=timer.read_ms(); + led2=!led2; + } + + + ble.waitForEvent(); } } + +//// Count the time to toggle a LED +// +//#include "mbed.h" +// +//Timer timer; +//DigitalOut led(LED1); +//int begin, end; +// +//int main() { +// timer.start(); +// +// while(true) +// { +//// begin = timer.read_ms(); +// led = !led; +// wait(1); +//// end = timer.read_ms(); +//// printf("%d us\r\n", end - begin); +// } +//}
diff -r 5818566e1e8a -r 7b3841a91548 mbed.bld --- a/mbed.bld Tue Sep 30 02:20:59 2014 +0000 +++ b/mbed.bld Fri Oct 31 07:55:37 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file