summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2017-04-16 14:24:12 +0200
committerLeo C2017-04-16 14:24:12 +0200
commit4d08a2f77cb136eeac9a0ec3bc5caf9fbba94c52 (patch)
treeabccf6ca11c511c8a77956db811e52c9ceedc1ab
parent30d1689ddd3c91f22ee9f79ae4cd6c897b7badbb (diff)
downloadirmp-4d08a2f77cb136eeac9a0ec3bc5caf9fbba94c52.zip
Add support for libopencm3 (STM32F1)
-rw-r--r--irmp.c9
-rw-r--r--irmp.h11
-rw-r--r--irmpconfig.h8
-rw-r--r--irmpsystem.h12
4 files changed, 40 insertions, 0 deletions
diff --git a/irmp.c b/irmp.c
index 150d69f..f95410b 100644
--- a/irmp.c
+++ b/irmp.c
@@ -2189,6 +2189,15 @@ irmp_init (void)
# endif
GPIO_Init(IRMP_PORT, &GPIO_InitStructure);
+#elif defined (ARM_OPENCM3) // STM32 with libopencm3
+
+ /* GPIOx clock enable */
+ rcc_periph_clock_enable(IRMP_PORT_RCC);
+
+ /* GPIO Configuration */
+ gpio_set_mode(IRMP_PORT, GPIO_MODE_INPUT,
+ GPIO_CNF_INPUT_FLOAT, 1<<IRMP_BIT);
+
#elif defined(STELLARIS_ARM_CORTEX_M4)
// Enable the GPIO port
ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH);
diff --git a/irmp.h b/irmp.h
index ded7e80..53e16c7 100644
--- a/irmp.h
+++ b/irmp.h
@@ -63,6 +63,17 @@
# warning The STM32 port of IRMP uses the ST standard peripheral drivers which are not enabled in your build configuration.
# endif
+#elif defined (ARM_OPENCM3)
+# define _CONCAT(a,b) a##b
+# define CONCAT(a,b) _CONCAT(a,b)
+# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)
+# define IRMP_PORT_RCC CONCAT(RCC_GPIO, IRMP_PORT_LETTER)
+
+# define IRMP_BIT IRMP_BIT_NUMBER
+# define IRMP_PIN IRMP_PORT // for use with input(x) below
+# define input(x) ((GPIO_IDR(IRMP_PORT) & (1<<IRMP_BIT)) != 0)
+//# define input(x) (BBIO_PERIPH(IRMP_PORT+IDR, IRMP_BIT))
+
#elif defined (STELLARIS_ARM_CORTEX_M4)
# define _CONCAT(a,b) a##b
# define CONCAT(a,b) _CONCAT(a,b)
diff --git a/irmpconfig.h b/irmpconfig.h
index 245129f..75d9834 100644
--- a/irmpconfig.h
+++ b/irmpconfig.h
@@ -137,6 +137,14 @@
# define IRMP_BIT_NUMBER 13
/*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * Change hardware pin here for ARM STM32 with libopencm3
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+#elif defined (ARM_OPENCM3) // use C13 as IR input on STM32
+# define IRMP_PORT_LETTER C
+# define IRMP_BIT_NUMBER 13
+
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
* Change hardware pin here for Stellaris ARM Cortex M4
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/
diff --git a/irmpsystem.h b/irmpsystem.h
index 25bacb2..e1fbc97 100644
--- a/irmpsystem.h
+++ b/irmpsystem.h
@@ -26,6 +26,9 @@
# define PIC_C18
#elif defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC compiler
# define PIC_CCS
+#elif defined(STM32F1) // ARM STM32 with libopencm3
+# define ARM_OPENCM3
+# define F_CPU (SysCtlClockGet())
#elif defined(STM32L1XX_MD) || defined(STM32L1XX_MDP) || defined(STM32L1XX_HD) // ARM STM32
# include <stm32l1xx.h>
# define ARM_STM32
@@ -133,6 +136,15 @@ typedef unsigned short uint16_t;
# define PROGMEM
# define memcpy_P memcpy
+#elif defined(ARM_OPENCM3)
+
+# include <libopencm3/cm3/nvic.h>
+# include <libopencm3/stm32/rcc.h>
+# include <libopencm3/stm32/gpio.h>
+# include <libopencm3/stm32/timer.h>
+# define PROGMEM
+# define memcpy_P memcpy
+
#elif defined(SDCC_STM8)
# include "stm8s.h"