-/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
- * irmp-main-stm32.c - demo main module to test IRMP decoder on STM32\r
+/*------------------------------------------------------------------------------\r
+ * irmp-main.c - demo program to test the IRMP decoder on STM32F1 whith libopencm3\r
*\r
+ * Copyright (c) 2017 Leo C. <erbl259-lmu@yahoo.de>\r
+ *\r
+ * This demo program is essentially a combination of some libopencm3 examples\r
+ * from https://github.com/libopencm3/libopencm3-examples,\r
+ * and irmp-main-stm32.c from the IRMP distribution, which is\r
* Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irmp-main-stm32.c,v 1.2 2016/01/12 21:15:16 fm Exp $\r
+ * The program demonstrates the integration of IRMP in a libopencm3 environment,\r
+ * and how to use the libopencm3 api functions, or alternatively direct\r
+ * register access, using the macros defined by libopencm3.\r
*\r
- * This demo module is runnable on STM32\r
+ * This demo runs on the Generic STM32F103C8T6 Development Board, aka bluepill.\r
*\r
* This program is free software; you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
* the Free Software Foundation; either version 2 of the License, or\r
* (at your option) any later version.\r
- *---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ *------------------------------------------------------------------------------\r
*/\r
\r
#include "config.h"\r
#include <libopencm3/stm32/gpio.h>\r
#include <stdio.h>\r
\r
+/* The folloing macros can also be defined in the Makefile */\r
+/* If 0 or undefined, use direct register access where appropriate,\r
+ * else use the libopencm3 api functions everywhere. */\r
#ifndef USE_OPENCM3_API\r
-#define USE_OPENCM3_API 1\r
+#define USE_OPENCM3_API 0\r
#endif\r
\r
+/* Toggle a pin on irmp timer isr entry and exit */\r
#ifndef DEBUG_IRMP_TIMER_INT\r
#define DEBUG_IRMP_TIMER_INT 0\r
#endif\r
\r
+/**\r
+ * Do all initialisations, that are not done by a specific module here.\r
+ */\r
static void setup_clock_and_gpios(void)\r
{\r
/* Clock setup */\r
/* Default clock is 8MHz HSI */\r
//rcc_clock_setup_in_hse_8mhz_out_24mhz();\r
- rcc_clock_setup_in_hse_8mhz_out_72mhz();\r
+ //rcc_clock_setup_in_hse_8mhz_out_72mhz();\r
\r
/* GPIO setup */\r
/* Only the on board led is configured here */\r
#define IRMP_TIMER_ISR CONCAT(CONCAT(tim, IRMP_TIMER), _isr)\r
\r
\r
+/** Retrieve the actual input clock of a timer\r
+\r
+@param[in] timer_peripheral Unsigned int32. Timer register address base\r
+@returns Unsigned int32. frequency value.\r
+*/\r
uint32_t timer_internal_clock_get(uint32_t timer_peripheral)\r
{\r
uint32_t timer_frequency;\r
return timer_frequency;\r
}\r
\r
+/**\r
+ * Intialize the irmp interrupt timer\r
+ */\r
void irmp_timer_init (void)\r
{\r
#if DEBUG_IRMP_TIMER_INT\r
\r
/*--------------------------------------------------------------------------*/\r
\r
+/** Test if a IR protocol is supported\r
+ *\r
+ * Return true, if proto is valid protocol number and the protocol\r
+ * is enabled in irmpconfig.h\r
+ */\r
int irmp_protocol_is_supported(int proto)\r
{\r
#if IRMP_SUPPORT_SIRCS_PROTOCOL\r
return 0;\r
}\r
\r
+/**\r
+ * Print the names of all supported protocols, or the supported protocol\r
+ * numbers, if names are not enabled.\r
+ */\r
void print_supported_protocols(void)\r
{\r
printf("Supported IR protocols:");\r
\r
/*--------------------------------------------------------------------------*/\r
\r
+/** Let the board led do something\r
+ *\r
+ * The led should blink with 1 Hz\r
+ */\r
void led_blink(void)\r
{\r
static uint32_t ts;\r
/*
- * (C) Copyright 2017 Leo C. <erbl259-lmu@yahoo.de>
+ * (C) Copyright 20014 - 2017 Leo C. <erbl259-lmu@yahoo.de>
*
* SPDX-License-Identifier: GPL-2.0
*/
#include <libopencm3/stm32/gpio.h>
-/* timer interrupt/overflow counter */
-/* counts up every ms. */
-static volatile
-uint32_t timestamp;
+/*
+ * timer interrupt/overflow counter, counts up every ms.
+ */
+static
+volatile uint32_t timestamp;
void systick_setup(void)
{
/*--------------------------------------------------------------------------*/
/*
- *
* 1000Hz timer interrupt generated by System Timer
*/
void sys_tick_handler(void)
/*--------------------------------------------------------------------------*/
+/*
+ * Return elapsed time in ms since base.
+ */
uint32_t get_timer(uint32_t base)
{
return timestamp - base;