Shinichiro Nakamura
/
TestProgramForBugTopic990
This is a test program for http://mbed.org/forum/bugs-suggestions/topic/990/
Diff: main.cpp
- Revision:
- 0:3eb38701225c
- Child:
- 1:4cfa24bbc098
--- /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); + } +}