Vjezba 6_4

Dependencies:   mbed

Committer:
imihalj
Date:
Thu Nov 10 17:57:01 2016 +0000
Revision:
5:94aa173f182c
Parent:
4:986fa54b04b5
Child:
6:ca9ae5ce232d
vjezba6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
imihalj 5:94aa173f182c 1 //*** main code
imihalj 0:c32036656bb4 2 int main()
imihalj 0:c32036656bb4 3 {
imihalj 5:94aa173f182c 4 timer1.start(); // start timer1 counting
imihalj 5:94aa173f182c 5 timer2.start(); // start timer2 counting
imihalj 4:986fa54b04b5 6 while(1) {
imihalj 5:94aa173f182c 7 if (timer1.read_ms()>=200) { // read time
imihalj 5:94aa173f182c 8 task1(); // call task1 function
imihalj 5:94aa173f182c 9 timer1.reset(); // reset timer
imihalj 5:94aa173f182c 10 }
imihalj 5:94aa173f182c 11 if (timer2.read_ms()>=1000) { // read time
imihalj 5:94aa173f182c 12 task2(); // call task2 function
imihalj 5:94aa173f182c 13 timer2.reset(); // reset timer
imihalj 4:986fa54b04b5 14 }
imihalj 4:986fa54b04b5 15 }
imihalj 5:94aa173f182c 16 }
imihalj 5:94aa173f182c 17 //*** task functions
imihalj 5:94aa173f182c 18 void task1(void)
imihalj 5:94aa173f182c 19 {
imihalj 5:94aa173f182c 20 output1=!output1; // toggle output1
imihalj 5:94aa173f182c 21 }
imihalj 5:94aa173f182c 22 void task2(void)
imihalj 5:94aa173f182c 23 {
imihalj 5:94aa173f182c 24 output2=!output2; // toggle output2
imihalj 0:c32036656bb4 25 }