Example of using Ticker or Timeout with libmDot Ticker did not work with the mDot instantiated

Fork of Ticker_HelloWorld by mbed_example

Committer:
jreiss
Date:
Wed Feb 28 13:47:41 2018 +0000
Revision:
6:f9d35ed0d0d8
Parent:
5:36b17c45c560
Ticker and Timeout work with mDot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 2:87f26931d8d1 1 /* mbed Example Program
mbedAustin 2:87f26931d8d1 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 2:87f26931d8d1 3 *
mbedAustin 2:87f26931d8d1 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 2:87f26931d8d1 5 * you may not use this file except in compliance with the License.
mbedAustin 2:87f26931d8d1 6 * You may obtain a copy of the License at
mbedAustin 2:87f26931d8d1 7 *
mbedAustin 2:87f26931d8d1 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 2:87f26931d8d1 9 *
mbedAustin 2:87f26931d8d1 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 2:87f26931d8d1 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 2:87f26931d8d1 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 2:87f26931d8d1 13 * See the License for the specific language governing permissions and
mbedAustin 2:87f26931d8d1 14 * limitations under the License.
mbedAustin 2:87f26931d8d1 15 */
mbed_official 0:5014bf742e9b 16 #include "mbed.h"
jreiss 5:36b17c45c560 17 #include "rtos.h"
jreiss 5:36b17c45c560 18 #include "mDot.h"
jreiss 5:36b17c45c560 19 #include "ChannelPlans.h"
mbed_official 0:5014bf742e9b 20
jreiss 5:36b17c45c560 21 DigitalOut led1(LED2);
jreiss 5:36b17c45c560 22 DigitalOut led2(XBEE_RSSI);
jreiss 5:36b17c45c560 23 void flip();
jreiss 5:36b17c45c560 24
jreiss 5:36b17c45c560 25
jreiss 5:36b17c45c560 26 //RtosTimer flipper(&flip);
jreiss 5:36b17c45c560 27 //
jreiss 5:36b17c45c560 28 //void flip() {
jreiss 5:36b17c45c560 29 // led2 = !led2;
jreiss 5:36b17c45c560 30 // flipper.start(2000);
jreiss 5:36b17c45c560 31 //}
jreiss 5:36b17c45c560 32 //
jreiss 5:36b17c45c560 33
jreiss 6:f9d35ed0d0d8 34 Ticker flipper;
jreiss 6:f9d35ed0d0d8 35 // Timeout flipper;
mbed_official 0:5014bf742e9b 36
mbed_official 0:5014bf742e9b 37 void flip() {
jreiss 5:36b17c45c560 38 led2 = !led2;
mbed_official 0:5014bf742e9b 39 }
mbed_official 0:5014bf742e9b 40
jreiss 5:36b17c45c560 41
mbed_official 0:5014bf742e9b 42 int main() {
jreiss 5:36b17c45c560 43
jreiss 5:36b17c45c560 44 mDot* dot;
jreiss 5:36b17c45c560 45
jreiss 5:36b17c45c560 46 lora::ChannelPlan* plan = new lora::ChannelPlan_US915();
jreiss 5:36b17c45c560 47
jreiss 5:36b17c45c560 48 // get a mDot handle
jreiss 5:36b17c45c560 49 dot = mDot::getInstance(plan);
jreiss 5:36b17c45c560 50
jreiss 5:36b17c45c560 51 dot->setJoinMode(mDot::MANUAL);
jreiss 5:36b17c45c560 52
jreiss 5:36b17c45c560 53 led2 = 1;
jreiss 5:36b17c45c560 54 // flipper.start(2000);
jreiss 5:36b17c45c560 55
jreiss 5:36b17c45c560 56 flipper.attach(&flip, 2.0); // setup flipper to call flip after 2 seconds
mbed_official 0:5014bf742e9b 57
mbed_official 0:5014bf742e9b 58 // spin in a main loop. flipper will interrupt it to call flip
mbed_official 0:5014bf742e9b 59 while(1) {
mbed_official 0:5014bf742e9b 60 led1 = !led1;
mbed_official 0:5014bf742e9b 61 wait(0.2);
mbed_official 0:5014bf742e9b 62 }
mbed_official 0:5014bf742e9b 63 }