This is a test program for http://mbed.org/forum/bugs-suggestions/topic/990/

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Mon Aug 16 11:25:35 2010 +0000
Child:
1:4cfa24bbc098
Commit message:

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Aug 16 11:25:35 2010 +0000
@@ -0,0 +1,63 @@
+/**
+ * Test program for a bug. (http://mbed.org/forum/bugs-suggestions/topic/990/)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "mbed.h"
+
+BusOut myled(LED4, LED3, LED2, LED1);
+Ticker tickerForLED;
+Ticker tickerForAnother;
+
+/**
+ * Tick function for toggle 4 LEDs.
+ */
+void tickfunc_led(void) {
+    myled = myled + 1;
+}
+
+/**
+ * Tick function for another ticker.
+ */
+void tickfunc_another(void) {
+    // Do nothing.
+}
+
+int main() {
+    int n = 0;
+    
+    /*
+     * Start my LED ticker.
+     */
+    tickerForLED.attach(&tickfunc_led, 0.2);    
+    
+    /*
+     * Wait 5 seconds.
+     */
+    wait(5);
+
+    /*
+     * Attach another ticker.
+     * Then the LED ticker will be stop.
+     */    
+    while (1) {
+        /*
+         * Check for this loop.
+         */
+        printf("n=%d\n", n++);
+
+        /*
+         * Change my another ticker.
+         */
+        tickerForAnother.attach_us(&tickfunc_another, 2 * 1000);
+        wait_ms(100);
+
+        tickerForAnother.attach_us(&tickfunc_another, 2 * 1000);
+        wait_ms(100);
+
+        tickerForAnother.attach_us(&tickfunc_another, 2 * 1000);
+        wait_ms(100);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Aug 16 11:25:35 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da