]> cloudbase.mooo.com Git - irmp.git/blob - irmp-main-stellaris-arm.c
libopencm3: Add IRMP_LOGGING
[irmp.git] / irmp-main-stellaris-arm.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp-main-stellaris-arm.c - demo main module to test IRMP decoder on LM4F120 Launchpad (ARM Cortex M4)
3 *
4 * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irmp-main-stellaris-arm.c,v 1.1 2016/01/12 11:55:05 fm Exp $
7 *
8 * This demo module is runnable on LM4F120 Launchpad (ARM Cortex M4)
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 void
24 timer1_init (void)
25 {
26 SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
27 TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
28
29 TimerLoadSet(TIMER1_BASE, TIMER_A, (F_CPU / F_INTERRUPTS) -1);
30 IntEnable(INT_TIMER1A);
31 TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
32 TimerEnable(TIMER1_BASE, TIMER_A);
33 // Important: Timer1IntHandler has to be configured in startup_ccs.c !
34 }
35
36 void
37 Timer1IntHandler(void) // Timer1 Interrupt Handler
38 {
39 (void) irmp_ISR(); // call irmp ISR
40 // call other timer interrupt routines...
41 }
42
43 int
44 main (void)
45 {
46 IRMP_DATA irmp_data;
47
48 ROM_FPUEnable();
49 ROM_FPUStackingEnable();
50 ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
51
52 irmp_init(); // initialize irmp
53 timer1_init(); // initialize timer1
54 sei (); // enable interrupts
55
56 for (;;)
57 {
58 if (irmp_get_data (&irmp_data))
59 {
60 // ir signal decoded, do something here...
61 // irmp_data.protocol is the protocol, see irmp.h
62 // irmp_data.address is the address/manufacturer code of ir sender
63 // irmp_data.command is the command code
64 // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)
65 }
66 }
67 }