]>
Commit | Line | Data |
---|---|---|
ea29682a | 1 | /*---------------------------------------------------------------------------------------------------------------------------------------------------\r |
7365350c | 2 | * irmp-main-pic-xc8.c - demo main module to test IRMP decoder on PIC18F4520 with XC8 compiler\r |
ea29682a | 3 | *\r |
4 | * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de\r | |
5 | *\r | |
7365350c | 6 | * $Id: irmp-main-pic-xc8.c,v 1.2 2016/09/09 08:01:11 fm Exp $\r |
ea29682a | 7 | *\r |
8 | * This demo module is runnable on PIC18F4520 with XC8 compiler\r | |
9 | *\r | |
10 | * This program is free software; you can redistribute it and/or modify\r | |
11 | * it under the terms of the GNU General Public License as published by\r | |
12 | * the Free Software Foundation; either version 2 of the License, or\r | |
13 | * (at your option) any later version.\r | |
14 | *---------------------------------------------------------------------------------------------------------------------------------------------------\r | |
15 | */\r | |
16 | \r | |
17 | #include "irmp.h"\r | |
18 | \r | |
19 | #ifndef F_CPU\r | |
20 | #error F_CPU unknown\r | |
21 | #endif\r | |
22 | \r | |
23 | #define _XTAL_FREQ 32000000UL // 32MHz clock\r | |
24 | #define FOSC _XTAL_FREQ\r | |
25 | #define FCY FOSC / 4UL // --> 8MHz\r | |
26 | \r | |
27 | #define BAUDRATE 19200UL\r | |
28 | #define BRG (( FCY 16 BAUDRATE ) -1UL)\r | |
29 | \r | |
30 | #include <stdio.h>\r | |
31 | #include <stdlib.h>\r | |
32 | \r | |
33 | int\r | |
34 | main (void)\r | |
35 | {\r | |
36 | IRMP_DATA irmp_data;\r | |
37 | \r | |
38 | irmp_init(); // initialize irmp\r | |
39 | \r | |
40 | // infinite loop, interrupts will blink PORTD pins and handle UART communications.\r | |
41 | while (1)\r | |
42 | {\r | |
43 | LATBbits.LATB0 = ~LATBbits.LATB0;\r | |
44 | \r | |
45 | if (irmp_get_data (&irmp_data))\r | |
46 | {\r | |
47 | // ir signal decoded, do something here...\r | |
48 | // irmp_data.protocol is the protocol, see irmp.h\r | |
49 | // irmp_data.address is the address/manufacturer code of ir sender\r | |
50 | // irmp_data.command is the command code\r | |
51 | // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)\r | |
52 | printf("proto %d addr %d cmd %d\n", irmp_data.protocol, irmp_data.address, irmp_data.command );\r | |
53 | }\r | |
54 | }\r | |
55 | }\r | |
56 | \r | |
57 | void interrupt high_priority high_isr(void)\r | |
58 | {\r | |
59 | if (TMR2IF)\r | |
60 | {\r | |
61 | TMR2IF = 0; // clear Timer 0 interrupt flag\r | |
62 | irmp_ISR();\r | |
63 | }\r | |
64 | }\r |