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