summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo C2017-04-19 18:11:23 +0200
committerLeo C2017-04-19 18:11:23 +0200
commitb8dc40706bc01c881b69d8a460b4c1f0fb794a7d (patch)
tree14f7663150b4e135a3fee95a6fdd52246a92efb0
parent1ab917ad6785300f1eb9d2effb6779150f510c24 (diff)
downloadirmp-demo-b8dc40706bc01c881b69d8a460b4c1f0fb794a7d.zip
Add some comments
-rw-r--r--irmp-main.c49
-rw-r--r--serial.c2
-rw-r--r--timer.c15
-rw-r--r--timer.h2
4 files changed, 53 insertions, 15 deletions
diff --git a/irmp-main.c b/irmp-main.c
index 51b2e1d..1399546 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. <erbl259-lmu@yahoo.de>
+ *
+ * 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 <libopencm3/stm32/gpio.h>
#include <stdio.h>
+/* 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;
diff --git a/serial.c b/serial.c
index 60a328c..e00fdcf 100644
--- 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 58a4d2f..5665098 100644
--- 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
*/
@@ -11,10 +11,11 @@
#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 b6bc785..6129677 100644
--- 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
*/