Thomas SOETE / Mbed 2 deprecated SimpleTimer

Dependencies:   mbed SimpleLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "leds.h"
00003 #include "timers.h"
00004 
00005 TIMER0_INTERRUPT_HANDLER(void)
00006 {
00007     TIMER0_CLEAR_INTERRUPT(MR0_INT);
00008     static int i = 0;
00009     i++;
00010     if(i%2)
00011         LEDS_SET(LED1);
00012     else
00013         LEDS_SET(LED2);
00014 }
00015 
00016 int main() {
00017     LEDS_INIT();
00018     TIMER0_INIT();
00019     TIMER0_SETPCLK(CCLK);
00020     TIMER0_SETPRESCALE(96000); // 1ms
00021     TIMER0_SETMATCH(0, 100);
00022     TIMER0_SETMATCHCONTROL(0, MATCH_RESET | MATCH_INTERRUPT); // Reset and Interrupt each 100ms
00023     TIMER0_ENABLE_INTERRUPT();
00024     TIMER0_START();
00025     while (1);
00026 }