|
1 /***************************************************************************** |
|
2 * Copyright (C) 2014 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of the mbsePi-apps |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * mbsePi-apps is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with EC-65K; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 #include "../lib/mbselib.h" |
|
24 #include "recv.h" |
|
25 |
|
26 |
|
27 int main(int argc, char *argv[]) { |
|
28 |
|
29 /* |
|
30 input PIN is hardcoded for testing purposes |
|
31 see https://projects.drogon.net/raspberry-pi/wiringpi/pins/ |
|
32 for pin mapping of the raspberry pi GPIO connector |
|
33 */ |
|
34 int PIN = 2; |
|
35 |
|
36 if (wiringPiSetup () ) |
|
37 return 1; |
|
38 |
|
39 enableReceiveIRQ(PIN); |
|
40 |
|
41 while (1) { |
|
42 if (available()) { |
|
43 |
|
44 int value = getReceivedValue(); |
|
45 |
|
46 if (value == 0) { |
|
47 printf("Unknown encoding\n"); |
|
48 } else { |
|
49 printf("Received %ld/%d bit Protocol: %d\n", getReceivedValue(), getReceivedBitlength(), getReceivedProtocol() ); |
|
50 } |
|
51 |
|
52 resetAvailable(); |
|
53 } else { |
|
54 /* |
|
55 * Don't hog the CPU. |
|
56 */ |
|
57 delay(10); |
|
58 } |
|
59 } |
|
60 |
|
61 return 0; |
|
62 } |
|
63 |