Finished Decoder

Committer:
Ursukar
Date:
Thu Oct 15 10:15:29 2020 +0000
Revision:
0:830dd1202b0b
Child:
1:da51d068920b
Working, but adjustments needed!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ursukar 0:830dd1202b0b 1 #include "mbed.h"
Ursukar 0:830dd1202b0b 2
Ursukar 0:830dd1202b0b 3 InterruptIn signal(A0);
Ursukar 0:830dd1202b0b 4 Timer t_Receiver_Ch_Signal;
Ursukar 0:830dd1202b0b 5 unsigned int all_Ch[8];
Ursukar 0:830dd1202b0b 6 unsigned int current_Ch;
Ursukar 0:830dd1202b0b 7 unsigned char state_Of_Signal;
Ursukar 0:830dd1202b0b 8
Ursukar 0:830dd1202b0b 9
Ursukar 0:830dd1202b0b 10
Ursukar 0:830dd1202b0b 11 void isrFall()
Ursukar 0:830dd1202b0b 12 {
Ursukar 0:830dd1202b0b 13 current_Ch = t_Receiver_Ch_Signal.read_us();
Ursukar 0:830dd1202b0b 14 t_Receiver_Ch_Signal.reset();
Ursukar 0:830dd1202b0b 15
Ursukar 0:830dd1202b0b 16 if(current_Ch >= 6000) {
Ursukar 0:830dd1202b0b 17 state_Of_Signal = 0;
Ursukar 0:830dd1202b0b 18 }
Ursukar 0:830dd1202b0b 19 else{
Ursukar 0:830dd1202b0b 20 all_Ch[state_Of_Signal] = current_Ch;
Ursukar 0:830dd1202b0b 21 }
Ursukar 0:830dd1202b0b 22 state_Of_Signal++;
Ursukar 0:830dd1202b0b 23 }
Ursukar 0:830dd1202b0b 24
Ursukar 0:830dd1202b0b 25 int main()
Ursukar 0:830dd1202b0b 26 {
Ursukar 0:830dd1202b0b 27 t_Receiver_Ch_Signal.reset();
Ursukar 0:830dd1202b0b 28 t_Receiver_Ch_Signal.start();
Ursukar 0:830dd1202b0b 29 signal.fall(&isrFall);
Ursukar 0:830dd1202b0b 30 state_Of_Signal = 0;
Ursukar 0:830dd1202b0b 31 while (true) {
Ursukar 0:830dd1202b0b 32 for(int i = 0; i <= 8; i++)
Ursukar 0:830dd1202b0b 33 {
Ursukar 0:830dd1202b0b 34 printf("Channel %d: %d \n", i, all_Ch[i]);
Ursukar 0:830dd1202b0b 35 }
Ursukar 0:830dd1202b0b 36 //printf("Timer %d\n", current_Ch);
Ursukar 0:830dd1202b0b 37 wait_ms(2000);
Ursukar 0:830dd1202b0b 38 }
Ursukar 0:830dd1202b0b 39 return 0;
Ursukar 0:830dd1202b0b 40 }