diff --git a/src/freertos_drivers/st/Stm32Uart.cxx b/src/freertos_drivers/st/Stm32Uart.cxx index 10cfd784c..fcee7849b 100644 --- a/src/freertos_drivers/st/Stm32Uart.cxx +++ b/src/freertos_drivers/st/Stm32Uart.cxx @@ -33,6 +33,7 @@ #include "Stm32Uart.hxx" +#include "freertos/tc_ioctl.h" #include "stm32f_hal_conf.hxx" #if defined(STM32F072xB) || defined(STM32F091xC) @@ -232,6 +233,21 @@ void Stm32Uart::disable() HAL_UART_DeInit(&uartHandle); } +int Stm32Uart::ioctl(File *file, unsigned long int key, unsigned long data) +{ + switch (key) + { + default: + return -EINVAL; + case TCBAUDRATE: + uartHandle.Init.BaudRate = data; + volatile auto ret = HAL_UART_Init(&uartHandle); + HASSERT(HAL_OK == ret); + break; + } + return 0; +} + /** Try and transmit a message. */ void Stm32Uart::tx_char() diff --git a/src/freertos_drivers/st/Stm32Uart.hxx b/src/freertos_drivers/st/Stm32Uart.hxx index e7998057c..0ff8c87a9 100644 --- a/src/freertos_drivers/st/Stm32Uart.hxx +++ b/src/freertos_drivers/st/Stm32Uart.hxx @@ -63,6 +63,10 @@ public: */ static void interrupt_handler(unsigned index); + /** Request an ioctl transaction. Supported ioctl is TCBAUDRATE from + * include/freertos/tc_ioctl.h */ + int ioctl(File *file, unsigned long int key, unsigned long data) override; + private: void enable() override; /**< function to enable device */ void disable() override; /**< function to disable device */