Applied engineering Team / Mbed 2 deprecated VT2_Ivana_Mihalj

Dependencies:   mbed

Committer:
imihalj
Date:
Thu Nov 10 18:00:28 2016 +0000
Revision:
6:ca9ae5ce232d
Parent:
5:94aa173f182c
Child:
7:c56b212b084e
vjezba_6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
imihalj 6:ca9ae5ce232d 1 #include "mbed.h"
imihalj 6:ca9ae5ce232d 2 Timer timer1; // define timer object
imihalj 6:ca9ae5ce232d 3 Timer timer2; // define timer object
imihalj 6:ca9ae5ce232d 4 DigitalOut output1(p5); // digital output
imihalj 6:ca9ae5ce232d 5 DigitalOut output2(p6); // digital output
imihalj 6:ca9ae5ce232d 6 void task1(void); // task function prototype
imihalj 6:ca9ae5ce232d 7 void task2(void); // task function prototype
imihalj 0:c32036656bb4 8 int main()
imihalj 0:c32036656bb4 9 {
imihalj 5:94aa173f182c 10 timer1.start(); // start timer1 counting
imihalj 5:94aa173f182c 11 timer2.start(); // start timer2 counting
imihalj 4:986fa54b04b5 12 while(1) {
imihalj 5:94aa173f182c 13 if (timer1.read_ms()>=200) { // read time
imihalj 5:94aa173f182c 14 task1(); // call task1 function
imihalj 5:94aa173f182c 15 timer1.reset(); // reset timer
imihalj 5:94aa173f182c 16 }
imihalj 5:94aa173f182c 17 if (timer2.read_ms()>=1000) { // read time
imihalj 5:94aa173f182c 18 task2(); // call task2 function
imihalj 5:94aa173f182c 19 timer2.reset(); // reset timer
imihalj 4:986fa54b04b5 20 }
imihalj 4:986fa54b04b5 21 }
imihalj 5:94aa173f182c 22 }
imihalj 5:94aa173f182c 23 //*** task functions
imihalj 5:94aa173f182c 24 void task1(void)
imihalj 5:94aa173f182c 25 {
imihalj 5:94aa173f182c 26 output1=!output1; // toggle output1
imihalj 5:94aa173f182c 27 }
imihalj 5:94aa173f182c 28 void task2(void)
imihalj 5:94aa173f182c 29 {
imihalj 5:94aa173f182c 30 output2=!output2; // toggle output2
imihalj 0:c32036656bb4 31 }