summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2017-05-03 15:03:07 +0200
committerLeo C2017-05-03 15:03:07 +0200
commita5e9d0fec449df2e341cddb7f6055b14820d0bd8 (patch)
tree42ff81eb6e5d43306a89e0669974321a3161ac69
parent9004ddf5192fdd2442dc2cbb0158f042c981702e (diff)
downloadirmp-a5e9d0fec449df2e341cddb7f6055b14820d0bd8.zip
libopencm3: Add IRMP_LOGGINGHEADirmp-libopencm3-pre-1libopencm3
-rw-r--r--irmp.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/irmp.c b/irmp.c
index c37449c..2b9d965 100644
--- a/irmp.c
+++ b/irmp.c
@@ -740,6 +740,14 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM =
# include "stm32f4xx_usart.h"
#elif defined(ARM_STM32F10X)
# define STM32_UART_COM USART3 // UART3 on PB10
+#elif defined(LIBOPENCM3) //
+# include <libopencm3/stm32/usart.h>
+# define STM32_UART_COM USART2 // UART2 on PA2
+# define STM32_UART_GPIO_PORT GPIOA
+# define STM32_UART_GPIO_PIN GPIO2
+# define STM32_UART_COM_RCC RCC_USART2
+# define STM32_UART_GPIO_RCC RCC_GPIOA
+# define STM32_UART_BAUD 115200 // 115200 Baud
#elif defined(ARDUINO) // Arduino Serial implementation
# if defined(USB_SERIAL)
# include "usb_serial.h"
@@ -877,6 +885,23 @@ irmp_uart_init (void)
// UART enable
USART_Cmd(STM32_UART_COM, ENABLE);
+#elif defined(LIBOPENCM3)
+ rcc_periph_clock_enable(STM32_UART_COM_RCC);
+ /* Setup GPIO pin for USART TX */
+ rcc_periph_clock_enable(STM32_UART_GPIO_RCC);
+ gpio_set_mode(STM32_UART_GPIO_PORT, GPIO_MODE_OUTPUT_2_MHZ,
+ GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, STM32_UART_GPIO_PIN);
+
+ /* Setup UART parameters. */
+ usart_set_baudrate(STM32_UART_COM, STM32_UART_BAUD);
+ usart_set_databits(STM32_UART_COM, 8);
+ usart_set_stopbits(STM32_UART_COM, USART_STOPBITS_1);
+ usart_set_parity(STM32_UART_COM, USART_PARITY_NONE);
+ usart_set_flow_control(STM32_UART_COM, USART_FLOWCONTROL_NONE);
+ usart_set_mode(STM32_UART_COM, USART_MODE_TX_RX);
+ /* Finally enable the USART. */
+ usart_enable(STM32_UART_COM);
+
#elif defined(ARDUINO)
// we use the Arduino Serial Imlementation
// you have to call Serial.begin(SER_BAUD); in Arduino setup() function
@@ -939,6 +964,12 @@ irmp_uart_putc (unsigned char ch)
USART_SendData(STM32_UART_COM, '\r');
}
+#elif defined(LIBOPENCM3)
+ if (ch == '\n') {
+ usart_send_blocking(STM32_UART_COM, '\r');
+ }
+ usart_send_blocking(STM32_UART_COM, ch);
+
#elif defined(ARDUINO)
// we use the Arduino Serial Imlementation
usb_serial_putchar(ch);