]> cloudbase.mooo.com Git - irmp-demo.git/commitdiff
Add some comments
authorLeo C <erbl259-lmu@yahoo.de>
Wed, 19 Apr 2017 16:11:23 +0000 (18:11 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Wed, 19 Apr 2017 16:11:23 +0000 (18:11 +0200)
irmp-main.c
serial.c
timer.c
timer.h

index 51b2e1dbd9c9616304308862949c251af115d485..1399546c85ddcf3a00a2e4ec54187c29978c6817 100644 (file)
@@ -1,17 +1,24 @@
-/*---------------------------------------------------------------------------------------------------------------------------------------------------\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
@@ -65,6 +79,11 @@ static void setup_clock_and_gpios(void)
 #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
@@ -87,6 +106,9 @@ uint32_t timer_internal_clock_get(uint32_t timer_peripheral)
        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
@@ -159,6 +181,11 @@ void IRMP_TIMER_ISR(void)
 \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
@@ -306,6 +333,10 @@ int irmp_protocol_is_supported(int proto)
     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
@@ -323,6 +354,10 @@ void print_supported_protocols(void)
 \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
index 60a328cbf199c464e0c30e08bdf5877b47177178..e00fdcfa5ca93cbe74ff0e8e7054d5717bfe6e14 100644 (file)
--- a/serial.c
+++ b/serial.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ * (C) Copyright 2014 - 2017 Leo C. <erbl259-lmu@yahoo.de>
  *
  * SPDX-License-Identifier:    GPL-2.0
  */
diff --git a/timer.c b/timer.c
index 58a4d2fba81daf85a652d54ea0029b8bf9052ce3..5665098bdfc8cee30373042c67acda95b1bbe0d6 100644 (file)
--- a/timer.c
+++ b/timer.c
@@ -1,5 +1,5 @@
 /*
- * (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)
 {
@@ -28,7 +29,6 @@ void systick_setup(void)
 /*--------------------------------------------------------------------------*/
 
 /*
- *
  * 1000Hz timer interrupt generated by System Timer
  */
 void sys_tick_handler(void)
@@ -38,6 +38,9 @@ void sys_tick_handler(void)
 
 /*--------------------------------------------------------------------------*/
 
+/*
+ * Return elapsed time in ms since base.
+ */
 uint32_t get_timer(uint32_t base)
 {
        return timestamp - base;
diff --git a/timer.h b/timer.h
index b6bc785a09e898ba0e00ea67f3a08c9e979d2344..6129677b494fe8afefdd82fc49bfcfaf7d08066a 100644 (file)
--- a/timer.h
+++ b/timer.h
@@ -1,5 +1,5 @@
 /*
- * (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
  */