slave2

Dependencies:   PinDetect dsp mbed-rtos mbed

main.cpp

Committer:
cpark308
Date:
2016-04-24
Revision:
0:7ee25b048596
Child:
1:caeb5792f292

File content as of revision 0:7ee25b048596:

#include "mbed.h"
#include "PinDetect.h"
#include "rtos.h"

DigitalOut myled(LED1);
DigitalOut myled2(LED2);
DigitalOut myled4(LED4);
AnalogOut outfunction(p18);
DigitalOut masterSignalOut(p26);
InterruptIn trigger(p25);
int counter;

Timer ti;

void analogScope(void const *args){
    counter = 0;
    myled = 0;
    while(1){
    //outfunction = (ti.read_us()%1000)*0.001;
    //myled= (((ti.read_ms())>>10)%1);
    outfunction = (counter%10)*0.1;
    counter++;
    myled = !myled;
    }
}
void sendinterrupt(void){
    masterSignalOut = 1;
}
void interruptrecv(void){
    ti.reset();
    myled4 = !myled4;
    counter = 0;
    masterSignalOut = 0;
}
int main() {
    ti.reset();
    myled2 = 0;
    myled4 = 0;
    masterSignalOut = 0;
    Thread threadanalog(analogScope);
    threadanalog.set_priority(osPriorityLow);
    trigger.rise(&interruptrecv);
    while(1) {
        myled2 = !myled2;
        Thread::wait(10000);
    }
}