1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp-main-stm32.c - demo main module to test IRMP decoder on STM32
4 * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de
6 * $Id: irmp-main-stm32.c,v 1.4 2017/02/17 09:13:06 fm Exp $
8 * This demo module is runnable on STM32
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 *---------------------------------------------------------------------------------------------------------------------------------------------------
26 RCC_ClocksTypeDef RCC_ClocksStatus
;
27 RCC_GetClocksFreq(&RCC_ClocksStatus
);
28 return RCC_ClocksStatus
.SYSCLK_Frequency
;
34 TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure
;
35 NVIC_InitTypeDef NVIC_InitStructure
;
36 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2
, ENABLE
);
38 TIM_TimeBaseStructure
.TIM_ClockDivision
= TIM_CKD_DIV1
;
39 TIM_TimeBaseStructure
.TIM_CounterMode
= TIM_CounterMode_Up
;
40 TIM_TimeBaseStructure
.TIM_Period
= 7;
41 TIM_TimeBaseStructure
.TIM_Prescaler
= ((F_CPU
/ F_INTERRUPTS
)/8) - 1;
42 TIM_TimeBaseInit(TIM2
, &TIM_TimeBaseStructure
);
44 TIM_ITConfig(TIM2
, TIM_IT_Update
, ENABLE
);
46 NVIC_InitStructure
.NVIC_IRQChannel
= TIM2_IRQn
;
47 NVIC_InitStructure
.NVIC_IRQChannelCmd
= ENABLE
;
48 NVIC_InitStructure
.NVIC_IRQChannelPreemptionPriority
= 0x0F;
49 NVIC_InitStructure
.NVIC_IRQChannelSubPriority
= 0x0F;
50 NVIC_Init(&NVIC_InitStructure
);
52 TIM_Cmd(TIM2
, ENABLE
);
56 TIM2_IRQHandler(void) // Timer2 Interrupt Handler
58 TIM_ClearITPendingBit(TIM2
, TIM_IT_Update
);
59 (void) irmp_ISR(); // call irmp ISR
60 // call other timer interrupt routines...
68 irmp_init(); // initialize irmp
69 timer2_init(); // initialize timer2
73 if (irmp_get_data (&irmp_data
))
75 // ir signal decoded, do something here...
76 // irmp_data.protocol is the protocol, see irmp.h
77 // irmp_data.address is the address/manufacturer code of ir sender
78 // irmp_data.command is the command code
79 // irmp_protocol_names[irmp_data.protocol] is the protocol name (if enabled, see irmpconfig.h)