EJEMPLO3

Dependencies:   mbed

Committer:
fabeltranm
Date:
Mon May 07 23:55:05 2018 +0000
Revision:
1:0f682b1c98ec
Parent:
0:a550aef65fac
ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fabeltranm 0:a550aef65fac 1 #include "mbed.h"
fabeltranm 0:a550aef65fac 2
fabeltranm 0:a550aef65fac 3
fabeltranm 0:a550aef65fac 4 Ticker tk1;
fabeltranm 0:a550aef65fac 5 Ticker tk2;
fabeltranm 0:a550aef65fac 6 DigitalOut output1(LED1); // digital output
fabeltranm 0:a550aef65fac 7 Serial serial(USBTX, USBRX);
fabeltranm 0:a550aef65fac 8
fabeltranm 0:a550aef65fac 9
fabeltranm 0:a550aef65fac 10 void task1(void); // task function prototype
fabeltranm 0:a550aef65fac 11 void task2(void); // task function prototype
fabeltranm 0:a550aef65fac 12
fabeltranm 0:a550aef65fac 13
fabeltranm 0:a550aef65fac 14
fabeltranm 0:a550aef65fac 15 //*** main code
fabeltranm 0:a550aef65fac 16
fabeltranm 0:a550aef65fac 17 void main() {
fabeltranm 0:a550aef65fac 18 output1=0;
fabeltranm 0:a550aef65fac 19 tk1.attach(&task1, 0.8);
fabeltranm 0:a550aef65fac 20 tk2.attach(&task2, 0.6);
fabeltranm 0:a550aef65fac 21 while(1) {
fabeltranm 0:a550aef65fac 22 wait_ms(2000);
fabeltranm 0:a550aef65fac 23 output1=!output1; // toggle output
fabeltranm 0:a550aef65fac 24 }
fabeltranm 0:a550aef65fac 25 }
fabeltranm 0:a550aef65fac 26 void task1(void){ // task function
fabeltranm 0:a550aef65fac 27
fabeltranm 0:a550aef65fac 28 serial.printf("hola soy task1\n");
fabeltranm 1:0f682b1c98ec 29 // wait_ms(300);
fabeltranm 0:a550aef65fac 30
fabeltranm 0:a550aef65fac 31
fabeltranm 0:a550aef65fac 32 }
fabeltranm 0:a550aef65fac 33
fabeltranm 0:a550aef65fac 34 void task2(void){ // task function
fabeltranm 0:a550aef65fac 35
fabeltranm 0:a550aef65fac 36 serial.printf("hola soy task2\n");
fabeltranm 1:0f682b1c98ec 37 //wait_ms(300);
fabeltranm 0:a550aef65fac 38
fabeltranm 0:a550aef65fac 39 }