Finished Decoder

Committer:
Ursukar
Date:
Thu Oct 15 17:50:38 2020 +0000
Revision:
2:6b9833ee0cc6
Parent:
1:da51d068920b
Child:
3:d22eedba5563
Finished Decoder

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 2:6b9833ee0cc6 5 unsigned short all_Ch[8];
Ursukar 2:6b9833ee0cc6 6 unsigned short 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 1:da51d068920b 19 else if(current_Ch <= 1000)
Ursukar 1:da51d068920b 20 {
Ursukar 1:da51d068920b 21 return;
Ursukar 1:da51d068920b 22 }
Ursukar 0:830dd1202b0b 23 else{
Ursukar 0:830dd1202b0b 24 all_Ch[state_Of_Signal] = current_Ch;
Ursukar 1:da51d068920b 25 state_Of_Signal++;
Ursukar 0:830dd1202b0b 26 }
Ursukar 1:da51d068920b 27
Ursukar 0:830dd1202b0b 28 }
Ursukar 0:830dd1202b0b 29
Ursukar 0:830dd1202b0b 30 int main()
Ursukar 0:830dd1202b0b 31 {
Ursukar 0:830dd1202b0b 32 t_Receiver_Ch_Signal.reset();
Ursukar 0:830dd1202b0b 33 t_Receiver_Ch_Signal.start();
Ursukar 0:830dd1202b0b 34 signal.fall(&isrFall);
Ursukar 0:830dd1202b0b 35 state_Of_Signal = 0;
Ursukar 2:6b9833ee0cc6 36 while (1) {
Ursukar 1:da51d068920b 37 for(int i = 0; i < 8; i++)
Ursukar 0:830dd1202b0b 38 {
Ursukar 1:da51d068920b 39 printf("Channel %d: %d \n", i + 1, all_Ch[i]);
Ursukar 0:830dd1202b0b 40 }
Ursukar 1:da51d068920b 41 printf("End of Signal\n");
Ursukar 0:830dd1202b0b 42 wait_ms(2000);
Ursukar 0:830dd1202b0b 43 }
Ursukar 0:830dd1202b0b 44 return 0;
Ursukar 0:830dd1202b0b 45 }