A ticker used to generate a periodic timer interrupt

Dependencies:   mbed

Fork of Timeout_HelloWorld by mbed official

Committer:
mbedAustin
Date:
Fri Mar 27 20:18:23 2015 +0000
Revision:
3:50216cc75b4a
Parent:
0:8a555873b7d3
Added license to main.c file.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 3:50216cc75b4a 1 /* mbed Example Program
mbedAustin 3:50216cc75b4a 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 3:50216cc75b4a 3 *
mbedAustin 3:50216cc75b4a 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 3:50216cc75b4a 5 * you may not use this file except in compliance with the License.
mbedAustin 3:50216cc75b4a 6 * You may obtain a copy of the License at
mbedAustin 3:50216cc75b4a 7 *
mbedAustin 3:50216cc75b4a 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 3:50216cc75b4a 9 *
mbedAustin 3:50216cc75b4a 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 3:50216cc75b4a 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 3:50216cc75b4a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 3:50216cc75b4a 13 * See the License for the specific language governing permissions and
mbedAustin 3:50216cc75b4a 14 * limitations under the License.
mbedAustin 3:50216cc75b4a 15 */
mbed_official 0:8a555873b7d3 16 #include "mbed.h"
mbed_official 0:8a555873b7d3 17
mbed_official 0:8a555873b7d3 18 Timeout flipper;
mbed_official 0:8a555873b7d3 19 DigitalOut led1(LED1);
mbed_official 0:8a555873b7d3 20 DigitalOut led2(LED2);
mbed_official 0:8a555873b7d3 21
mbed_official 0:8a555873b7d3 22 void flip() {
mbed_official 0:8a555873b7d3 23 led2 = !led2;
mbed_official 0:8a555873b7d3 24 }
mbed_official 0:8a555873b7d3 25
mbed_official 0:8a555873b7d3 26 int main() {
mbed_official 0:8a555873b7d3 27 led2 = 1;
mbed_official 0:8a555873b7d3 28 flipper.attach(&flip, 2.0); // setup flipper to call flip after 2 seconds
mbed_official 0:8a555873b7d3 29
mbed_official 0:8a555873b7d3 30 // spin in a main loop. flipper will interrupt it to call flip
mbed_official 0:8a555873b7d3 31 while(1) {
mbed_official 0:8a555873b7d3 32 led1 = !led1;
mbed_official 0:8a555873b7d3 33 wait(0.2);
mbed_official 0:8a555873b7d3 34 }
mbed_official 0:8a555873b7d3 35 }