![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
slave2
Dependencies: PinDetect dsp mbed-rtos mbed
main.cpp@0:7ee25b048596, 2016-04-24 (annotated)
- Committer:
- cpark308
- Date:
- Sun Apr 24 17:37:33 2016 +0000
- Revision:
- 0:7ee25b048596
- Child:
- 1:caeb5792f292
slave code using old method
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cpark308 | 0:7ee25b048596 | 1 | #include "mbed.h" |
cpark308 | 0:7ee25b048596 | 2 | #include "PinDetect.h" |
cpark308 | 0:7ee25b048596 | 3 | #include "rtos.h" |
cpark308 | 0:7ee25b048596 | 4 | |
cpark308 | 0:7ee25b048596 | 5 | DigitalOut myled(LED1); |
cpark308 | 0:7ee25b048596 | 6 | DigitalOut myled2(LED2); |
cpark308 | 0:7ee25b048596 | 7 | DigitalOut myled4(LED4); |
cpark308 | 0:7ee25b048596 | 8 | AnalogOut outfunction(p18); |
cpark308 | 0:7ee25b048596 | 9 | DigitalOut masterSignalOut(p26); |
cpark308 | 0:7ee25b048596 | 10 | InterruptIn trigger(p25); |
cpark308 | 0:7ee25b048596 | 11 | int counter; |
cpark308 | 0:7ee25b048596 | 12 | |
cpark308 | 0:7ee25b048596 | 13 | Timer ti; |
cpark308 | 0:7ee25b048596 | 14 | |
cpark308 | 0:7ee25b048596 | 15 | void analogScope(void const *args){ |
cpark308 | 0:7ee25b048596 | 16 | counter = 0; |
cpark308 | 0:7ee25b048596 | 17 | myled = 0; |
cpark308 | 0:7ee25b048596 | 18 | while(1){ |
cpark308 | 0:7ee25b048596 | 19 | //outfunction = (ti.read_us()%1000)*0.001; |
cpark308 | 0:7ee25b048596 | 20 | //myled= (((ti.read_ms())>>10)%1); |
cpark308 | 0:7ee25b048596 | 21 | outfunction = (counter%10)*0.1; |
cpark308 | 0:7ee25b048596 | 22 | counter++; |
cpark308 | 0:7ee25b048596 | 23 | myled = !myled; |
cpark308 | 0:7ee25b048596 | 24 | } |
cpark308 | 0:7ee25b048596 | 25 | } |
cpark308 | 0:7ee25b048596 | 26 | void sendinterrupt(void){ |
cpark308 | 0:7ee25b048596 | 27 | masterSignalOut = 1; |
cpark308 | 0:7ee25b048596 | 28 | } |
cpark308 | 0:7ee25b048596 | 29 | void interruptrecv(void){ |
cpark308 | 0:7ee25b048596 | 30 | ti.reset(); |
cpark308 | 0:7ee25b048596 | 31 | myled4 = !myled4; |
cpark308 | 0:7ee25b048596 | 32 | counter = 0; |
cpark308 | 0:7ee25b048596 | 33 | masterSignalOut = 0; |
cpark308 | 0:7ee25b048596 | 34 | } |
cpark308 | 0:7ee25b048596 | 35 | int main() { |
cpark308 | 0:7ee25b048596 | 36 | ti.reset(); |
cpark308 | 0:7ee25b048596 | 37 | myled2 = 0; |
cpark308 | 0:7ee25b048596 | 38 | myled4 = 0; |
cpark308 | 0:7ee25b048596 | 39 | masterSignalOut = 0; |
cpark308 | 0:7ee25b048596 | 40 | Thread threadanalog(analogScope); |
cpark308 | 0:7ee25b048596 | 41 | threadanalog.set_priority(osPriorityLow); |
cpark308 | 0:7ee25b048596 | 42 | trigger.rise(&interruptrecv); |
cpark308 | 0:7ee25b048596 | 43 | while(1) { |
cpark308 | 0:7ee25b048596 | 44 | myled2 = !myled2; |
cpark308 | 0:7ee25b048596 | 45 | Thread::wait(10000); |
cpark308 | 0:7ee25b048596 | 46 | } |
cpark308 | 0:7ee25b048596 | 47 | } |