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