X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp-demo.git/blobdiff_plain/b1a276a15faaf6b4b74769021857850e818156b7..113f999d8cf296bb78f8652b1cc08fc323c7c4aa:/irmp-main.c?ds=sidebyside diff --git a/irmp-main.c b/irmp-main.c index 51b2e1d..f7d213d 100644 --- a/irmp-main.c +++ b/irmp-main.c @@ -1,17 +1,24 @@ -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * irmp-main-stm32.c - demo main module to test IRMP decoder on STM32 +/*------------------------------------------------------------------------------ + * irmp-main.c - demo program to test the IRMP decoder on STM32F1 whith libopencm3 * + * Copyright (c) 2017 Leo C. + * + * This demo program is essentially a combination of some libopencm3 examples + * from https://github.com/libopencm3/libopencm3-examples + * and irmp-main-stm32.c from the IRMP distribution, which is * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp-main-stm32.c,v 1.2 2016/01/12 21:15:16 fm Exp $ + * The program demonstrates the integration of IRMP in a libopencm3 environment, + * and how to use the libopencm3 api functions, or alternatively direct + * register access, using the macros defined by libopencm3. * - * This demo module is runnable on STM32 + * This demo runs on the Generic STM32F103C8T6 Development Board, aka bluepill. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - *--------------------------------------------------------------------------------------------------------------------------------------------------- + *------------------------------------------------------------------------------ */ #include "config.h" @@ -22,20 +29,27 @@ #include #include +/* The folloing macros can also be defined in the Makefile */ +/* If 0 or undefined, use direct register access where appropriate, + * else use the libopencm3 api functions everywhere. */ #ifndef USE_OPENCM3_API -#define USE_OPENCM3_API 1 +#define USE_OPENCM3_API 0 #endif +/* Toggle a pin on irmp timer isr entry and exit */ #ifndef DEBUG_IRMP_TIMER_INT #define DEBUG_IRMP_TIMER_INT 0 #endif +/** + * Do all initialisations, that are not done by a specific module here. + */ static void setup_clock_and_gpios(void) { /* Clock setup */ /* Default clock is 8MHz HSI */ //rcc_clock_setup_in_hse_8mhz_out_24mhz(); - rcc_clock_setup_in_hse_8mhz_out_72mhz(); + //rcc_clock_setup_in_hse_8mhz_out_72mhz(); /* GPIO setup */ /* Only the on board led is configured here */ @@ -65,6 +79,11 @@ static void setup_clock_and_gpios(void) #define IRMP_TIMER_ISR CONCAT(CONCAT(tim, IRMP_TIMER), _isr) +/** Retrieve the actual input clock of a timer + +@param[in] timer_peripheral Unsigned int32. Timer register address base +@returns Unsigned int32. frequency value. +*/ uint32_t timer_internal_clock_get(uint32_t timer_peripheral) { uint32_t timer_frequency; @@ -87,6 +106,9 @@ uint32_t timer_internal_clock_get(uint32_t timer_peripheral) return timer_frequency; } +/** + * Intialize the irmp interrupt timer + */ void irmp_timer_init (void) { #if DEBUG_IRMP_TIMER_INT @@ -159,6 +181,11 @@ void IRMP_TIMER_ISR(void) /*--------------------------------------------------------------------------*/ +/** Test if a IR protocol is supported + * + * Return true, if proto is valid protocol number and the protocol + * is enabled in irmpconfig.h + */ int irmp_protocol_is_supported(int proto) { #if IRMP_SUPPORT_SIRCS_PROTOCOL @@ -306,6 +333,10 @@ int irmp_protocol_is_supported(int proto) return 0; } +/** + * Print the names of all supported protocols, or the supported protocol + * numbers, if names are not enabled. + */ void print_supported_protocols(void) { printf("Supported IR protocols:"); @@ -323,6 +354,10 @@ void print_supported_protocols(void) /*--------------------------------------------------------------------------*/ +/** Let the board led do something + * + * The led should blink with 1 Hz + */ void led_blink(void) { static uint32_t ts;