From a5e9d0fec449df2e341cddb7f6055b14820d0bd8 Mon Sep 17 00:00:00 2001 From: Leo C Date: Wed, 3 May 2017 15:03:07 +0200 Subject: [PATCH] libopencm3: Add IRMP_LOGGING --- irmp.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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 +# 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); -- 2.39.2