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: FatFileSystem mbed
Fork of BTstack by
Diff: led_counter.cpp
- Revision:
- 0:1ed23ab1345f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/led_counter.cpp Tue Jun 26 14:27:45 2012 +0000
@@ -0,0 +1,56 @@
+#if 0
+//*****************************************************************************
+//
+// led_counter demo - uses the BTstack run loop to blink an LED
+//
+//*****************************************************************************
+#include "mbed.h"
+#include <btstack/run_loop.h>
+
+Serial pc(USBTX, USBRX);
+DigitalOut led1(LED1), led2(LED2);
+
+#define HEARTBEAT_PERIOD_MS 1000
+
+static void heartbeat_handler(struct timer *ts){
+
+ // increment counter
+ static int counter = 0;
+ char lineBuffer[30];
+ sprintf(lineBuffer, "BTstack counter %04u\n\r", ++counter);
+ printf(lineBuffer);
+
+ // toggle LED
+ led2 = !led2;
+
+ run_loop_set_timer(ts, HEARTBEAT_PERIOD_MS);
+ run_loop_add_timer(ts);
+}
+
+// main
+int main(void)
+{
+ pc.baud(921600);
+ printf("%s\n", __FILE__);
+
+ // init LEDs
+ led1 = led2 = 1;
+
+ /// GET STARTED with BTstack ///
+ run_loop_init(RUN_LOOP_EMBEDDED);
+
+ // set one-shot timer
+ timer_source_t heartbeat;
+ heartbeat.process = &heartbeat_handler;
+ run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
+ run_loop_add_timer(&heartbeat);
+
+ printf("Run...\n\r");
+
+ // go!
+ run_loop_execute();
+
+ // happy compiler!
+ return 0;
+}
+#endif
\ No newline at end of file
