]> cloudbase.mooo.com Git - irmp.git/blobdiff - main.c
Version 2.6.0: added SAMSUNG48 protocol (in IRSND).
[irmp.git] / main.c
diff --git a/main.c b/main.c
index 88deb316a552749ff72f708e8147bf30fa0d11f7..25600d6d226f43f89aa3b7eb85b7743d7425e3d0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,9 +1,9 @@
 /*---------------------------------------------------------------------------------------------------------------------------------------------------\r
  * main.c - demo main module to test irmp decoder\r
  *\r
- * Copyright (c) 2009-2012 Frank Meyer - frank(at)fli4l.de\r
+ * Copyright (c) 2009-2013 Frank Meyer - frank(at)fli4l.de\r
  *\r
- * $Id: main.c,v 1.16 2012/12/06 08:49:33 fm Exp $\r
+ * $Id: main.c,v 1.18 2014/07/01 07:50:33 fm Exp $\r
  *\r
  * This demo module is runnable on AVRs and LM4F120 Launchpad (ARM Cortex M4)\r
  *\r
@@ -140,4 +140,53 @@ main (void)
     }\r
 }\r
 \r
+/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ * PIC18F4520 with XC8 compiler:\r
+ *---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ */\r
+#elif defined (__XC8)\r
+\r
+#define _XTAL_FREQ  32000000UL                                              // 32MHz clock\r
+#define FOSC        _XTAL_FREQ\r
+#define FCY         FOSC / 4UL                                              // --> 8MHz\r
+\r
+#define BAUDRATE 19200UL\r
+#define BRG (( FCY  16  BAUDRATE ) -1UL)\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+int\r
+main (void)\r
+{\r
+    IRMP_DATA irmp_data;\r
+\r
+    irmp_init();                                                            // initialize irmp\r
+\r
+    // infinite loop, interrupts will blink PORTD pins and handle UART communications.\r
+    while (1)\r
+    {\r
+        LATBbits.LATB0 = ~LATBbits.LATB0;\r
+\r
+        if (irmp_get_data (&irmp_data))\r
+        {\r
+            // ir signal decoded, do something here...\r
+            // irmp_data.protocol is the protocol, see irmp.h\r
+            // irmp_data.address is the address/manufacturer code of ir sender\r
+            // irmp_data.command is the command code\r
+            // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)\r
+            printf("proto %d addr %d cmd %d\n", irmp_data.protocol, irmp_data.address, irmp_data.command );\r
+        }\r
+    }\r
+}\r
+\r
+void interrupt high_priority high_isr(void)\r
+{\r
+    if (TMR2IF)\r
+    {\r
+        TMR2IF = 0;                                                         // clear Timer 0 interrupt flag\r
+        irmp_ISR();\r
+    }\r
+}\r
+\r
 #endif\r