diff --git a/.cproject b/.cproject
index c531b61..d57df10 100644
--- a/.cproject
+++ b/.cproject
@@ -51,8 +51,8 @@
-
+
@@ -132,8 +132,8 @@
-
+
diff --git a/.mxproject b/.mxproject
index f0a6f32..32b69f0 100644
--- a/.mxproject
+++ b/.mxproject
@@ -1,35 +1,37 @@
[PreviousLibFiles]
-LibFiles=Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_system.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_adc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_bus.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crs.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_utils.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_exti.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_def.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_exti.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dac.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_usart.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_uart.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_uart_ex.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_adc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_cortex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_crc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dac.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_usart.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_uart.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_uart_ex.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_system.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_adc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_bus.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crs.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_utils.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_exti.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_def.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_exti.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dac.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_usart.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_uart.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_uart_ex.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\stm32f303xe.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\stm32f3xx.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\system_stm32f3xx.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\system_stm32f3xx.h;Drivers\CMSIS\Device\ST\STM32F3xx\Source\Templates\system_stm32f3xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
+LibFiles=Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_system.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_adc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_bus.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crs.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_utils.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_exti.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_def.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_exti.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dac.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_usart.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_adc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_cortex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_crc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dac.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_usart.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_system.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_adc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_bus.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crs.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_utils.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_exti.h;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_def.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_rcc_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_gpio_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_dma.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_cortex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_pwr_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_flash_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_i2c_ex.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_hal_exti.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_crc.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_dac.h;Drivers\STM32F3xx_HAL_Driver\Inc\stm32f3xx_ll_usart.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\stm32f303xe.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\stm32f3xx.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\system_stm32f3xx.h;Drivers\CMSIS\Device\ST\STM32F3xx\Include\system_stm32f3xx.h;Drivers\CMSIS\Device\ST\STM32F3xx\Source\Templates\system_stm32f3xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
[PreviousUsedCubeIDEFiles]
-SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\adc.c;Core\Src\crc.c;Core\Src\dac.c;Core\Src\usart.c;Core\Src\stm32f3xx_it.c;Core\Src\stm32f3xx_hal_msp.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_adc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_cortex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_crc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dac.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_usart.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_uart.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32F3xx\Source\Templates\system_stm32f3xx.c;Core\Src\system_stm32f3xx.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_adc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_cortex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_crc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dac.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_usart.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_uart.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32F3xx\Source\Templates\system_stm32f3xx.c;Core\Src\system_stm32f3xx.c;;;
+SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\adc.c;Core\Src\crc.c;Core\Src\dac.c;Core\Src\dma.c;Core\Src\usart.c;Core\Src\stm32f3xx_it.c;Core\Src\stm32f3xx_hal_msp.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_adc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_cortex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_crc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dac.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_usart.c;Drivers\CMSIS\Device\ST\STM32F3xx\Source\Templates\system_stm32f3xx.c;Core\Src\system_stm32f3xx.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_utils.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_adc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_rcc_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_gpio.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_dma.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_cortex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_pwr_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_flash_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_i2c_ex.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_hal_exti.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_crc.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_dac.c;Drivers\STM32F3xx_HAL_Driver\Src\stm32f3xx_ll_usart.c;Drivers\CMSIS\Device\ST\STM32F3xx\Source\Templates\system_stm32f3xx.c;Core\Src\system_stm32f3xx.c;;;
HeaderPath=Drivers\STM32F3xx_HAL_Driver\Inc;Drivers\STM32F3xx_HAL_Driver\Inc\Legacy;Drivers\CMSIS\Device\ST\STM32F3xx\Include;Drivers\CMSIS\Include;Core\Inc;
CDefines=USE_FULL_LL_DRIVER;USE_HAL_DRIVER;STM32F303xE;USE_FULL_LL_DRIVER;USE_HAL_DRIVER;USE_HAL_DRIVER;
[PreviousGenFiles]
AdvancedFolderStructure=true
-HeaderFileListSize=9
+HeaderFileListSize=10
HeaderFiles#0=..\Core\Inc\gpio.h
HeaderFiles#1=..\Core\Inc\adc.h
HeaderFiles#2=..\Core\Inc\crc.h
HeaderFiles#3=..\Core\Inc\dac.h
-HeaderFiles#4=..\Core\Inc\usart.h
-HeaderFiles#5=..\Core\Inc\stm32f3xx_it.h
-HeaderFiles#6=..\Core\Inc\stm32_assert.h
-HeaderFiles#7=..\Core\Inc\stm32f3xx_hal_conf.h
-HeaderFiles#8=..\Core\Inc\main.h
+HeaderFiles#4=..\Core\Inc\dma.h
+HeaderFiles#5=..\Core\Inc\usart.h
+HeaderFiles#6=..\Core\Inc\stm32f3xx_it.h
+HeaderFiles#7=..\Core\Inc\stm32_assert.h
+HeaderFiles#8=..\Core\Inc\stm32f3xx_hal_conf.h
+HeaderFiles#9=..\Core\Inc\main.h
HeaderFolderListSize=1
HeaderPath#0=..\Core\Inc
HeaderFiles=;
-SourceFileListSize=8
+SourceFileListSize=9
SourceFiles#0=..\Core\Src\gpio.c
SourceFiles#1=..\Core\Src\adc.c
SourceFiles#2=..\Core\Src\crc.c
SourceFiles#3=..\Core\Src\dac.c
-SourceFiles#4=..\Core\Src\usart.c
-SourceFiles#5=..\Core\Src\stm32f3xx_it.c
-SourceFiles#6=..\Core\Src\stm32f3xx_hal_msp.c
-SourceFiles#7=..\Core\Src\main.c
+SourceFiles#4=..\Core\Src\dma.c
+SourceFiles#5=..\Core\Src\usart.c
+SourceFiles#6=..\Core\Src\stm32f3xx_it.c
+SourceFiles#7=..\Core\Src\stm32f3xx_hal_msp.c
+SourceFiles#8=..\Core\Src\main.c
SourceFolderListSize=1
SourcePath#0=..\Core\Src
SourceFiles=;
diff --git a/Core/Inc/dma.h b/Core/Inc/dma.h
new file mode 100644
index 0000000..493d98e
--- /dev/null
+++ b/Core/Inc/dma.h
@@ -0,0 +1,52 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file dma.h
+ * @brief This file contains all the function prototypes for
+ * the dma.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __DMA_H__
+#define __DMA_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* DMA memory to memory transfer handles -------------------------------------*/
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_DMA_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DMA_H__ */
+
diff --git a/Core/Inc/stm32f3xx_hal_conf.h b/Core/Inc/stm32f3xx_hal_conf.h
index ce396b6..e107d3c 100644
--- a/Core/Inc/stm32f3xx_hal_conf.h
+++ b/Core/Inc/stm32f3xx_hal_conf.h
@@ -58,7 +58,7 @@
/*#define HAL_RTC_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
/*#define HAL_TIM_MODULE_ENABLED */
-#define HAL_UART_MODULE_ENABLED
+/*#define HAL_UART_MODULE_ENABLED */
/*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_IRDA_MODULE_ENABLED */
/*#define HAL_SMARTCARD_MODULE_ENABLED */
diff --git a/Core/Inc/stm32f3xx_it.h b/Core/Inc/stm32f3xx_it.h
index 096e046..02f8433 100644
--- a/Core/Inc/stm32f3xx_it.h
+++ b/Core/Inc/stm32f3xx_it.h
@@ -55,7 +55,11 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void DMA1_Channel6_IRQHandler(void);
+void DMA1_Channel7_IRQHandler(void);
/* USER CODE BEGIN EFP */
+uint32_t SysTimeGetAbs(void);
+int32_t SysTimeGetRel(uint32_t tref);
/* USER CODE END EFP */
diff --git a/Core/Inc/usart.h b/Core/Inc/usart.h
index 2cccff1..ca7c54d 100644
--- a/Core/Inc/usart.h
+++ b/Core/Inc/usart.h
@@ -32,10 +32,6 @@ extern "C" {
/* USER CODE END Includes */
-extern UART_HandleTypeDef huart2;
-
-extern UART_HandleTypeDef huart3;
-
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
diff --git a/Core/Src/dma.c b/Core/Src/dma.c
new file mode 100644
index 0000000..c56ccd3
--- /dev/null
+++ b/Core/Src/dma.c
@@ -0,0 +1,58 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file dma.c
+ * @brief This file provides code for the configuration
+ * of all the requested memory to memory DMA transfers.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "dma.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/*----------------------------------------------------------------------------*/
+/* Configure DMA */
+/*----------------------------------------------------------------------------*/
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+/**
+ * Enable DMA controller clock
+ */
+void MX_DMA_Init(void)
+{
+
+ /* DMA controller clock enable */
+ __HAL_RCC_DMA1_CLK_ENABLE();
+
+ /* DMA interrupt init */
+ /* DMA1_Channel6_IRQn interrupt configuration */
+ NVIC_SetPriority(DMA1_Channel6_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
+ NVIC_EnableIRQ(DMA1_Channel6_IRQn);
+ /* DMA1_Channel7_IRQn interrupt configuration */
+ NVIC_SetPriority(DMA1_Channel7_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
+ NVIC_EnableIRQ(DMA1_Channel7_IRQn);
+
+}
+
+/* USER CODE BEGIN 2 */
+
+/* USER CODE END 2 */
+
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 2c43f00..2505034 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -21,13 +21,16 @@
#include "adc.h"
#include "crc.h"
#include "dac.h"
+#include "dma.h"
#include "usart.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "printf.h"
+#include
#include "uart5_it.h"
+#include "stm32f3xx_it.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -92,12 +95,12 @@ int main(void) {
SystemClock_Config();
/* USER CODE BEGIN SysInit */
- SysTick_Config(SystemCoreClock / 1000);
-
+ //SysTick_Config(SystemCoreClock / 1000);
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
+ MX_DMA_Init();
MX_ADC1_Init();
MX_CRC_Init();
MX_DAC1_Init();
@@ -118,7 +121,7 @@ int main(void) {
if (c != -1) { // new incoming data
Uart5_PutByte(c); // UART5rx --> UART5tx
LL_GPIO_TogglePin(GPIOA, LL_GPIO_PIN_5);
- printf(" %u ms\n", HAL_GetTick());
+ printf(" %u ms\n", SysTimeGetAbs());
}
/* USER CODE END WHILE */
diff --git a/Core/Src/stm32f3xx_it.c b/Core/Src/stm32f3xx_it.c
index cc57432..e7ebefe 100644
--- a/Core/Src/stm32f3xx_it.c
+++ b/Core/Src/stm32f3xx_it.c
@@ -1,20 +1,20 @@
/* USER CODE BEGIN Header */
/**
- ******************************************************************************
- * @file stm32f3xx_it.c
- * @brief Interrupt Service Routines.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
+ ******************************************************************************
+ * @file stm32f3xx_it.c
+ * @brief Interrupt Service Routines.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
@@ -41,7 +41,7 @@
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
-
+static volatile uint32_t SysTickCnt_ms = 0;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@@ -52,6 +52,20 @@
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
+/***************************************************************************//**
+* @brief Get absolute system time ms
+*//****************************************************************************/
+uint32_t SysTimeGetAbs (void) {
+ return SysTickCnt_ms;
+}
+/***************************************************************************//**
+* @brief Get relative time ms
+*//****************************************************************************/
+int32_t SysTimeGetRel (uint32_t tref) {
+ int32_t tdif = SysTickCnt_ms - tref;
+ return tdif;
+}
+
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
@@ -64,131 +78,118 @@
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
- * @brief This function handles Non maskable interrupt.
- */
-void NMI_Handler(void)
-{
- /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
-
- /* USER CODE END NonMaskableInt_IRQn 0 */
- /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
- while (1)
- {
- }
- /* USER CODE END NonMaskableInt_IRQn 1 */
+ * @brief This function handles Non maskable interrupt.
+ */
+void NMI_Handler(void) {
+ /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
+
+ /* USER CODE END NonMaskableInt_IRQn 0 */
+ /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
+ while (1) {
+ }
+ /* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
- * @brief This function handles Hard fault interrupt.
- */
-void HardFault_Handler(void)
-{
- /* USER CODE BEGIN HardFault_IRQn 0 */
-
- /* USER CODE END HardFault_IRQn 0 */
- while (1)
- {
- /* USER CODE BEGIN W1_HardFault_IRQn 0 */
- /* USER CODE END W1_HardFault_IRQn 0 */
- }
+ * @brief This function handles Hard fault interrupt.
+ */
+void HardFault_Handler(void) {
+ /* USER CODE BEGIN HardFault_IRQn 0 */
+
+ /* USER CODE END HardFault_IRQn 0 */
+ while (1) {
+ /* USER CODE BEGIN W1_HardFault_IRQn 0 */
+ /* USER CODE END W1_HardFault_IRQn 0 */
+ }
}
/**
- * @brief This function handles Memory management fault.
- */
-void MemManage_Handler(void)
-{
- /* USER CODE BEGIN MemoryManagement_IRQn 0 */
-
- /* USER CODE END MemoryManagement_IRQn 0 */
- while (1)
- {
- /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
- /* USER CODE END W1_MemoryManagement_IRQn 0 */
- }
+ * @brief This function handles Memory management fault.
+ */
+void MemManage_Handler(void) {
+ /* USER CODE BEGIN MemoryManagement_IRQn 0 */
+
+ /* USER CODE END MemoryManagement_IRQn 0 */
+ while (1) {
+ /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
+ /* USER CODE END W1_MemoryManagement_IRQn 0 */
+ }
}
/**
- * @brief This function handles Pre-fetch fault, memory access fault.
- */
-void BusFault_Handler(void)
-{
- /* USER CODE BEGIN BusFault_IRQn 0 */
-
- /* USER CODE END BusFault_IRQn 0 */
- while (1)
- {
- /* USER CODE BEGIN W1_BusFault_IRQn 0 */
- /* USER CODE END W1_BusFault_IRQn 0 */
- }
+ * @brief This function handles Pre-fetch fault, memory access fault.
+ */
+void BusFault_Handler(void) {
+ /* USER CODE BEGIN BusFault_IRQn 0 */
+
+ /* USER CODE END BusFault_IRQn 0 */
+ while (1) {
+ /* USER CODE BEGIN W1_BusFault_IRQn 0 */
+ /* USER CODE END W1_BusFault_IRQn 0 */
+ }
}
/**
- * @brief This function handles Undefined instruction or illegal state.
- */
-void UsageFault_Handler(void)
-{
- /* USER CODE BEGIN UsageFault_IRQn 0 */
-
- /* USER CODE END UsageFault_IRQn 0 */
- while (1)
- {
- /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
- /* USER CODE END W1_UsageFault_IRQn 0 */
- }
+ * @brief This function handles Undefined instruction or illegal state.
+ */
+void UsageFault_Handler(void) {
+ /* USER CODE BEGIN UsageFault_IRQn 0 */
+
+ /* USER CODE END UsageFault_IRQn 0 */
+ while (1) {
+ /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
+ /* USER CODE END W1_UsageFault_IRQn 0 */
+ }
}
/**
- * @brief This function handles System service call via SWI instruction.
- */
-void SVC_Handler(void)
-{
- /* USER CODE BEGIN SVCall_IRQn 0 */
+ * @brief This function handles System service call via SWI instruction.
+ */
+void SVC_Handler(void) {
+ /* USER CODE BEGIN SVCall_IRQn 0 */
- /* USER CODE END SVCall_IRQn 0 */
- /* USER CODE BEGIN SVCall_IRQn 1 */
+ /* USER CODE END SVCall_IRQn 0 */
+ /* USER CODE BEGIN SVCall_IRQn 1 */
- /* USER CODE END SVCall_IRQn 1 */
+ /* USER CODE END SVCall_IRQn 1 */
}
/**
- * @brief This function handles Debug monitor.
- */
-void DebugMon_Handler(void)
-{
- /* USER CODE BEGIN DebugMonitor_IRQn 0 */
+ * @brief This function handles Debug monitor.
+ */
+void DebugMon_Handler(void) {
+ /* USER CODE BEGIN DebugMonitor_IRQn 0 */
- /* USER CODE END DebugMonitor_IRQn 0 */
- /* USER CODE BEGIN DebugMonitor_IRQn 1 */
+ /* USER CODE END DebugMonitor_IRQn 0 */
+ /* USER CODE BEGIN DebugMonitor_IRQn 1 */
- /* USER CODE END DebugMonitor_IRQn 1 */
+ /* USER CODE END DebugMonitor_IRQn 1 */
}
/**
- * @brief This function handles Pendable request for system service.
- */
-void PendSV_Handler(void)
-{
- /* USER CODE BEGIN PendSV_IRQn 0 */
+ * @brief This function handles Pendable request for system service.
+ */
+void PendSV_Handler(void) {
+ /* USER CODE BEGIN PendSV_IRQn 0 */
- /* USER CODE END PendSV_IRQn 0 */
- /* USER CODE BEGIN PendSV_IRQn 1 */
+ /* USER CODE END PendSV_IRQn 0 */
+ /* USER CODE BEGIN PendSV_IRQn 1 */
- /* USER CODE END PendSV_IRQn 1 */
+ /* USER CODE END PendSV_IRQn 1 */
}
/**
- * @brief This function handles System tick timer.
- */
-void SysTick_Handler(void)
-{
- /* USER CODE BEGIN SysTick_IRQn 0 */
+ * @brief This function handles System tick timer.
+ */
+void SysTick_Handler(void) {
+ /* USER CODE BEGIN SysTick_IRQn 0 */
+ SysTickCnt_ms++;
- /* USER CODE END SysTick_IRQn 0 */
- HAL_IncTick();
- /* USER CODE BEGIN SysTick_IRQn 1 */
+ /* USER CODE END SysTick_IRQn 0 */
+ HAL_IncTick();
+ /* USER CODE BEGIN SysTick_IRQn 1 */
- /* USER CODE END SysTick_IRQn 1 */
+ /* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
@@ -198,6 +199,30 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32f3xx.s). */
/******************************************************************************/
+/**
+ * @brief This function handles DMA1 channel6 global interrupt.
+ */
+void DMA1_Channel6_IRQHandler(void) {
+ /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
+
+ /* USER CODE END DMA1_Channel6_IRQn 0 */
+ /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
+
+ /* USER CODE END DMA1_Channel6_IRQn 1 */
+}
+
+/**
+ * @brief This function handles DMA1 channel7 global interrupt.
+ */
+void DMA1_Channel7_IRQHandler(void) {
+ /* USER CODE BEGIN DMA1_Channel7_IRQn 0 */
+
+ /* USER CODE END DMA1_Channel7_IRQn 0 */
+ /* USER CODE BEGIN DMA1_Channel7_IRQn 1 */
+
+ /* USER CODE END DMA1_Channel7_IRQn 1 */
+}
+
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Core/Src/usart.c b/Core/Src/usart.c
index 0eac176..78f8c82 100644
--- a/Core/Src/usart.c
+++ b/Core/Src/usart.c
@@ -24,9 +24,6 @@
/* USER CODE END 0 */
-UART_HandleTypeDef huart2;
-UART_HandleTypeDef huart3;
-
/* UART5 init function */
void MX_UART5_Init(void)
{
@@ -95,164 +92,132 @@ void MX_USART2_UART_Init(void)
/* USER CODE END USART2_Init 0 */
- /* USER CODE BEGIN USART2_Init 1 */
+ LL_USART_InitTypeDef USART_InitStruct = {0};
- /* USER CODE END USART2_Init 1 */
- huart2.Instance = USART2;
- huart2.Init.BaudRate = 38400;
- huart2.Init.WordLength = UART_WORDLENGTH_8B;
- huart2.Init.StopBits = UART_STOPBITS_1;
- huart2.Init.Parity = UART_PARITY_NONE;
- huart2.Init.Mode = UART_MODE_TX_RX;
- huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart2.Init.OverSampling = UART_OVERSAMPLING_16;
- huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
- huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
- if (HAL_RS485Ex_Init(&huart2, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART2_Init 2 */
+ LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
- /* USER CODE END USART2_Init 2 */
+ /* Peripheral clock enable */
+ LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
-}
-/* USART3 init function */
+ LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
+ /**USART2 GPIO Configuration
+ PA1 ------> USART2_DE
+ PA2 ------> USART2_TX
+ PA3 ------> USART2_RX
+ */
+ GPIO_InitStruct.Pin = LL_GPIO_PIN_1|USART2_TX_Pin|LL_GPIO_PIN_3;
+ GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
+ GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
+ GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
+ GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
+ LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-void MX_USART3_UART_Init(void)
-{
+ /* USART2 DMA Init */
- /* USER CODE BEGIN USART3_Init 0 */
+ /* USART2_RX Init */
+ LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_6, LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
- /* USER CODE END USART3_Init 0 */
+ LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_6, LL_DMA_PRIORITY_LOW);
- /* USER CODE BEGIN USART3_Init 1 */
+ LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_6, LL_DMA_MODE_NORMAL);
- /* USER CODE END USART3_Init 1 */
- huart3.Instance = USART3;
- huart3.Init.BaudRate = 115200;
- huart3.Init.WordLength = UART_WORDLENGTH_8B;
- huart3.Init.StopBits = UART_STOPBITS_1;
- huart3.Init.Parity = UART_PARITY_NONE;
- huart3.Init.Mode = UART_MODE_TX_RX;
- huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart3.Init.OverSampling = UART_OVERSAMPLING_16;
- huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
- huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
- if (HAL_RS485Ex_Init(&huart3, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART3_Init 2 */
+ LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_6, LL_DMA_PERIPH_NOINCREMENT);
- /* USER CODE END USART3_Init 2 */
+ LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_6, LL_DMA_MEMORY_INCREMENT);
-}
+ LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_6, LL_DMA_PDATAALIGN_BYTE);
-void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
-{
+ LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_6, LL_DMA_MDATAALIGN_BYTE);
+
+ /* USART2_TX Init */
+ LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_7, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
+
+ LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_7, LL_DMA_PRIORITY_LOW);
+
+ LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_7, LL_DMA_MODE_NORMAL);
+
+ LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_7, LL_DMA_PERIPH_NOINCREMENT);
+
+ LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_7, LL_DMA_MEMORY_INCREMENT);
+
+ LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_7, LL_DMA_PDATAALIGN_BYTE);
+
+ LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_7, LL_DMA_MDATAALIGN_BYTE);
+
+ /* USER CODE BEGIN USART2_Init 1 */
+
+ /* USER CODE END USART2_Init 1 */
+ USART_InitStruct.BaudRate = 5000000;
+ USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
+ USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
+ USART_InitStruct.Parity = LL_USART_PARITY_NONE;
+ USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
+ USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
+ USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_8;
+ LL_USART_Init(USART2, &USART_InitStruct);
+ LL_USART_EnableDEMode(USART2);
+ LL_USART_SetDESignalPolarity(USART2, LL_USART_DE_POLARITY_HIGH);
+ LL_USART_SetDEAssertionTime(USART2, 0);
+ LL_USART_SetDEDeassertionTime(USART2, 0);
+ LL_USART_ConfigAsyncMode(USART2);
+ LL_USART_Enable(USART2);
+ /* USER CODE BEGIN USART2_Init 2 */
+
+ /* USER CODE END USART2_Init 2 */
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(uartHandle->Instance==USART2)
- {
- /* USER CODE BEGIN USART2_MspInit 0 */
-
- /* USER CODE END USART2_MspInit 0 */
- /* USART2 clock enable */
- __HAL_RCC_USART2_CLK_ENABLE();
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**USART2 GPIO Configuration
- PA1 ------> USART2_DE
- PA2 ------> USART2_TX
- PA3 ------> USART2_RX
- */
- GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_3;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- GPIO_InitStruct.Pin = GPIO_PIN_2;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* USER CODE BEGIN USART2_MspInit 1 */
-
- /* USER CODE END USART2_MspInit 1 */
- }
- else if(uartHandle->Instance==USART3)
- {
- /* USER CODE BEGIN USART3_MspInit 0 */
-
- /* USER CODE END USART3_MspInit 0 */
- /* USART3 clock enable */
- __HAL_RCC_USART3_CLK_ENABLE();
-
- __HAL_RCC_GPIOB_CLK_ENABLE();
- /**USART3 GPIO Configuration
- PB10 ------> USART3_TX
- PB11 ------> USART3_RX
- PB14 ------> USART3_DE
- */
- GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_14;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- /* USER CODE BEGIN USART3_MspInit 1 */
-
- /* USER CODE END USART3_MspInit 1 */
- }
}
+/* USART3 init function */
-void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
+void MX_USART3_UART_Init(void)
{
- if(uartHandle->Instance==USART2)
- {
- /* USER CODE BEGIN USART2_MspDeInit 0 */
+ /* USER CODE BEGIN USART3_Init 0 */
- /* USER CODE END USART2_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_USART2_CLK_DISABLE();
+ /* USER CODE END USART3_Init 0 */
- /**USART2 GPIO Configuration
- PA1 ------> USART2_DE
- PA2 ------> USART2_TX
- PA3 ------> USART2_RX
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
+ LL_USART_InitTypeDef USART_InitStruct = {0};
- /* USER CODE BEGIN USART2_MspDeInit 1 */
+ LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
- /* USER CODE END USART2_MspDeInit 1 */
- }
- else if(uartHandle->Instance==USART3)
- {
- /* USER CODE BEGIN USART3_MspDeInit 0 */
+ /* Peripheral clock enable */
+ LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
- /* USER CODE END USART3_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_USART3_CLK_DISABLE();
+ LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
+ /**USART3 GPIO Configuration
+ PB10 ------> USART3_TX
+ PB11 ------> USART3_RX
+ PB14 ------> USART3_DE
+ */
+ GPIO_InitStruct.Pin = LL_GPIO_PIN_10|LL_GPIO_PIN_11|LL_GPIO_PIN_14;
+ GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
+ GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
+ GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
+ GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
+ LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN USART3_Init 1 */
- /**USART3 GPIO Configuration
- PB10 ------> USART3_TX
- PB11 ------> USART3_RX
- PB14 ------> USART3_DE
- */
- HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_14);
+ /* USER CODE END USART3_Init 1 */
+ USART_InitStruct.BaudRate = 115200;
+ USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
+ USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
+ USART_InitStruct.Parity = LL_USART_PARITY_NONE;
+ USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
+ USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
+ USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
+ LL_USART_Init(USART3, &USART_InitStruct);
+ LL_USART_EnableDEMode(USART3);
+ LL_USART_SetDESignalPolarity(USART3, LL_USART_DE_POLARITY_HIGH);
+ LL_USART_SetDEAssertionTime(USART3, 0);
+ LL_USART_SetDEDeassertionTime(USART3, 0);
+ LL_USART_ConfigAsyncMode(USART3);
+ LL_USART_Enable(USART3);
+ /* USER CODE BEGIN USART3_Init 2 */
- /* USER CODE BEGIN USART3_MspDeInit 1 */
+ /* USER CODE END USART3_Init 2 */
- /* USER CODE END USART3_MspDeInit 1 */
- }
}
/* USER CODE BEGIN 1 */
diff --git a/Core/user/uart5_it.c b/Core/user/uart5_it.c
index 5b7dca1..f0610fe 100644
--- a/Core/user/uart5_it.c
+++ b/Core/user/uart5_it.c
@@ -1,7 +1,7 @@
/***************************************************************************//**
-* @file uart5_it.c
-* @brief UART with interrupt and ring buffer
-*//****************************************************************************/
+ * @file uart5_it.c
+ * @brief UART with interrupt and ring buffer
+ *//****************************************************************************/
#include "uart5_it.h"
@@ -11,9 +11,6 @@
#include "uart5_it_cfg.h"
//------------------------------------------------------------------------------
-
-
-
/* Private typedefs ----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
@@ -30,43 +27,38 @@
#error TX buffer size is not a power of 2!
#endif
-
/* Private variables ---------------------------------------------------------*/
//====== Variables for transmitter =============================================
-static uint8_t Uart5TxBuf[UART5_TXBUF_SIZE];
-static uint16_t Uart5TxWrIdx = 0;
+static uint8_t Uart5TxBuf[UART5_TXBUF_SIZE];
+static uint16_t Uart5TxWrIdx = 0;
static volatile uint16_t Uart5TxRdIdx = 0;
//====== Variables for Receiver ================================================
-static uint8_t Uart5RxBuf[UART5_RXBUF_SIZE];
+static uint8_t Uart5RxBuf[UART5_RXBUF_SIZE];
static volatile uint16_t Uart5RxWrIdx = 0;
static volatile uint16_t Uart5RxRdIdx = 0;
-
/* Public variables ----------------------------------------------------------*/
-
/* Functions -----------------------------------------------------------------*/
-
/***************************************************************************//**
-* @brief UART5 init
-*//****************************************************************************/
+ * @brief UART5 init
+ *//****************************************************************************/
void Uart5_Init(void) {
- LL_USART_EnableIT_RXNE(UART5); //UART5->CR1 |= UART_CR1_RXNEIE; // Enable RX interrupt
+ LL_USART_EnableIT_RXNE(UART5); //UART5->CR1 |= UART_CR1_RXNEIE; // Enable RX interrupt
}
-
/***************************************************************************//**
-* @brief UART5 interrupt handler
-*//****************************************************************************/
+ * @brief UART5 interrupt handler
+ *//****************************************************************************/
void UART5_IRQHandler(void) {
if (LL_USART_IsActiveFlag_RXNE(UART5)) { // RX interrupt
uint8_t d = LL_USART_ReceiveData8(UART5); // read received byte
uint_fast16_t wr = Uart5RxWrIdx;
wr = (wr + 1) & UART5_RXBUF_MASK; // new write index
- Uart5RxBuf[wr] = d; // received data to buffer
+ Uart5RxBuf[wr] = d; // received data to buffer
Uart5RxWrIdx = wr; // Store new index
}
@@ -84,35 +76,33 @@ void UART5_IRQHandler(void) {
}
}
-
/***************************************************************************//**
-* @brief Send byte to UART
-* @param d: byte to send
-*//****************************************************************************/
+ * @brief Send byte to UART
+ * @param d: byte to send
+ *//****************************************************************************/
void Uart5_PutByte(uint8_t d) {
uint_fast16_t wr = Uart5TxWrIdx;
wr = (wr + 1) & UART5_TXBUF_MASK; // new write index
if (wr == Uart5TxRdIdx) { // No free space in buffer (overflow)
- return; // drop remaining data (Attention! Buffer overflow not signaled! Use bigger buffer)
+ return; // drop remaining data (Attention! Buffer overflow not signaled! Use bigger buffer)
}
Uart5TxBuf[wr] = d; // Store data in buffer
Uart5TxWrIdx = wr; // Store new index
LL_USART_EnableIT_TXE(UART5); // Interrupt enable (start send)
}
-
/***************************************************************************//**
-* @brief Send more data to UART
-* @param src: data to send
-* @param n: count of data
-*//****************************************************************************/
-void Uart5_PutData (void* src, uint16_t n) {
- uint8_t* p = src;
+ * @brief Send more data to UART
+ * @param src: data to send
+ * @param n: count of data
+ *//****************************************************************************/
+void Uart5_PutData(void *src, uint16_t n) {
+ uint8_t *p = src;
uint_fast16_t wr = Uart5TxWrIdx;
while (n) {
wr = (wr + 1) & UART5_TXBUF_MASK; // new write index
if (wr == Uart5TxRdIdx) { // No free space in buffer (overflow)
- break; // drop remaining data (Attention! Buffer overflow not signaled! Use bigger buffer)
+ break; // drop remaining data (Attention! Buffer overflow not signaled! Use bigger buffer)
}
Uart5TxBuf[wr] = *p; // Store data in buffer
p++;
@@ -123,16 +113,16 @@ void Uart5_PutData (void* src, uint16_t n) {
}
/***************************************************************************//**
-* @brief Read data from UART RX buffer
-* @return received character, -1: no data in RX buffer
-*//****************************************************************************/
+ * @brief Read data from UART RX buffer
+ * @return received character, -1: no data in RX buffer
+ *//****************************************************************************/
int16_t Uart5_GetByte(void) {
uint_fast16_t rd = Uart5RxRdIdx;
if (rd != Uart5RxWrIdx) { // new data in buffer
rd = (rd + 1) & UART5_RXBUF_MASK; // new read index
Uart5RxRdIdx = rd; // store new index
return Uart5RxBuf[rd]; // return with data
- }else {
+ } else {
return -1; // buffer empty
}
}
diff --git a/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_uart.h b/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_uart.h
deleted file mode 100644
index d57ae55..0000000
--- a/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_uart.h
+++ /dev/null
@@ -1,1588 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32f3xx_hal_uart.h
- * @author MCD Application Team
- * @brief Header file of UART HAL module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2016 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32F3xx_HAL_UART_H
-#define STM32F3xx_HAL_UART_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f3xx_hal_def.h"
-
-/** @addtogroup STM32F3xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup UART
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/** @defgroup UART_Exported_Types UART Exported Types
- * @{
- */
-
-/**
- * @brief UART Init Structure definition
- */
-typedef struct
-{
- uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
- The baud rate register is computed using the following formula:
- - If oversampling is 16 or in LIN mode,
- Baud Rate Register = ((uart_ker_ck) / ((huart->Init.BaudRate)))
- - If oversampling is 8,
- Baud Rate Register[15:4] = ((2 * uart_ker_ck) /
- ((huart->Init.BaudRate)))[15:4]
- Baud Rate Register[3] = 0
- Baud Rate Register[2:0] = (((2 * uart_ker_ck) /
- ((huart->Init.BaudRate)))[3:0]) >> 1
- where uart_ker_ck is the UART input clock */
-
- uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
- This parameter can be a value of @ref UARTEx_Word_Length. */
-
- uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
- This parameter can be a value of @ref UART_Stop_Bits. */
-
- uint32_t Parity; /*!< Specifies the parity mode.
- This parameter can be a value of @ref UART_Parity
- @note When parity is enabled, the computed parity is inserted
- at the MSB position of the transmitted data (9th bit when
- the word length is set to 9 data bits; 8th bit when the
- word length is set to 8 data bits). */
-
- uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
- This parameter can be a value of @ref UART_Mode. */
-
- uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
- or disabled.
- This parameter can be a value of @ref UART_Hardware_Flow_Control. */
-
- uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled,
- to achieve higher speed (up to f_PCLK/8).
- This parameter can be a value of @ref UART_Over_Sampling. */
-
- uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
- Selecting the single sample method increases the receiver tolerance to clock
- deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
-
-
-} UART_InitTypeDef;
-
-/**
- * @brief UART Advanced Features initialization structure definition
- */
-typedef struct
-{
- uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
- Advanced Features may be initialized at the same time .
- This parameter can be a value of
- @ref UART_Advanced_Features_Initialization_Type. */
-
- uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
- This parameter can be a value of @ref UART_Tx_Inv. */
-
- uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
- This parameter can be a value of @ref UART_Rx_Inv. */
-
- uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
- vs negative/inverted logic).
- This parameter can be a value of @ref UART_Data_Inv. */
-
- uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
- This parameter can be a value of @ref UART_Rx_Tx_Swap. */
-
- uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
- This parameter can be a value of @ref UART_Overrun_Disable. */
-
- uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
- This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error. */
-
- uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
- This parameter can be a value of @ref UART_AutoBaudRate_Enable. */
-
- uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
- detection is carried out.
- This parameter can be a value of @ref UART_AutoBaud_Rate_Mode. */
-
- uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
- This parameter can be a value of @ref UART_MSB_First. */
-} UART_AdvFeatureInitTypeDef;
-
-/**
- * @brief HAL UART State definition
- * @note HAL UART State value is a combination of 2 different substates:
- * gState and RxState (see @ref UART_State_Definition).
- * - gState contains UART state information related to global Handle management
- * and also information related to Tx operations.
- * gState value coding follow below described bitmap :
- * b7-b6 Error information
- * 00 : No Error
- * 01 : (Not Used)
- * 10 : Timeout
- * 11 : Error
- * b5 Peripheral initialization status
- * 0 : Reset (Peripheral not initialized)
- * 1 : Init done (Peripheral initialized. HAL UART Init function already called)
- * b4-b3 (not used)
- * xx : Should be set to 00
- * b2 Intrinsic process state
- * 0 : Ready
- * 1 : Busy (Peripheral busy with some configuration or internal operations)
- * b1 (not used)
- * x : Should be set to 0
- * b0 Tx state
- * 0 : Ready (no Tx operation ongoing)
- * 1 : Busy (Tx operation ongoing)
- * - RxState contains information related to Rx operations.
- * RxState value coding follow below described bitmap :
- * b7-b6 (not used)
- * xx : Should be set to 00
- * b5 Peripheral initialization status
- * 0 : Reset (Peripheral not initialized)
- * 1 : Init done (Peripheral initialized)
- * b4-b2 (not used)
- * xxx : Should be set to 000
- * b1 Rx state
- * 0 : Ready (no Rx operation ongoing)
- * 1 : Busy (Rx operation ongoing)
- * b0 (not used)
- * x : Should be set to 0.
- */
-typedef uint32_t HAL_UART_StateTypeDef;
-
-/**
- * @brief UART clock sources definition
- */
-typedef enum
-{
- UART_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */
- UART_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */
- UART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
- UART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */
- UART_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */
- UART_CLOCKSOURCE_UNDEFINED = 0x10U /*!< Undefined clock source */
-} UART_ClockSourceTypeDef;
-
-/**
- * @brief HAL UART Reception type definition
- * @note HAL UART Reception type value aims to identify which type of Reception is ongoing.
- * This parameter can be a value of @ref UART_Reception_Type_Values :
- * HAL_UART_RECEPTION_STANDARD = 0x00U,
- * HAL_UART_RECEPTION_TOIDLE = 0x01U,
- * HAL_UART_RECEPTION_TORTO = 0x02U,
- * HAL_UART_RECEPTION_TOCHARMATCH = 0x03U,
- */
-typedef uint32_t HAL_UART_RxTypeTypeDef;
-
-/**
- * @brief HAL UART Rx Event type definition
- * @note HAL UART Rx Event type value aims to identify which type of Event has occurred
- * leading to call of the RxEvent callback.
- * This parameter can be a value of @ref UART_RxEvent_Type_Values :
- * HAL_UART_RXEVENT_TC = 0x00U,
- * HAL_UART_RXEVENT_HT = 0x01U,
- * HAL_UART_RXEVENT_IDLE = 0x02U,
- */
-typedef uint32_t HAL_UART_RxEventTypeTypeDef;
-
-/**
- * @brief UART handle Structure definition
- */
-typedef struct __UART_HandleTypeDef
-{
- USART_TypeDef *Instance; /*!< UART registers base address */
-
- UART_InitTypeDef Init; /*!< UART communication parameters */
-
- UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
-
- const uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
-
- uint16_t TxXferSize; /*!< UART Tx Transfer size */
-
- __IO uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
-
- uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
-
- uint16_t RxXferSize; /*!< UART Rx Transfer size */
-
- __IO uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
-
- uint16_t Mask; /*!< UART Rx RDR register mask */
-
- __IO HAL_UART_RxTypeTypeDef ReceptionType; /*!< Type of ongoing reception */
-
- __IO HAL_UART_RxEventTypeTypeDef RxEventType; /*!< Type of Rx Event */
-
- void (*RxISR)(struct __UART_HandleTypeDef *huart); /*!< Function pointer on Rx IRQ handler */
-
- void (*TxISR)(struct __UART_HandleTypeDef *huart); /*!< Function pointer on Tx IRQ handler */
-
- DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
-
- DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
-
- HAL_LockTypeDef Lock; /*!< Locking object */
-
- __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
- and also related to Tx operations. This parameter
- can be a value of @ref HAL_UART_StateTypeDef */
-
- __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations. This
- parameter can be a value of @ref HAL_UART_StateTypeDef */
-
- __IO uint32_t ErrorCode; /*!< UART Error code */
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- void (* TxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Half Complete Callback */
- void (* TxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Complete Callback */
- void (* RxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Half Complete Callback */
- void (* RxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Complete Callback */
- void (* ErrorCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Error Callback */
- void (* AbortCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Complete Callback */
- void (* AbortTransmitCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Transmit Complete Callback */
- void (* AbortReceiveCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Receive Complete Callback */
- void (* WakeupCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Wakeup Callback */
- void (* RxEventCallback)(struct __UART_HandleTypeDef *huart, uint16_t Pos); /*!< UART Reception Event Callback */
-
- void (* MspInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp Init callback */
- void (* MspDeInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp DeInit callback */
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-} UART_HandleTypeDef;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-/**
- * @brief HAL UART Callback ID enumeration definition
- */
-typedef enum
-{
- HAL_UART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< UART Tx Half Complete Callback ID */
- HAL_UART_TX_COMPLETE_CB_ID = 0x01U, /*!< UART Tx Complete Callback ID */
- HAL_UART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< UART Rx Half Complete Callback ID */
- HAL_UART_RX_COMPLETE_CB_ID = 0x03U, /*!< UART Rx Complete Callback ID */
- HAL_UART_ERROR_CB_ID = 0x04U, /*!< UART Error Callback ID */
- HAL_UART_ABORT_COMPLETE_CB_ID = 0x05U, /*!< UART Abort Complete Callback ID */
- HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< UART Abort Transmit Complete Callback ID */
- HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< UART Abort Receive Complete Callback ID */
- HAL_UART_WAKEUP_CB_ID = 0x08U, /*!< UART Wakeup Callback ID */
-
- HAL_UART_MSPINIT_CB_ID = 0x0BU, /*!< UART MspInit callback ID */
- HAL_UART_MSPDEINIT_CB_ID = 0x0CU /*!< UART MspDeInit callback ID */
-
-} HAL_UART_CallbackIDTypeDef;
-
-/**
- * @brief HAL UART Callback pointer definition
- */
-typedef void (*pUART_CallbackTypeDef)(UART_HandleTypeDef *huart); /*!< pointer to an UART callback function */
-typedef void (*pUART_RxEventCallbackTypeDef)
-(struct __UART_HandleTypeDef *huart, uint16_t Pos); /*!< pointer to a UART Rx Event specific callback function */
-
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/* Exported constants --------------------------------------------------------*/
-/** @defgroup UART_Exported_Constants UART Exported Constants
- * @{
- */
-
-/** @defgroup UART_State_Definition UART State Code Definition
- * @{
- */
-#define HAL_UART_STATE_RESET 0x00000000U /*!< Peripheral is not initialized
- Value is allowed for gState and RxState */
-#define HAL_UART_STATE_READY 0x00000020U /*!< Peripheral Initialized and ready for use
- Value is allowed for gState and RxState */
-#define HAL_UART_STATE_BUSY 0x00000024U /*!< an internal process is ongoing
- Value is allowed for gState only */
-#define HAL_UART_STATE_BUSY_TX 0x00000021U /*!< Data Transmission process is ongoing
- Value is allowed for gState only */
-#define HAL_UART_STATE_BUSY_RX 0x00000022U /*!< Data Reception process is ongoing
- Value is allowed for RxState only */
-#define HAL_UART_STATE_BUSY_TX_RX 0x00000023U /*!< Data Transmission and Reception process is ongoing
- Not to be used for neither gState nor RxState.Value is result
- of combination (Or) between gState and RxState values */
-#define HAL_UART_STATE_TIMEOUT 0x000000A0U /*!< Timeout state
- Value is allowed for gState only */
-#define HAL_UART_STATE_ERROR 0x000000E0U /*!< Error
- Value is allowed for gState only */
-/**
- * @}
- */
-
-/** @defgroup UART_Error_Definition UART Error Definition
- * @{
- */
-#define HAL_UART_ERROR_NONE (0x00000000U) /*!< No error */
-#define HAL_UART_ERROR_PE (0x00000001U) /*!< Parity error */
-#define HAL_UART_ERROR_NE (0x00000002U) /*!< Noise error */
-#define HAL_UART_ERROR_FE (0x00000004U) /*!< Frame error */
-#define HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error */
-#define HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
-#define HAL_UART_ERROR_RTO (0x00000020U) /*!< Receiver Timeout error */
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-#define HAL_UART_ERROR_INVALID_CALLBACK (0x00000040U) /*!< Invalid Callback error */
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-/**
- * @}
- */
-
-/** @defgroup UART_Stop_Bits UART Number of Stop Bits
- * @{
- */
-#define UART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< UART frame with 0.5 stop bit */
-#define UART_STOPBITS_1 0x00000000U /*!< UART frame with 1 stop bit */
-#define UART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< UART frame with 1.5 stop bits */
-#define UART_STOPBITS_2 USART_CR2_STOP_1 /*!< UART frame with 2 stop bits */
-/**
- * @}
- */
-
-/** @defgroup UART_Parity UART Parity
- * @{
- */
-#define UART_PARITY_NONE 0x00000000U /*!< No parity */
-#define UART_PARITY_EVEN USART_CR1_PCE /*!< Even parity */
-#define UART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */
-/**
- * @}
- */
-
-/** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
- * @{
- */
-#define UART_HWCONTROL_NONE 0x00000000U /*!< No hardware control */
-#define UART_HWCONTROL_RTS USART_CR3_RTSE /*!< Request To Send */
-#define UART_HWCONTROL_CTS USART_CR3_CTSE /*!< Clear To Send */
-#define UART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< Request and Clear To Send */
-/**
- * @}
- */
-
-/** @defgroup UART_Mode UART Transfer Mode
- * @{
- */
-#define UART_MODE_RX USART_CR1_RE /*!< RX mode */
-#define UART_MODE_TX USART_CR1_TE /*!< TX mode */
-#define UART_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */
-/**
- * @}
- */
-
-/** @defgroup UART_State UART State
- * @{
- */
-#define UART_STATE_DISABLE 0x00000000U /*!< UART disabled */
-#define UART_STATE_ENABLE USART_CR1_UE /*!< UART enabled */
-/**
- * @}
- */
-
-/** @defgroup UART_Over_Sampling UART Over Sampling
- * @{
- */
-#define UART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */
-#define UART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
-/**
- * @}
- */
-
-/** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
- * @{
- */
-#define UART_ONE_BIT_SAMPLE_DISABLE 0x00000000U /*!< One-bit sampling disable */
-#define UART_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT /*!< One-bit sampling enable */
-/**
- * @}
- */
-
-/** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
- * @{
- */
-#define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT 0x00000000U /*!< Auto Baud rate detection
- on start bit */
-#define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE USART_CR2_ABRMODE_0 /*!< Auto Baud rate detection
- on falling edge */
-#define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME USART_CR2_ABRMODE_1 /*!< Auto Baud rate detection
- on 0x7F frame detection */
-#define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME USART_CR2_ABRMODE /*!< Auto Baud rate detection
- on 0x55 frame detection */
-/**
- * @}
- */
-
-/** @defgroup UART_Receiver_Timeout UART Receiver Timeout
- * @{
- */
-#define UART_RECEIVER_TIMEOUT_DISABLE 0x00000000U /*!< UART Receiver Timeout disable */
-#define UART_RECEIVER_TIMEOUT_ENABLE USART_CR2_RTOEN /*!< UART Receiver Timeout enable */
-/**
- * @}
- */
-
-/** @defgroup UART_LIN UART Local Interconnection Network mode
- * @{
- */
-#define UART_LIN_DISABLE 0x00000000U /*!< Local Interconnect Network disable */
-#define UART_LIN_ENABLE USART_CR2_LINEN /*!< Local Interconnect Network enable */
-/**
- * @}
- */
-
-/** @defgroup UART_LIN_Break_Detection UART LIN Break Detection
- * @{
- */
-#define UART_LINBREAKDETECTLENGTH_10B 0x00000000U /*!< LIN 10-bit break detection length */
-#define UART_LINBREAKDETECTLENGTH_11B USART_CR2_LBDL /*!< LIN 11-bit break detection length */
-/**
- * @}
- */
-
-/** @defgroup UART_DMA_Tx UART DMA Tx
- * @{
- */
-#define UART_DMA_TX_DISABLE 0x00000000U /*!< UART DMA TX disabled */
-#define UART_DMA_TX_ENABLE USART_CR3_DMAT /*!< UART DMA TX enabled */
-/**
- * @}
- */
-
-/** @defgroup UART_DMA_Rx UART DMA Rx
- * @{
- */
-#define UART_DMA_RX_DISABLE 0x00000000U /*!< UART DMA RX disabled */
-#define UART_DMA_RX_ENABLE USART_CR3_DMAR /*!< UART DMA RX enabled */
-/**
- * @}
- */
-
-/** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
- * @{
- */
-#define UART_HALF_DUPLEX_DISABLE 0x00000000U /*!< UART half-duplex disabled */
-#define UART_HALF_DUPLEX_ENABLE USART_CR3_HDSEL /*!< UART half-duplex enabled */
-/**
- * @}
- */
-
-/** @defgroup UART_WakeUp_Methods UART WakeUp Methods
- * @{
- */
-#define UART_WAKEUPMETHOD_IDLELINE 0x00000000U /*!< UART wake-up on idle line */
-#define UART_WAKEUPMETHOD_ADDRESSMARK USART_CR1_WAKE /*!< UART wake-up on address mark */
-/**
- * @}
- */
-
-/** @defgroup UART_Request_Parameters UART Request Parameters
- * @{
- */
-#define UART_AUTOBAUD_REQUEST USART_RQR_ABRRQ /*!< Auto-Baud Rate Request */
-#define UART_SENDBREAK_REQUEST USART_RQR_SBKRQ /*!< Send Break Request */
-#define UART_MUTE_MODE_REQUEST USART_RQR_MMRQ /*!< Mute Mode Request */
-#define UART_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */
-#define UART_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */
-/**
- * @}
- */
-
-/** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
- * @{
- */
-#define UART_ADVFEATURE_NO_INIT 0x00000000U /*!< No advanced feature initialization */
-#define UART_ADVFEATURE_TXINVERT_INIT 0x00000001U /*!< TX pin active level inversion */
-#define UART_ADVFEATURE_RXINVERT_INIT 0x00000002U /*!< RX pin active level inversion */
-#define UART_ADVFEATURE_DATAINVERT_INIT 0x00000004U /*!< Binary data inversion */
-#define UART_ADVFEATURE_SWAP_INIT 0x00000008U /*!< TX/RX pins swap */
-#define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT 0x00000010U /*!< RX overrun disable */
-#define UART_ADVFEATURE_DMADISABLEONERROR_INIT 0x00000020U /*!< DMA disable on Reception Error */
-#define UART_ADVFEATURE_AUTOBAUDRATE_INIT 0x00000040U /*!< Auto Baud rate detection initialization */
-#define UART_ADVFEATURE_MSBFIRST_INIT 0x00000080U /*!< Most significant bit sent/received first */
-/**
- * @}
- */
-
-/** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
- * @{
- */
-#define UART_ADVFEATURE_TXINV_DISABLE 0x00000000U /*!< TX pin active level inversion disable */
-#define UART_ADVFEATURE_TXINV_ENABLE USART_CR2_TXINV /*!< TX pin active level inversion enable */
-/**
- * @}
- */
-
-/** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
- * @{
- */
-#define UART_ADVFEATURE_RXINV_DISABLE 0x00000000U /*!< RX pin active level inversion disable */
-#define UART_ADVFEATURE_RXINV_ENABLE USART_CR2_RXINV /*!< RX pin active level inversion enable */
-/**
- * @}
- */
-
-/** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
- * @{
- */
-#define UART_ADVFEATURE_DATAINV_DISABLE 0x00000000U /*!< Binary data inversion disable */
-#define UART_ADVFEATURE_DATAINV_ENABLE USART_CR2_DATAINV /*!< Binary data inversion enable */
-/**
- * @}
- */
-
-/** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
- * @{
- */
-#define UART_ADVFEATURE_SWAP_DISABLE 0x00000000U /*!< TX/RX pins swap disable */
-#define UART_ADVFEATURE_SWAP_ENABLE USART_CR2_SWAP /*!< TX/RX pins swap enable */
-/**
- * @}
- */
-
-/** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
- * @{
- */
-#define UART_ADVFEATURE_OVERRUN_ENABLE 0x00000000U /*!< RX overrun enable */
-#define UART_ADVFEATURE_OVERRUN_DISABLE USART_CR3_OVRDIS /*!< RX overrun disable */
-/**
- * @}
- */
-
-/** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
- * @{
- */
-#define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE 0x00000000U /*!< RX Auto Baud rate detection enable */
-#define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE USART_CR2_ABREN /*!< RX Auto Baud rate detection disable */
-/**
- * @}
- */
-
-/** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
- * @{
- */
-#define UART_ADVFEATURE_DMA_ENABLEONRXERROR 0x00000000U /*!< DMA enable on Reception Error */
-#define UART_ADVFEATURE_DMA_DISABLEONRXERROR USART_CR3_DDRE /*!< DMA disable on Reception Error */
-/**
- * @}
- */
-
-/** @defgroup UART_MSB_First UART Advanced Feature MSB First
- * @{
- */
-#define UART_ADVFEATURE_MSBFIRST_DISABLE 0x00000000U /*!< Most significant bit sent/received
- first disable */
-#define UART_ADVFEATURE_MSBFIRST_ENABLE USART_CR2_MSBFIRST /*!< Most significant bit sent/received
- first enable */
-/**
- * @}
- */
-
-/** @defgroup UART_Stop_Mode_Enable UART Advanced Feature Stop Mode Enable
- * @{
- */
-#define UART_ADVFEATURE_STOPMODE_DISABLE 0x00000000U /*!< UART stop mode disable */
-#define UART_ADVFEATURE_STOPMODE_ENABLE USART_CR1_UESM /*!< UART stop mode enable */
-/**
- * @}
- */
-
-/** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
- * @{
- */
-#define UART_ADVFEATURE_MUTEMODE_DISABLE 0x00000000U /*!< UART mute mode disable */
-#define UART_ADVFEATURE_MUTEMODE_ENABLE USART_CR1_MME /*!< UART mute mode enable */
-/**
- * @}
- */
-
-/** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
- * @{
- */
-#define UART_CR2_ADDRESS_LSB_POS 24U /*!< UART address-matching LSB position in CR2 register */
-/**
- * @}
- */
-
-/** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection
- * @{
- */
-#define UART_WAKEUP_ON_ADDRESS 0x00000000U /*!< UART wake-up on address */
-#define UART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< UART wake-up on start bit */
-#define UART_WAKEUP_ON_READDATA_NONEMPTY USART_CR3_WUS /*!< UART wake-up on receive data register
- not empty or RXFIFO is not empty */
-/**
- * @}
- */
-
-/** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
- * @{
- */
-#define UART_DE_POLARITY_HIGH 0x00000000U /*!< Driver enable signal is active high */
-#define UART_DE_POLARITY_LOW USART_CR3_DEP /*!< Driver enable signal is active low */
-/**
- * @}
- */
-
-/** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
- * @{
- */
-#define UART_CR1_DEAT_ADDRESS_LSB_POS 21U /*!< UART Driver Enable assertion time LSB
- position in CR1 register */
-/**
- * @}
- */
-
-/** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
- * @{
- */
-#define UART_CR1_DEDT_ADDRESS_LSB_POS 16U /*!< UART Driver Enable de-assertion time LSB
- position in CR1 register */
-/**
- * @}
- */
-
-/** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
- * @{
- */
-#define UART_IT_MASK 0x001FU /*!< UART interruptions flags mask */
-/**
- * @}
- */
-
-/** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
- * @{
- */
-#define HAL_UART_TIMEOUT_VALUE 0x1FFFFFFU /*!< UART polling-based communications time-out value */
-/**
- * @}
- */
-
-/** @defgroup UART_Flags UART Status Flags
- * Elements values convention: 0xXXXX
- * - 0xXXXX : Flag mask in the ISR register
- * @{
- */
-#define UART_FLAG_REACK USART_ISR_REACK /*!< UART receive enable acknowledge flag */
-#define UART_FLAG_TEACK USART_ISR_TEACK /*!< UART transmit enable acknowledge flag */
-#define UART_FLAG_WUF USART_ISR_WUF /*!< UART wake-up from stop mode flag */
-#define UART_FLAG_RWU USART_ISR_RWU /*!< UART receiver wake-up from mute mode flag */
-#define UART_FLAG_SBKF USART_ISR_SBKF /*!< UART send break flag */
-#define UART_FLAG_CMF USART_ISR_CMF /*!< UART character match flag */
-#define UART_FLAG_BUSY USART_ISR_BUSY /*!< UART busy flag */
-#define UART_FLAG_ABRF USART_ISR_ABRF /*!< UART auto Baud rate flag */
-#define UART_FLAG_ABRE USART_ISR_ABRE /*!< UART auto Baud rate error */
-#define UART_FLAG_RTOF USART_ISR_RTOF /*!< UART receiver timeout flag */
-#define UART_FLAG_CTS USART_ISR_CTS /*!< UART clear to send flag */
-#define UART_FLAG_CTSIF USART_ISR_CTSIF /*!< UART clear to send interrupt flag */
-#define UART_FLAG_LBDF USART_ISR_LBDF /*!< UART LIN break detection flag */
-#define UART_FLAG_TXE USART_ISR_TXE /*!< UART transmit data register empty */
-#define UART_FLAG_TC USART_ISR_TC /*!< UART transmission complete */
-#define UART_FLAG_RXNE USART_ISR_RXNE /*!< UART read data register not empty */
-#define UART_FLAG_IDLE USART_ISR_IDLE /*!< UART idle flag */
-#define UART_FLAG_ORE USART_ISR_ORE /*!< UART overrun error */
-#define UART_FLAG_NE USART_ISR_NE /*!< UART noise error */
-#define UART_FLAG_FE USART_ISR_FE /*!< UART frame error */
-#define UART_FLAG_PE USART_ISR_PE /*!< UART parity error */
-/**
- * @}
- */
-
-/** @defgroup UART_Interrupt_definition UART Interrupts Definition
- * Elements values convention: 000ZZZZZ0XXYYYYYb
- * - YYYYY : Interrupt source position in the XX register (5bits)
- * - XX : Interrupt source register (2bits)
- * - 01: CR1 register
- * - 10: CR2 register
- * - 11: CR3 register
- * - ZZZZZ : Flag position in the ISR register(5bits)
- * Elements values convention: 000000000XXYYYYYb
- * - YYYYY : Interrupt source position in the XX register (5bits)
- * - XX : Interrupt source register (2bits)
- * - 01: CR1 register
- * - 10: CR2 register
- * - 11: CR3 register
- * Elements values convention: 0000ZZZZ00000000b
- * - ZZZZ : Flag position in the ISR register(4bits)
- * @{
- */
-#define UART_IT_PE 0x0028U /*!< UART parity error interruption */
-#define UART_IT_TXE 0x0727U /*!< UART transmit data register empty interruption */
-#define UART_IT_TC 0x0626U /*!< UART transmission complete interruption */
-#define UART_IT_RXNE 0x0525U /*!< UART read data register not empty interruption */
-#define UART_IT_IDLE 0x0424U /*!< UART idle interruption */
-#define UART_IT_LBD 0x0846U /*!< UART LIN break detection interruption */
-#define UART_IT_CTS 0x096AU /*!< UART CTS interruption */
-#define UART_IT_CM 0x112EU /*!< UART character match interruption */
-#define UART_IT_WUF 0x1476U /*!< UART wake-up from stop mode interruption */
-#define UART_IT_RTO 0x0B3AU /*!< UART receiver timeout interruption */
-
-#define UART_IT_ERR 0x0060U /*!< UART error interruption */
-
-#define UART_IT_ORE 0x0300U /*!< UART overrun error interruption */
-#define UART_IT_NE 0x0200U /*!< UART noise error interruption */
-#define UART_IT_FE 0x0100U /*!< UART frame error interruption */
-/**
- * @}
- */
-
-/** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags
- * @{
- */
-#define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
-#define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
-#define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise Error detected Clear Flag */
-#define UART_CLEAR_OREF USART_ICR_ORECF /*!< Overrun Error Clear Flag */
-#define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
-#define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
-#define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
-#define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
-#define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
-#define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
-#define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< UART receiver timeout clear flag */
-/**
- * @}
- */
-
-/** @defgroup UART_Reception_Type_Values UART Reception type values
- * @{
- */
-#define HAL_UART_RECEPTION_STANDARD (0x00000000U) /*!< Standard reception */
-#define HAL_UART_RECEPTION_TOIDLE (0x00000001U) /*!< Reception till completion or IDLE event */
-#define HAL_UART_RECEPTION_TORTO (0x00000002U) /*!< Reception till completion or RTO event */
-#define HAL_UART_RECEPTION_TOCHARMATCH (0x00000003U) /*!< Reception till completion or CM event */
-/**
- * @}
- */
-
-/** @defgroup UART_RxEvent_Type_Values UART RxEvent type values
- * @{
- */
-#define HAL_UART_RXEVENT_TC (0x00000000U) /*!< RxEvent linked to Transfer Complete event */
-#define HAL_UART_RXEVENT_HT (0x00000001U) /*!< RxEvent linked to Half Transfer event */
-#define HAL_UART_RXEVENT_IDLE (0x00000002U) /*!< RxEvent linked to IDLE event */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Exported macros -----------------------------------------------------------*/
-/** @defgroup UART_Exported_Macros UART Exported Macros
- * @{
- */
-
-/** @brief Reset UART handle states.
- * @param __HANDLE__ UART handle.
- * @retval None
- */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
- (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
- (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
- (__HANDLE__)->MspInitCallback = NULL; \
- (__HANDLE__)->MspDeInitCallback = NULL; \
- } while(0U)
-#else
-#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
- (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
- (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
- } while(0U)
-#endif /*USE_HAL_UART_REGISTER_CALLBACKS */
-
-/** @brief Flush the UART Data registers.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
- do{ \
- SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
- SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
- } while(0U)
-
-/** @brief Clear the specified UART pending flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __FLAG__ specifies the flag to check.
- * This parameter can be any combination of the following values:
- * @arg @ref UART_CLEAR_PEF Parity Error Clear Flag
- * @arg @ref UART_CLEAR_FEF Framing Error Clear Flag
- * @arg @ref UART_CLEAR_NEF Noise detected Clear Flag
- * @arg @ref UART_CLEAR_OREF Overrun Error Clear Flag
- * @arg @ref UART_CLEAR_IDLEF IDLE line detected Clear Flag
- * @arg @ref UART_CLEAR_TCF Transmission Complete Clear Flag
- * @arg @ref UART_CLEAR_RTOF Receiver Timeout clear flag
- * @arg @ref UART_CLEAR_LBDF LIN Break Detection Clear Flag
- * @arg @ref UART_CLEAR_CTSF CTS Interrupt Clear Flag
- * @arg @ref UART_CLEAR_CMF Character Match Clear Flag
- * @arg @ref UART_CLEAR_WUF Wake Up from stop mode Clear Flag
- * @retval None
- */
-#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
-
-/** @brief Clear the UART PE pending flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)
-
-/** @brief Clear the UART FE pending flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)
-
-/** @brief Clear the UART NE pending flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)
-
-/** @brief Clear the UART ORE pending flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)
-
-/** @brief Clear the UART IDLE pending flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)
-
-
-/** @brief Check whether the specified UART flag is set or not.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __FLAG__ specifies the flag to check.
- * This parameter can be one of the following values:
- * @arg @ref UART_FLAG_REACK Receive enable acknowledge flag
- * @arg @ref UART_FLAG_TEACK Transmit enable acknowledge flag
- * @arg @ref UART_FLAG_WUF Wake up from stop mode flag
- * @arg @ref UART_FLAG_RWU Receiver wake up flag (if the UART in mute mode)
- * @arg @ref UART_FLAG_SBKF Send Break flag
- * @arg @ref UART_FLAG_CMF Character match flag
- * @arg @ref UART_FLAG_BUSY Busy flag
- * @arg @ref UART_FLAG_ABRF Auto Baud rate detection flag
- * @arg @ref UART_FLAG_ABRE Auto Baud rate detection error flag
- * @arg @ref UART_FLAG_CTS CTS Change flag
- * @arg @ref UART_FLAG_LBDF LIN Break detection flag
- * @arg @ref UART_FLAG_TXE Transmit data register empty flag
- * @arg @ref UART_FLAG_TC Transmission Complete flag
- * @arg @ref UART_FLAG_RXNE Receive data register not empty flag
- * @arg @ref UART_FLAG_RTOF Receiver Timeout flag
- * @arg @ref UART_FLAG_IDLE Idle Line detection flag
- * @arg @ref UART_FLAG_ORE Overrun Error flag
- * @arg @ref UART_FLAG_NE Noise Error flag
- * @arg @ref UART_FLAG_FE Framing Error flag
- * @arg @ref UART_FLAG_PE Parity Error flag
- * @retval The new state of __FLAG__ (TRUE or FALSE).
- */
-#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
-
-/** @brief Enable the specified UART interrupt.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __INTERRUPT__ specifies the UART interrupt source to enable.
- * This parameter can be one of the following values:
- * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
- * @arg @ref UART_IT_CM Character match interrupt
- * @arg @ref UART_IT_CTS CTS change interrupt
- * @arg @ref UART_IT_LBD LIN Break detection interrupt
- * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
- * @arg @ref UART_IT_TC Transmission complete interrupt
- * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
- * @arg @ref UART_IT_RTO Receive Timeout interrupt
- * @arg @ref UART_IT_IDLE Idle line detection interrupt
- * @arg @ref UART_IT_PE Parity Error interrupt
- * @arg @ref UART_IT_ERR Error interrupt (frame error, noise error, overrun error)
- * @retval None
- */
-#define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (\
- ((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)?\
- ((__HANDLE__)->Instance->CR1 |= (1U <<\
- ((__INTERRUPT__) & UART_IT_MASK))): \
- ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)?\
- ((__HANDLE__)->Instance->CR2 |= (1U <<\
- ((__INTERRUPT__) & UART_IT_MASK))): \
- ((__HANDLE__)->Instance->CR3 |= (1U <<\
- ((__INTERRUPT__) & UART_IT_MASK))))
-
-/** @brief Disable the specified UART interrupt.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __INTERRUPT__ specifies the UART interrupt source to disable.
- * This parameter can be one of the following values:
- * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
- * @arg @ref UART_IT_CM Character match interrupt
- * @arg @ref UART_IT_CTS CTS change interrupt
- * @arg @ref UART_IT_LBD LIN Break detection interrupt
- * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
- * @arg @ref UART_IT_TC Transmission complete interrupt
- * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
- * @arg @ref UART_IT_RTO Receive Timeout interrupt
- * @arg @ref UART_IT_IDLE Idle line detection interrupt
- * @arg @ref UART_IT_PE Parity Error interrupt
- * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
- * @retval None
- */
-#define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (\
- ((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)?\
- ((__HANDLE__)->Instance->CR1 &= ~ (1U <<\
- ((__INTERRUPT__) & UART_IT_MASK))): \
- ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)?\
- ((__HANDLE__)->Instance->CR2 &= ~ (1U <<\
- ((__INTERRUPT__) & UART_IT_MASK))): \
- ((__HANDLE__)->Instance->CR3 &= ~ (1U <<\
- ((__INTERRUPT__) & UART_IT_MASK))))
-
-/** @brief Check whether the specified UART interrupt has occurred or not.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __INTERRUPT__ specifies the UART interrupt to check.
- * This parameter can be one of the following values:
- * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
- * @arg @ref UART_IT_CM Character match interrupt
- * @arg @ref UART_IT_CTS CTS change interrupt
- * @arg @ref UART_IT_LBD LIN Break detection interrupt
- * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
- * @arg @ref UART_IT_TC Transmission complete interrupt
- * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
- * @arg @ref UART_IT_RTO Receive Timeout interrupt
- * @arg @ref UART_IT_IDLE Idle line detection interrupt
- * @arg @ref UART_IT_PE Parity Error interrupt
- * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
- * @retval The new state of __INTERRUPT__ (SET or RESET).
- */
-#define __HAL_UART_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR\
- & (1U << ((__INTERRUPT__)>> 8U))) != RESET) ? SET : RESET)
-
-/** @brief Check whether the specified UART interrupt source is enabled or not.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __INTERRUPT__ specifies the UART interrupt source to check.
- * This parameter can be one of the following values:
- * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
- * @arg @ref UART_IT_CM Character match interrupt
- * @arg @ref UART_IT_CTS CTS change interrupt
- * @arg @ref UART_IT_LBD LIN Break detection interrupt
- * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
- * @arg @ref UART_IT_TC Transmission complete interrupt
- * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
- * @arg @ref UART_IT_RTO Receive Timeout interrupt
- * @arg @ref UART_IT_IDLE Idle line detection interrupt
- * @arg @ref UART_IT_PE Parity Error interrupt
- * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
- * @retval The new state of __INTERRUPT__ (SET or RESET).
- */
-#define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U) ?\
- (__HANDLE__)->Instance->CR1 : \
- (((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U) ?\
- (__HANDLE__)->Instance->CR2 : \
- (__HANDLE__)->Instance->CR3)) & (1U <<\
- (((uint16_t)(__INTERRUPT__)) &\
- UART_IT_MASK))) != RESET) ? SET : RESET)
-
-/** @brief Clear the specified UART ISR flag, in setting the proper ICR register flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
- * to clear the corresponding interrupt
- * This parameter can be one of the following values:
- * @arg @ref UART_CLEAR_PEF Parity Error Clear Flag
- * @arg @ref UART_CLEAR_FEF Framing Error Clear Flag
- * @arg @ref UART_CLEAR_NEF Noise detected Clear Flag
- * @arg @ref UART_CLEAR_OREF Overrun Error Clear Flag
- * @arg @ref UART_CLEAR_IDLEF IDLE line detected Clear Flag
- * @arg @ref UART_CLEAR_RTOF Receiver timeout clear flag
- * @arg @ref UART_CLEAR_TCF Transmission Complete Clear Flag
- * @arg @ref UART_CLEAR_LBDF LIN Break Detection Clear Flag
- * @arg @ref UART_CLEAR_CTSF CTS Interrupt Clear Flag
- * @arg @ref UART_CLEAR_CMF Character Match Clear Flag
- * @arg @ref UART_CLEAR_WUF Wake Up from stop mode Clear Flag
- * @retval None
- */
-#define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
-
-/** @brief Set a specific UART request flag.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __REQ__ specifies the request flag to set
- * This parameter can be one of the following values:
- * @arg @ref UART_AUTOBAUD_REQUEST Auto-Baud Rate Request
- * @arg @ref UART_SENDBREAK_REQUEST Send Break Request
- * @arg @ref UART_MUTE_MODE_REQUEST Mute Mode Request
- * @arg @ref UART_RXDATA_FLUSH_REQUEST Receive Data flush Request
- * @arg @ref UART_TXDATA_FLUSH_REQUEST Transmit data flush Request
- * @retval None
- */
-#define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
-
-/** @brief Enable the UART one bit sample method.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
-
-/** @brief Disable the UART one bit sample method.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT)
-
-/** @brief Enable UART.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
-
-/** @brief Disable UART.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
-
-/** @brief Enable CTS flow control.
- * @note This macro allows to enable CTS hardware flow control for a given UART instance,
- * without need to call HAL_UART_Init() function.
- * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
- * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
- * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
- * - UART instance should have already been initialised (through call of HAL_UART_Init() )
- * - macro could only be called when corresponding UART instance is disabled
- * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable
- * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
- do{ \
- ATOMIC_SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
- (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
- } while(0U)
-
-/** @brief Disable CTS flow control.
- * @note This macro allows to disable CTS hardware flow control for a given UART instance,
- * without need to call HAL_UART_Init() function.
- * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
- * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
- * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
- * - UART instance should have already been initialised (through call of HAL_UART_Init() )
- * - macro could only be called when corresponding UART instance is disabled
- * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable
- * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
- do{ \
- ATOMIC_CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
- (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
- } while(0U)
-
-/** @brief Enable RTS flow control.
- * @note This macro allows to enable RTS hardware flow control for a given UART instance,
- * without need to call HAL_UART_Init() function.
- * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
- * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
- * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
- * - UART instance should have already been initialised (through call of HAL_UART_Init() )
- * - macro could only be called when corresponding UART instance is disabled
- * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable
- * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
- do{ \
- ATOMIC_SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
- (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
- } while(0U)
-
-/** @brief Disable RTS flow control.
- * @note This macro allows to disable RTS hardware flow control for a given UART instance,
- * without need to call HAL_UART_Init() function.
- * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
- * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
- * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
- * - UART instance should have already been initialised (through call of HAL_UART_Init() )
- * - macro could only be called when corresponding UART instance is disabled
- * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable
- * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None
- */
-#define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
- do{ \
- ATOMIC_CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
- (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
- } while(0U)
-/**
- * @}
- */
-
-/* Private macros --------------------------------------------------------*/
-/** @defgroup UART_Private_Macros UART Private Macros
- * @{
- */
-
-
-/** @brief BRR division operation to set BRR register in 8-bit oversampling mode.
- * @param __PCLK__ UART clock.
- * @param __BAUD__ Baud rate set by the user.
- * @retval Division result
- */
-#define UART_DIV_SAMPLING8(__PCLK__, __BAUD__) ((((__PCLK__)*2U) + ((__BAUD__)/2U)) / (__BAUD__))
-
-/** @brief BRR division operation to set BRR register in 16-bit oversampling mode.
- * @param __PCLK__ UART clock.
- * @param __BAUD__ Baud rate set by the user.
- * @retval Division result
- */
-#define UART_DIV_SAMPLING16(__PCLK__, __BAUD__) (((__PCLK__) + ((__BAUD__)/2U)) / (__BAUD__))
-
-
-/** @brief Check UART Baud rate.
- * @param __BAUDRATE__ Baudrate specified by the user.
- * The maximum Baud Rate is derived from the maximum clock on F3 (i.e. 72 MHz)
- * divided by the smallest oversampling used on the USART (i.e. 8)
- * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
- */
-#define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 9000001U)
-
-/** @brief Check UART assertion time.
- * @param __TIME__ 5-bit value assertion time.
- * @retval Test result (TRUE or FALSE).
- */
-#define IS_UART_ASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU)
-
-/** @brief Check UART deassertion time.
- * @param __TIME__ 5-bit value deassertion time.
- * @retval Test result (TRUE or FALSE).
- */
-#define IS_UART_DEASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU)
-
-/**
- * @brief Ensure that UART frame number of stop bits is valid.
- * @param __STOPBITS__ UART frame number of stop bits.
- * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
- */
-#define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_0_5) || \
- ((__STOPBITS__) == UART_STOPBITS_1) || \
- ((__STOPBITS__) == UART_STOPBITS_1_5) || \
- ((__STOPBITS__) == UART_STOPBITS_2))
-
-
-/**
- * @brief Ensure that UART frame parity is valid.
- * @param __PARITY__ UART frame parity.
- * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
- */
-#define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
- ((__PARITY__) == UART_PARITY_EVEN) || \
- ((__PARITY__) == UART_PARITY_ODD))
-
-/**
- * @brief Ensure that UART hardware flow control is valid.
- * @param __CONTROL__ UART hardware flow control.
- * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
- */
-#define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
- (((__CONTROL__) == UART_HWCONTROL_NONE) || \
- ((__CONTROL__) == UART_HWCONTROL_RTS) || \
- ((__CONTROL__) == UART_HWCONTROL_CTS) || \
- ((__CONTROL__) == UART_HWCONTROL_RTS_CTS))
-
-/**
- * @brief Ensure that UART communication mode is valid.
- * @param __MODE__ UART communication mode.
- * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
- */
-#define IS_UART_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(UART_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U))
-
-/**
- * @brief Ensure that UART state is valid.
- * @param __STATE__ UART state.
- * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
- */
-#define IS_UART_STATE(__STATE__) (((__STATE__) == UART_STATE_DISABLE) || \
- ((__STATE__) == UART_STATE_ENABLE))
-
-/**
- * @brief Ensure that UART oversampling is valid.
- * @param __SAMPLING__ UART oversampling.
- * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid)
- */
-#define IS_UART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == UART_OVERSAMPLING_16) || \
- ((__SAMPLING__) == UART_OVERSAMPLING_8))
-
-/**
- * @brief Ensure that UART frame sampling is valid.
- * @param __ONEBIT__ UART frame sampling.
- * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
- */
-#define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == UART_ONE_BIT_SAMPLE_DISABLE) || \
- ((__ONEBIT__) == UART_ONE_BIT_SAMPLE_ENABLE))
-
-/**
- * @brief Ensure that UART auto Baud rate detection mode is valid.
- * @param __MODE__ UART auto Baud rate detection mode.
- * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
- */
-#define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__) (((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
- ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
- ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
- ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
-
-/**
- * @brief Ensure that UART receiver timeout setting is valid.
- * @param __TIMEOUT__ UART receiver timeout setting.
- * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
- */
-#define IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_DISABLE) || \
- ((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_ENABLE))
-
-/** @brief Check the receiver timeout value.
- * @note The maximum UART receiver timeout value is 0xFFFFFF.
- * @param __TIMEOUTVALUE__ receiver timeout value.
- * @retval Test result (TRUE or FALSE)
- */
-#define IS_UART_RECEIVER_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFFU)
-
-/**
- * @brief Ensure that UART LIN state is valid.
- * @param __LIN__ UART LIN state.
- * @retval SET (__LIN__ is valid) or RESET (__LIN__ is invalid)
- */
-#define IS_UART_LIN(__LIN__) (((__LIN__) == UART_LIN_DISABLE) || \
- ((__LIN__) == UART_LIN_ENABLE))
-
-/**
- * @brief Ensure that UART LIN break detection length is valid.
- * @param __LENGTH__ UART LIN break detection length.
- * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
- */
-#define IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__) (((__LENGTH__) == UART_LINBREAKDETECTLENGTH_10B) || \
- ((__LENGTH__) == UART_LINBREAKDETECTLENGTH_11B))
-
-/**
- * @brief Ensure that UART DMA TX state is valid.
- * @param __DMATX__ UART DMA TX state.
- * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
- */
-#define IS_UART_DMA_TX(__DMATX__) (((__DMATX__) == UART_DMA_TX_DISABLE) || \
- ((__DMATX__) == UART_DMA_TX_ENABLE))
-
-/**
- * @brief Ensure that UART DMA RX state is valid.
- * @param __DMARX__ UART DMA RX state.
- * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
- */
-#define IS_UART_DMA_RX(__DMARX__) (((__DMARX__) == UART_DMA_RX_DISABLE) || \
- ((__DMARX__) == UART_DMA_RX_ENABLE))
-
-/**
- * @brief Ensure that UART half-duplex state is valid.
- * @param __HDSEL__ UART half-duplex state.
- * @retval SET (__HDSEL__ is valid) or RESET (__HDSEL__ is invalid)
- */
-#define IS_UART_HALF_DUPLEX(__HDSEL__) (((__HDSEL__) == UART_HALF_DUPLEX_DISABLE) || \
- ((__HDSEL__) == UART_HALF_DUPLEX_ENABLE))
-
-/**
- * @brief Ensure that UART wake-up method is valid.
- * @param __WAKEUP__ UART wake-up method .
- * @retval SET (__WAKEUP__ is valid) or RESET (__WAKEUP__ is invalid)
- */
-#define IS_UART_WAKEUPMETHOD(__WAKEUP__) (((__WAKEUP__) == UART_WAKEUPMETHOD_IDLELINE) || \
- ((__WAKEUP__) == UART_WAKEUPMETHOD_ADDRESSMARK))
-
-/**
- * @brief Ensure that UART request parameter is valid.
- * @param __PARAM__ UART request parameter.
- * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
- */
-#define IS_UART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == UART_AUTOBAUD_REQUEST) || \
- ((__PARAM__) == UART_SENDBREAK_REQUEST) || \
- ((__PARAM__) == UART_MUTE_MODE_REQUEST) || \
- ((__PARAM__) == UART_RXDATA_FLUSH_REQUEST) || \
- ((__PARAM__) == UART_TXDATA_FLUSH_REQUEST))
-
-/**
- * @brief Ensure that UART advanced features initialization is valid.
- * @param __INIT__ UART advanced features initialization.
- * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
- */
-#define IS_UART_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (UART_ADVFEATURE_NO_INIT | \
- UART_ADVFEATURE_TXINVERT_INIT | \
- UART_ADVFEATURE_RXINVERT_INIT | \
- UART_ADVFEATURE_DATAINVERT_INIT | \
- UART_ADVFEATURE_SWAP_INIT | \
- UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
- UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
- UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
- UART_ADVFEATURE_MSBFIRST_INIT))
-
-/**
- * @brief Ensure that UART frame TX inversion setting is valid.
- * @param __TXINV__ UART frame TX inversion setting.
- * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
- */
-#define IS_UART_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == UART_ADVFEATURE_TXINV_DISABLE) || \
- ((__TXINV__) == UART_ADVFEATURE_TXINV_ENABLE))
-
-/**
- * @brief Ensure that UART frame RX inversion setting is valid.
- * @param __RXINV__ UART frame RX inversion setting.
- * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
- */
-#define IS_UART_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == UART_ADVFEATURE_RXINV_DISABLE) || \
- ((__RXINV__) == UART_ADVFEATURE_RXINV_ENABLE))
-
-/**
- * @brief Ensure that UART frame data inversion setting is valid.
- * @param __DATAINV__ UART frame data inversion setting.
- * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
- */
-#define IS_UART_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == UART_ADVFEATURE_DATAINV_DISABLE) || \
- ((__DATAINV__) == UART_ADVFEATURE_DATAINV_ENABLE))
-
-/**
- * @brief Ensure that UART frame RX/TX pins swap setting is valid.
- * @param __SWAP__ UART frame RX/TX pins swap setting.
- * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
- */
-#define IS_UART_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == UART_ADVFEATURE_SWAP_DISABLE) || \
- ((__SWAP__) == UART_ADVFEATURE_SWAP_ENABLE))
-
-/**
- * @brief Ensure that UART frame overrun setting is valid.
- * @param __OVERRUN__ UART frame overrun setting.
- * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
- */
-#define IS_UART_OVERRUN(__OVERRUN__) (((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
- ((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_DISABLE))
-
-/**
- * @brief Ensure that UART auto Baud rate state is valid.
- * @param __AUTOBAUDRATE__ UART auto Baud rate state.
- * @retval SET (__AUTOBAUDRATE__ is valid) or RESET (__AUTOBAUDRATE__ is invalid)
- */
-#define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__) (((__AUTOBAUDRATE__) == \
- UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
- ((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
-
-/**
- * @brief Ensure that UART DMA enabling or disabling on error setting is valid.
- * @param __DMA__ UART DMA enabling or disabling on error setting.
- * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
- */
-#define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
- ((__DMA__) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
-
-/**
- * @brief Ensure that UART frame MSB first setting is valid.
- * @param __MSBFIRST__ UART frame MSB first setting.
- * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
- */
-#define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
- ((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_ENABLE))
-
-/**
- * @brief Ensure that UART stop mode state is valid.
- * @param __STOPMODE__ UART stop mode state.
- * @retval SET (__STOPMODE__ is valid) or RESET (__STOPMODE__ is invalid)
- */
-#define IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__) (((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
- ((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_ENABLE))
-
-/**
- * @brief Ensure that UART mute mode state is valid.
- * @param __MUTE__ UART mute mode state.
- * @retval SET (__MUTE__ is valid) or RESET (__MUTE__ is invalid)
- */
-#define IS_UART_MUTE_MODE(__MUTE__) (((__MUTE__) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
- ((__MUTE__) == UART_ADVFEATURE_MUTEMODE_ENABLE))
-
-/**
- * @brief Ensure that UART wake-up selection is valid.
- * @param __WAKE__ UART wake-up selection.
- * @retval SET (__WAKE__ is valid) or RESET (__WAKE__ is invalid)
- */
-#define IS_UART_WAKEUP_SELECTION(__WAKE__) (((__WAKE__) == UART_WAKEUP_ON_ADDRESS) || \
- ((__WAKE__) == UART_WAKEUP_ON_STARTBIT) || \
- ((__WAKE__) == UART_WAKEUP_ON_READDATA_NONEMPTY))
-
-/**
- * @brief Ensure that UART driver enable polarity is valid.
- * @param __POLARITY__ UART driver enable polarity.
- * @retval SET (__POLARITY__ is valid) or RESET (__POLARITY__ is invalid)
- */
-#define IS_UART_DE_POLARITY(__POLARITY__) (((__POLARITY__) == UART_DE_POLARITY_HIGH) || \
- ((__POLARITY__) == UART_DE_POLARITY_LOW))
-
-
-/**
- * @}
- */
-
-/* Include UART HAL Extended module */
-#include "stm32f3xx_hal_uart_ex.h"
-
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup UART_Exported_Functions UART Exported Functions
- * @{
- */
-
-/** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
- * @{
- */
-
-/* Initialization and de-initialization functions ****************************/
-HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
-HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
-HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart);
-void HAL_UART_MspInit(UART_HandleTypeDef *huart);
-void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
-
-/* Callbacks Register/UnRegister functions ***********************************/
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID,
- pUART_CallbackTypeDef pCallback);
-HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID);
-
-HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback);
-HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @addtogroup UART_Exported_Functions_Group2 IO operation functions
- * @{
- */
-
-/* IO operation functions *****************************************************/
-HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size, uint32_t Timeout);
-HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
-HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size);
-HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
-HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size);
-HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
-HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
-/* Transfer Abort functions */
-HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
-
-void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
-void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
-void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
-void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
-void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
-void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
-void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart);
-void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart);
-void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart);
-
-void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size);
-
-/**
- * @}
- */
-
-/** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
- * @{
- */
-
-/* Peripheral Control functions ************************************************/
-void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart, uint32_t TimeoutValue);
-HAL_StatusTypeDef HAL_UART_EnableReceiverTimeout(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UART_DisableReceiverTimeout(UART_HandleTypeDef *huart);
-
-HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
-void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
-
-/**
- * @}
- */
-
-/** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions
- * @{
- */
-
-/* Peripheral State and Errors functions **************************************************/
-HAL_UART_StateTypeDef HAL_UART_GetState(const UART_HandleTypeDef *huart);
-uint32_t HAL_UART_GetError(const UART_HandleTypeDef *huart);
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private functions -----------------------------------------------------------*/
-/** @addtogroup UART_Private_Functions UART Private Functions
- * @{
- */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-void UART_InitCallbacksToDefault(UART_HandleTypeDef *huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status,
- uint32_t Tickstart, uint32_t Timeout);
-void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
-HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
-
-/**
- * @}
- */
-
-/* Private variables -----------------------------------------------------------*/
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STM32F3xx_HAL_UART_H */
-
diff --git a/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_uart_ex.h b/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_uart_ex.h
deleted file mode 100644
index e5d9e72..0000000
--- a/Drivers/STM32F3xx_HAL_Driver/Inc/stm32f3xx_hal_uart_ex.h
+++ /dev/null
@@ -1,513 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32f3xx_hal_uart_ex.h
- * @author MCD Application Team
- * @brief Header file of UART HAL Extended module.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2016 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32F3xx_HAL_UART_EX_H
-#define STM32F3xx_HAL_UART_EX_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f3xx_hal_def.h"
-
-/** @addtogroup STM32F3xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup UARTEx
- * @{
- */
-
-/* Exported types ------------------------------------------------------------*/
-/** @defgroup UARTEx_Exported_Types UARTEx Exported Types
- * @{
- */
-
-/**
- * @brief UART wake up from stop mode parameters
- */
-typedef struct
-{
- uint32_t WakeUpEvent; /*!< Specifies which event will activate the Wakeup from Stop mode flag (WUF).
- This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
- If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
- be filled up. */
-
- uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
- This parameter can be a value of @ref UARTEx_WakeUp_Address_Length. */
-
- uint8_t Address; /*!< UART/USART node address (7-bit long max). */
-} UART_WakeUpTypeDef;
-
-/**
- * @}
- */
-
-/* Exported constants --------------------------------------------------------*/
-/** @defgroup UARTEx_Exported_Constants UARTEx Exported Constants
- * @{
- */
-
-/** @defgroup UARTEx_Word_Length UARTEx Word Length
- * @{
- */
-#if defined(USART_CR1_M1)
-#define UART_WORDLENGTH_7B USART_CR1_M1 /*!< 7-bit long UART frame */
-#endif /* USART_CR1_M1 */
-#define UART_WORDLENGTH_8B 0x00000000U /*!< 8-bit long UART frame */
-#if defined (USART_CR1_M0)
-#define UART_WORDLENGTH_9B USART_CR1_M0 /*!< 9-bit long UART frame */
-#else
-#define UART_WORDLENGTH_9B USART_CR1_M /*!< 9-bit long UART frame */
-#endif /* USART_CR1_M0 */
-/**
- * @}
- */
-
-/** @defgroup UARTEx_WakeUp_Address_Length UARTEx WakeUp Address Length
- * @{
- */
-#define UART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit long wake-up address */
-#define UART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit long wake-up address */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Exported macros -----------------------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup UARTEx_Exported_Functions
- * @{
- */
-
-/** @addtogroup UARTEx_Exported_Functions_Group1
- * @{
- */
-
-/* Initialization and de-initialization functions ****************************/
-HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime,
- uint32_t DeassertionTime);
-
-/**
- * @}
- */
-
-/** @addtogroup UARTEx_Exported_Functions_Group2
- * @{
- */
-
-void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart);
-
-/**
- * @}
- */
-
-/** @addtogroup UARTEx_Exported_Functions_Group3
- * @{
- */
-
-/* Peripheral Control functions **********************************************/
-HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
-HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
-HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
-
-HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength);
-
-
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint16_t *RxLen,
- uint32_t Timeout);
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
-
-HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(const UART_HandleTypeDef *huart);
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private macros ------------------------------------------------------------*/
-/** @defgroup UARTEx_Private_Macros UARTEx Private Macros
- * @{
- */
-
-/** @brief Report the UART clock source.
- * @param __HANDLE__ specifies the UART Handle.
- * @param __CLOCKSOURCE__ output variable.
- * @retval UART clocking source, written in __CLOCKSOURCE__.
- */
-#if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F302xC) \
- || defined(STM32F303xC) || defined(STM32F358xx)
-#define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
- do { \
- if((__HANDLE__)->Instance == USART1) \
- { \
- switch(__HAL_RCC_GET_USART1_SOURCE()) \
- { \
- case RCC_USART1CLKSOURCE_PCLK2: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
- break; \
- case RCC_USART1CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART1CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART1CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if((__HANDLE__)->Instance == USART2) \
- { \
- switch(__HAL_RCC_GET_USART2_SOURCE()) \
- { \
- case RCC_USART2CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_USART2CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART2CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART2CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if((__HANDLE__)->Instance == USART3) \
- { \
- switch(__HAL_RCC_GET_USART3_SOURCE()) \
- { \
- case RCC_USART3CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_USART3CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART3CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART3CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if((__HANDLE__)->Instance == UART4) \
- { \
- switch(__HAL_RCC_GET_UART4_SOURCE()) \
- { \
- case RCC_UART4CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_UART4CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_UART4CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_UART4CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if ((__HANDLE__)->Instance == UART5) \
- { \
- switch(__HAL_RCC_GET_UART5_SOURCE()) \
- { \
- case RCC_UART5CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_UART5CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_UART5CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_UART5CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else \
- { \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- } \
- } while(0U)
-#elif defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || defined(STM32F301x8) \
- || defined(STM32F302x8) || defined(STM32F318xx)
-#define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
- do { \
- if((__HANDLE__)->Instance == USART1) \
- { \
- switch(__HAL_RCC_GET_USART1_SOURCE()) \
- { \
- case RCC_USART1CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_USART1CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART1CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART1CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if((__HANDLE__)->Instance == USART2) \
- { \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- } \
- else if((__HANDLE__)->Instance == USART3) \
- { \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- } \
- else \
- { \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- } \
- } while(0U)
-#else
-#define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
- do { \
- if((__HANDLE__)->Instance == USART1) \
- { \
- switch(__HAL_RCC_GET_USART1_SOURCE()) \
- { \
- case RCC_USART1CLKSOURCE_PCLK2: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
- break; \
- case RCC_USART1CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART1CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART1CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if((__HANDLE__)->Instance == USART2) \
- { \
- switch(__HAL_RCC_GET_USART2_SOURCE()) \
- { \
- case RCC_USART2CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_USART2CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART2CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART2CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else if((__HANDLE__)->Instance == USART3) \
- { \
- switch(__HAL_RCC_GET_USART3_SOURCE()) \
- { \
- case RCC_USART3CLKSOURCE_PCLK1: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
- break; \
- case RCC_USART3CLKSOURCE_HSI: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
- break; \
- case RCC_USART3CLKSOURCE_SYSCLK: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
- break; \
- case RCC_USART3CLKSOURCE_LSE: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
- break; \
- default: \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- break; \
- } \
- } \
- else \
- { \
- (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
- } \
- } while(0U)
-#endif /* STM32F302xE || STM32F303xE || STM32F398xx || STM32F302xC || STM32F303xC || STM32F358xx */
-
-/** @brief Report the UART mask to apply to retrieve the received data
- * according to the word length and to the parity bits activation.
- * @note If PCE = 1, the parity bit is not included in the data extracted
- * by the reception API().
- * This masking operation is not carried out in the case of
- * DMA transfers.
- * @param __HANDLE__ specifies the UART Handle.
- * @retval None, the mask to apply to UART RDR register is stored in (__HANDLE__)->Mask field.
- */
-#if defined (USART_CR1_M1)
-#define UART_MASK_COMPUTATION(__HANDLE__) \
- do { \
- if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
- { \
- if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
- { \
- (__HANDLE__)->Mask = 0x01FFU ; \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x00FFU ; \
- } \
- } \
- else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
- { \
- if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
- { \
- (__HANDLE__)->Mask = 0x00FFU ; \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x007FU ; \
- } \
- } \
- else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \
- { \
- if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
- { \
- (__HANDLE__)->Mask = 0x007FU ; \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x003FU ; \
- } \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x0000U; \
- } \
- } while(0U)
-
-#else
-#define UART_MASK_COMPUTATION(__HANDLE__) \
- do { \
- if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
- { \
- if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
- { \
- (__HANDLE__)->Mask = 0x01FFU ; \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x00FFU ; \
- } \
- } \
- else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
- { \
- if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
- { \
- (__HANDLE__)->Mask = 0x00FFU ; \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x007FU ; \
- } \
- } \
- else \
- { \
- (__HANDLE__)->Mask = 0x0000U; \
- } \
- } while(0U)
-
-#endif /* USART_CR1_M1 */
-
-/**
- * @brief Ensure that UART frame length is valid.
- * @param __LENGTH__ UART frame length.
- * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
- */
-#if defined (USART_CR1_M1)
-#define IS_UART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == UART_WORDLENGTH_7B) || \
- ((__LENGTH__) == UART_WORDLENGTH_8B) || \
- ((__LENGTH__) == UART_WORDLENGTH_9B))
-#else
-#define IS_UART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == UART_WORDLENGTH_8B) || \
- ((__LENGTH__) == UART_WORDLENGTH_9B))
-#endif /* USART_CR1_M1 */
-
-/**
- * @brief Ensure that UART wake-up address length is valid.
- * @param __ADDRESS__ UART wake-up address length.
- * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
- */
-#define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__) (((__ADDRESS__) == UART_ADDRESS_DETECT_4B) || \
- ((__ADDRESS__) == UART_ADDRESS_DETECT_7B))
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STM32F3xx_HAL_UART_EX_H */
-
diff --git a/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart.c b/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart.c
deleted file mode 100644
index a6b101f..0000000
--- a/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart.c
+++ /dev/null
@@ -1,4012 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32f3xx_hal_uart.c
- * @author MCD Application Team
- * @brief UART HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Universal Asynchronous Receiver Transmitter Peripheral (UART).
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- *
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2016 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- @verbatim
- ===============================================================================
- ##### How to use this driver #####
- ===============================================================================
- [..]
- The UART HAL driver can be used as follows:
-
- (#) Declare a UART_HandleTypeDef handle structure (eg. UART_HandleTypeDef huart).
- (#) Initialize the UART low level resources by implementing the HAL_UART_MspInit() API:
- (++) Enable the USARTx interface clock.
- (++) UART pins configuration:
- (+++) Enable the clock for the UART GPIOs.
- (+++) Configure these UART pins as alternate function pull-up.
- (++) NVIC configuration if you need to use interrupt process (HAL_UART_Transmit_IT()
- and HAL_UART_Receive_IT() APIs):
- (+++) Configure the USARTx interrupt priority.
- (+++) Enable the NVIC USART IRQ handle.
- (++) UART interrupts handling:
- -@@- The specific UART interrupts (Transmission complete interrupt,
- RXNE interrupt, RX/TX FIFOs related interrupts and Error Interrupts)
- are managed using the macros __HAL_UART_ENABLE_IT() and __HAL_UART_DISABLE_IT()
- inside the transmit and receive processes.
- (++) DMA Configuration if you need to use DMA process (HAL_UART_Transmit_DMA()
- and HAL_UART_Receive_DMA() APIs):
- (+++) Declare a DMA handle structure for the Tx/Rx channel.
- (+++) Enable the DMAx interface clock.
- (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
- (+++) Configure the DMA Tx/Rx channel.
- (+++) Associate the initialized DMA handle to the UART DMA Tx/Rx handle.
- (+++) Configure the priority and enable the NVIC for the transfer complete
- interrupt on the DMA Tx/Rx channel.
-
- (#) Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware
- flow control and Mode (Receiver/Transmitter) in the huart handle Init structure.
-
- (#) If required, program UART advanced features (TX/RX pins swap, auto Baud rate detection,...)
- in the huart handle AdvancedInit structure.
-
- (#) For the UART asynchronous mode, initialize the UART registers by calling
- the HAL_UART_Init() API.
-
- (#) For the UART Half duplex mode, initialize the UART registers by calling
- the HAL_HalfDuplex_Init() API.
-
- (#) For the UART LIN (Local Interconnection Network) mode, initialize the UART registers
- by calling the HAL_LIN_Init() API.
-
- (#) For the UART Multiprocessor mode, initialize the UART registers
- by calling the HAL_MultiProcessor_Init() API.
-
- (#) For the UART RS485 Driver Enabled mode, initialize the UART registers
- by calling the HAL_RS485Ex_Init() API.
-
- [..]
- (@) These API's (HAL_UART_Init(), HAL_HalfDuplex_Init(), HAL_LIN_Init(), HAL_MultiProcessor_Init(),
- also configure the low level Hardware GPIO, CLOCK, CORTEX...etc) by
- calling the customized HAL_UART_MspInit() API.
-
- ##### Callback registration #####
- ==================================
-
- [..]
- The compilation define USE_HAL_UART_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- [..]
- Use Function HAL_UART_RegisterCallback() to register a user callback.
- Function HAL_UART_RegisterCallback() allows to register following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
- (+) AbortReceiveCpltCallback : Abort Receive Complete Callback.
- (+) WakeupCallback : Wakeup Callback.
- (+) MspInitCallback : UART MspInit.
- (+) MspDeInitCallback : UART MspDeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- [..]
- Use function HAL_UART_UnRegisterCallback() to reset a callback to the default
- weak function.
- HAL_UART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
- (+) AbortReceiveCpltCallback : Abort Receive Complete Callback.
- (+) WakeupCallback : Wakeup Callback.
- (+) MspInitCallback : UART MspInit.
- (+) MspDeInitCallback : UART MspDeInit.
-
- [..]
- For specific callback RxEventCallback, use dedicated registration/reset functions:
- respectively HAL_UART_RegisterRxEventCallback() , HAL_UART_UnRegisterRxEventCallback().
-
- [..]
- By default, after the HAL_UART_Init() and when the state is HAL_UART_STATE_RESET
- all callbacks are set to the corresponding weak functions:
- examples HAL_UART_TxCpltCallback(), HAL_UART_RxHalfCpltCallback().
- Exception done for MspInit and MspDeInit functions that are respectively
- reset to the legacy weak functions in the HAL_UART_Init()
- and HAL_UART_DeInit() only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the HAL_UART_Init() and HAL_UART_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
-
- [..]
- Callbacks can be registered/unregistered in HAL_UART_STATE_READY state only.
- Exception done MspInit/MspDeInit that can be registered/unregistered
- in HAL_UART_STATE_READY or HAL_UART_STATE_RESET state, thus registered (user)
- MspInit/DeInit callbacks can be used during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using HAL_UART_RegisterCallback() before calling HAL_UART_DeInit()
- or HAL_UART_Init() function.
-
- [..]
- When The compilation define USE_HAL_UART_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available
- and weak callbacks are used.
-
-
- @endverbatim
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f3xx_hal.h"
-
-/** @addtogroup STM32F3xx_HAL_Driver
- * @{
- */
-
-/** @defgroup UART UART
- * @brief HAL UART module driver
- * @{
- */
-
-#ifdef HAL_UART_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @defgroup UART_Private_Constants UART Private Constants
- * @{
- */
-#define USART_CR1_FIELDS ((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE | \
- USART_CR1_OVER8)) /*!< UART or USART CR1 fields of parameters set by UART_SetConfig API */
-
-#define USART_CR3_FIELDS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE |\
- USART_CR3_ONEBIT)) /*!< UART or USART CR3 fields of parameters set by UART_SetConfig API */
-
-
-#define UART_BRR_MIN 0x10U /* UART BRR minimum authorized value */
-#define UART_BRR_MAX 0x0000FFFFU /* UART BRR maximum authorized value */
-/**
- * @}
- */
-
-/* Private macros ------------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/** @addtogroup UART_Private_Functions
- * @{
- */
-static void UART_EndRxTransfer(UART_HandleTypeDef *huart);
-static void UART_EndTxTransfer(UART_HandleTypeDef *huart);
-static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMAError(DMA_HandleTypeDef *hdma);
-static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma);
-static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_TxISR_8BIT(UART_HandleTypeDef *huart);
-static void UART_TxISR_16BIT(UART_HandleTypeDef *huart);
-static void UART_EndTransmit_IT(UART_HandleTypeDef *huart);
-static void UART_RxISR_8BIT(UART_HandleTypeDef *huart);
-static void UART_RxISR_16BIT(UART_HandleTypeDef *huart);
-/**
- * @}
- */
-
-/* Private variables ---------------------------------------------------------*/
-/* Exported Constants --------------------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-
-/** @defgroup UART_Exported_Functions UART Exported Functions
- * @{
- */
-
-/** @defgroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions
- *
-@verbatim
-===============================================================================
- ##### Initialization and Configuration functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
- in asynchronous mode.
- (+) For the asynchronous mode the parameters below can be configured:
- (++) Baud Rate
- (++) Word Length
- (++) Stop Bit
- (++) Parity: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- (++) Hardware flow control
- (++) Receiver/transmitter modes
- (++) Over Sampling Method
- (++) One-Bit Sampling Method
- (+) For the asynchronous mode, the following advanced features can be configured as well:
- (++) TX and/or RX pin level inversion
- (++) data logical level inversion
- (++) RX and TX pins swap
- (++) RX overrun detection disabling
- (++) DMA disabling on RX error
- (++) MSB first on communication line
- (++) auto Baud rate detection
- [..]
- The HAL_UART_Init(), HAL_HalfDuplex_Init(), HAL_LIN_Init()and HAL_MultiProcessor_Init()API
- follow respectively the UART asynchronous, UART Half duplex, UART LIN mode
- and UART multiprocessor mode configuration procedures (details for the procedures
- are available in reference manual).
-
-@endverbatim
-
- Depending on the frame length defined by the M1 and M0 bits (7-bit,
- 8-bit or 9-bit), the possible UART formats are listed in the
- following table.
-
- Table 1. UART frame format.
- +-----------------------------------------------------------------------+
- | M1 bit | M0 bit | PCE bit | UART frame |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 0 | 0 | | SB | 8 bit data | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 0 | 1 | | SB | 7 bit data | PB | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 1 | 0 | | SB | 9 bit data | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 1 | 1 | | SB | 8 bit data | PB | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 1 | 0 | 0 | | SB | 7 bit data | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 1 | 0 | 1 | | SB | 6 bit data | PB | STB | |
- +-----------------------------------------------------------------------+
-
- * @{
- */
-
-/**
- * @brief Initialize the UART mode according to the specified
- * parameters in the UART_InitTypeDef and initialize the associated handle.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- if (huart->Init.HwFlowCtl != UART_HWCONTROL_NONE)
- {
- /* Check the parameters */
- assert_param(IS_UART_HWFLOW_INSTANCE(huart->Instance));
- }
- else
- {
- /* Check the parameters */
- assert_param(IS_UART_INSTANCE(huart->Instance));
- }
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- __HAL_UART_DISABLE(huart);
-
- /* Perform advanced settings configuration */
- /* For some items, configuration requires to be done prior TE and RE bits are set */
- if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
- {
- UART_AdvFeatureConfig(huart);
- }
-
- /* Set the UART Communication parameters */
- if (UART_SetConfig(huart) == HAL_ERROR)
- {
- return HAL_ERROR;
- }
-
- /* In asynchronous mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN, HDSEL and IREN bits in the USART_CR3 register.*/
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
-
- __HAL_UART_ENABLE(huart);
-
- /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
- return (UART_CheckIdleState(huart));
-}
-
-/**
- * @brief Initialize the half-duplex mode according to the specified
- * parameters in the UART_InitTypeDef and creates the associated handle.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check UART instance */
- assert_param(IS_UART_HALFDUPLEX_INSTANCE(huart->Instance));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- __HAL_UART_DISABLE(huart);
-
- /* Perform advanced settings configuration */
- /* For some items, configuration requires to be done prior TE and RE bits are set */
- if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
- {
- UART_AdvFeatureConfig(huart);
- }
-
- /* Set the UART Communication parameters */
- if (UART_SetConfig(huart) == HAL_ERROR)
- {
- return HAL_ERROR;
- }
-
- /* In half-duplex mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN and IREN bits in the USART_CR3 register.*/
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_IREN | USART_CR3_SCEN));
-
- /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
- SET_BIT(huart->Instance->CR3, USART_CR3_HDSEL);
-
- __HAL_UART_ENABLE(huart);
-
- /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
- return (UART_CheckIdleState(huart));
-}
-
-
-/**
- * @brief Initialize the LIN mode according to the specified
- * parameters in the UART_InitTypeDef and creates the associated handle.
- * @param huart UART handle.
- * @param BreakDetectLength Specifies the LIN break detection length.
- * This parameter can be one of the following values:
- * @arg @ref UART_LINBREAKDETECTLENGTH_10B 10-bit break detection
- * @arg @ref UART_LINBREAKDETECTLENGTH_11B 11-bit break detection
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the LIN UART instance */
- assert_param(IS_UART_LIN_INSTANCE(huart->Instance));
- /* Check the Break detection length parameter */
- assert_param(IS_UART_LIN_BREAK_DETECT_LENGTH(BreakDetectLength));
-
- /* LIN mode limited to 16-bit oversampling only */
- if (huart->Init.OverSampling == UART_OVERSAMPLING_8)
- {
- return HAL_ERROR;
- }
- /* LIN mode limited to 8-bit data length */
- if (huart->Init.WordLength != UART_WORDLENGTH_8B)
- {
- return HAL_ERROR;
- }
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- __HAL_UART_DISABLE(huart);
-
- /* Perform advanced settings configuration */
- /* For some items, configuration requires to be done prior TE and RE bits are set */
- if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
- {
- UART_AdvFeatureConfig(huart);
- }
-
- /* Set the UART Communication parameters */
- if (UART_SetConfig(huart) == HAL_ERROR)
- {
- return HAL_ERROR;
- }
-
- /* In LIN mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN and IREN bits in the USART_CR3 register.*/
- CLEAR_BIT(huart->Instance->CR2, USART_CR2_CLKEN);
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_HDSEL | USART_CR3_IREN | USART_CR3_SCEN));
-
- /* Enable the LIN mode by setting the LINEN bit in the CR2 register */
- SET_BIT(huart->Instance->CR2, USART_CR2_LINEN);
-
- /* Set the USART LIN Break detection length. */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_LBDL, BreakDetectLength);
-
- __HAL_UART_ENABLE(huart);
-
- /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
- return (UART_CheckIdleState(huart));
-}
-
-
-/**
- * @brief Initialize the multiprocessor mode according to the specified
- * parameters in the UART_InitTypeDef and initialize the associated handle.
- * @param huart UART handle.
- * @param Address UART node address (4-, 6-, 7- or 8-bit long).
- * @param WakeUpMethod Specifies the UART wakeup method.
- * This parameter can be one of the following values:
- * @arg @ref UART_WAKEUPMETHOD_IDLELINE WakeUp by an idle line detection
- * @arg @ref UART_WAKEUPMETHOD_ADDRESSMARK WakeUp by an address mark
- * @note If the user resorts to idle line detection wake up, the Address parameter
- * is useless and ignored by the initialization function.
- * @note If the user resorts to address mark wake up, the address length detection
- * is configured by default to 4 bits only. For the UART to be able to
- * manage 6-, 7- or 8-bit long addresses detection, the API
- * HAL_MultiProcessorEx_AddressLength_Set() must be called after
- * HAL_MultiProcessor_Init().
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the wake up method parameter */
- assert_param(IS_UART_WAKEUPMETHOD(WakeUpMethod));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- __HAL_UART_DISABLE(huart);
-
- /* Perform advanced settings configuration */
- /* For some items, configuration requires to be done prior TE and RE bits are set */
- if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
- {
- UART_AdvFeatureConfig(huart);
- }
-
- /* Set the UART Communication parameters */
- if (UART_SetConfig(huart) == HAL_ERROR)
- {
- return HAL_ERROR;
- }
-
- /* In multiprocessor mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN, HDSEL and IREN bits in the USART_CR3 register. */
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
-
- if (WakeUpMethod == UART_WAKEUPMETHOD_ADDRESSMARK)
- {
- /* If address mark wake up method is chosen, set the USART address node */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_ADD, ((uint32_t)Address << UART_CR2_ADDRESS_LSB_POS));
- }
-
- /* Set the wake up method by setting the WAKE bit in the CR1 register */
- MODIFY_REG(huart->Instance->CR1, USART_CR1_WAKE, WakeUpMethod);
-
- __HAL_UART_ENABLE(huart);
-
- /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
- return (UART_CheckIdleState(huart));
-}
-
-
-/**
- * @brief DeInitialize the UART peripheral.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_UART_INSTANCE(huart->Instance));
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- __HAL_UART_DISABLE(huart);
-
- huart->Instance->CR1 = 0x0U;
- huart->Instance->CR2 = 0x0U;
- huart->Instance->CR3 = 0x0U;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- if (huart->MspDeInitCallback == NULL)
- {
- huart->MspDeInitCallback = HAL_UART_MspDeInit;
- }
- /* DeInit the low level hardware */
- huart->MspDeInitCallback(huart);
-#else
- /* DeInit the low level hardware */
- HAL_UART_MspDeInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_RESET;
- huart->RxState = HAL_UART_STATE_RESET;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Initialize the UART MSP.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_MspInit(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_MspInit can be implemented in the user file
- */
-}
-
-/**
- * @brief DeInitialize the UART MSP.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_MspDeInit can be implemented in the user file
- */
-}
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-/**
- * @brief Register a User UART Callback
- * To be used to override the weak predefined callback
- * @note The HAL_UART_RegisterCallback() may be called before HAL_UART_Init(), HAL_HalfDuplex_Init(),
- * HAL_LIN_Init(), HAL_MultiProcessor_Init() or HAL_RS485Ex_Init() in HAL_UART_STATE_RESET to register
- * callbacks for HAL_UART_MSPINIT_CB_ID and HAL_UART_MSPDEINIT_CB_ID
- * @param huart uart handle
- * @param CallbackID ID of the callback to be registered
- * This parameter can be one of the following values:
- * @arg @ref HAL_UART_TX_HALFCOMPLETE_CB_ID Tx Half Complete Callback ID
- * @arg @ref HAL_UART_TX_COMPLETE_CB_ID Tx Complete Callback ID
- * @arg @ref HAL_UART_RX_HALFCOMPLETE_CB_ID Rx Half Complete Callback ID
- * @arg @ref HAL_UART_RX_COMPLETE_CB_ID Rx Complete Callback ID
- * @arg @ref HAL_UART_ERROR_CB_ID Error Callback ID
- * @arg @ref HAL_UART_ABORT_COMPLETE_CB_ID Abort Complete Callback ID
- * @arg @ref HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID Abort Transmit Complete Callback ID
- * @arg @ref HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID Abort Receive Complete Callback ID
- * @arg @ref HAL_UART_WAKEUP_CB_ID Wakeup Callback ID
- * @arg @ref HAL_UART_MSPINIT_CB_ID MspInit Callback ID
- * @arg @ref HAL_UART_MSPDEINIT_CB_ID MspDeInit Callback ID
- * @param pCallback pointer to the Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID,
- pUART_CallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- if (huart->gState == HAL_UART_STATE_READY)
- {
- switch (CallbackID)
- {
- case HAL_UART_TX_HALFCOMPLETE_CB_ID :
- huart->TxHalfCpltCallback = pCallback;
- break;
-
- case HAL_UART_TX_COMPLETE_CB_ID :
- huart->TxCpltCallback = pCallback;
- break;
-
- case HAL_UART_RX_HALFCOMPLETE_CB_ID :
- huart->RxHalfCpltCallback = pCallback;
- break;
-
- case HAL_UART_RX_COMPLETE_CB_ID :
- huart->RxCpltCallback = pCallback;
- break;
-
- case HAL_UART_ERROR_CB_ID :
- huart->ErrorCallback = pCallback;
- break;
-
- case HAL_UART_ABORT_COMPLETE_CB_ID :
- huart->AbortCpltCallback = pCallback;
- break;
-
- case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
- huart->AbortTransmitCpltCallback = pCallback;
- break;
-
- case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
- huart->AbortReceiveCpltCallback = pCallback;
- break;
-
- case HAL_UART_WAKEUP_CB_ID :
- huart->WakeupCallback = pCallback;
- break;
-
-
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = pCallback;
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = pCallback;
- break;
-
- default :
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- break;
- }
- }
- else if (huart->gState == HAL_UART_STATE_RESET)
- {
- switch (CallbackID)
- {
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = pCallback;
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = pCallback;
- break;
-
- default :
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief Unregister an UART Callback
- * UART callaback is redirected to the weak predefined callback
- * @note The HAL_UART_UnRegisterCallback() may be called before HAL_UART_Init(), HAL_HalfDuplex_Init(),
- * HAL_LIN_Init(), HAL_MultiProcessor_Init() or HAL_RS485Ex_Init() in HAL_UART_STATE_RESET to un-register
- * callbacks for HAL_UART_MSPINIT_CB_ID and HAL_UART_MSPDEINIT_CB_ID
- * @param huart uart handle
- * @param CallbackID ID of the callback to be unregistered
- * This parameter can be one of the following values:
- * @arg @ref HAL_UART_TX_HALFCOMPLETE_CB_ID Tx Half Complete Callback ID
- * @arg @ref HAL_UART_TX_COMPLETE_CB_ID Tx Complete Callback ID
- * @arg @ref HAL_UART_RX_HALFCOMPLETE_CB_ID Rx Half Complete Callback ID
- * @arg @ref HAL_UART_RX_COMPLETE_CB_ID Rx Complete Callback ID
- * @arg @ref HAL_UART_ERROR_CB_ID Error Callback ID
- * @arg @ref HAL_UART_ABORT_COMPLETE_CB_ID Abort Complete Callback ID
- * @arg @ref HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID Abort Transmit Complete Callback ID
- * @arg @ref HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID Abort Receive Complete Callback ID
- * @arg @ref HAL_UART_WAKEUP_CB_ID Wakeup Callback ID
- * @arg @ref HAL_UART_MSPINIT_CB_ID MspInit Callback ID
- * @arg @ref HAL_UART_MSPDEINIT_CB_ID MspDeInit Callback ID
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (HAL_UART_STATE_READY == huart->gState)
- {
- switch (CallbackID)
- {
- case HAL_UART_TX_HALFCOMPLETE_CB_ID :
- huart->TxHalfCpltCallback = HAL_UART_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
- break;
-
- case HAL_UART_TX_COMPLETE_CB_ID :
- huart->TxCpltCallback = HAL_UART_TxCpltCallback; /* Legacy weak TxCpltCallback */
- break;
-
- case HAL_UART_RX_HALFCOMPLETE_CB_ID :
- huart->RxHalfCpltCallback = HAL_UART_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
- break;
-
- case HAL_UART_RX_COMPLETE_CB_ID :
- huart->RxCpltCallback = HAL_UART_RxCpltCallback; /* Legacy weak RxCpltCallback */
- break;
-
- case HAL_UART_ERROR_CB_ID :
- huart->ErrorCallback = HAL_UART_ErrorCallback; /* Legacy weak ErrorCallback */
- break;
-
- case HAL_UART_ABORT_COMPLETE_CB_ID :
- huart->AbortCpltCallback = HAL_UART_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
- break;
-
- case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
- huart->AbortTransmitCpltCallback = HAL_UART_AbortTransmitCpltCallback; /* Legacy weak
- AbortTransmitCpltCallback */
- break;
-
- case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
- huart->AbortReceiveCpltCallback = HAL_UART_AbortReceiveCpltCallback; /* Legacy weak
- AbortReceiveCpltCallback */
- break;
-
- case HAL_UART_WAKEUP_CB_ID :
- huart->WakeupCallback = HAL_UARTEx_WakeupCallback; /* Legacy weak WakeupCallback */
- break;
-
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = HAL_UART_MspInit; /* Legacy weak MspInitCallback */
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = HAL_UART_MspDeInit; /* Legacy weak MspDeInitCallback */
- break;
-
- default :
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- break;
- }
- }
- else if (HAL_UART_STATE_RESET == huart->gState)
- {
- switch (CallbackID)
- {
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = HAL_UART_MspInit;
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = HAL_UART_MspDeInit;
- break;
-
- default :
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief Register a User UART Rx Event Callback
- * To be used instead of the weak predefined callback
- * @param huart Uart handle
- * @param pCallback Pointer to the Rx Event Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- huart->RxEventCallback = pCallback;
- }
- else
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief UnRegister the UART Rx Event Callback
- * UART Rx Event Callback is redirected to the weak HAL_UARTEx_RxEventCallback() predefined callback
- * @param huart Uart handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak UART Rx Event Callback */
- }
- else
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- }
-
- return status;
-}
-
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @defgroup UART_Exported_Functions_Group2 IO operation functions
- * @brief UART Transmit/Receive functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- This subsection provides a set of functions allowing to manage the UART asynchronous
- and Half duplex data transfers.
-
- (#) There are two mode of transfer:
- (+) Blocking mode: The communication is performed in polling mode.
- The HAL status of all data processing is returned by the same function
- after finishing transfer.
- (+) Non-Blocking mode: The communication is performed using Interrupts
- or DMA, These API's return the HAL status.
- The end of the data processing will be indicated through the
- dedicated UART IRQ when using Interrupt mode or the DMA IRQ when
- using DMA mode.
- The HAL_UART_TxCpltCallback(), HAL_UART_RxCpltCallback() user callbacks
- will be executed respectively at the end of the transmit or Receive process
- The HAL_UART_ErrorCallback()user callback will be executed when a communication error is detected
-
- (#) Blocking mode API's are :
- (+) HAL_UART_Transmit()
- (+) HAL_UART_Receive()
-
- (#) Non-Blocking mode API's with Interrupt are :
- (+) HAL_UART_Transmit_IT()
- (+) HAL_UART_Receive_IT()
- (+) HAL_UART_IRQHandler()
-
- (#) Non-Blocking mode API's with DMA are :
- (+) HAL_UART_Transmit_DMA()
- (+) HAL_UART_Receive_DMA()
- (+) HAL_UART_DMAPause()
- (+) HAL_UART_DMAResume()
- (+) HAL_UART_DMAStop()
-
- (#) A set of Transfer Complete Callbacks are provided in Non_Blocking mode:
- (+) HAL_UART_TxHalfCpltCallback()
- (+) HAL_UART_TxCpltCallback()
- (+) HAL_UART_RxHalfCpltCallback()
- (+) HAL_UART_RxCpltCallback()
- (+) HAL_UART_ErrorCallback()
-
- (#) Non-Blocking mode transfers could be aborted using Abort API's :
- (+) HAL_UART_Abort()
- (+) HAL_UART_AbortTransmit()
- (+) HAL_UART_AbortReceive()
- (+) HAL_UART_Abort_IT()
- (+) HAL_UART_AbortTransmit_IT()
- (+) HAL_UART_AbortReceive_IT()
-
- (#) For Abort services based on interrupts (HAL_UART_Abortxxx_IT), a set of Abort Complete Callbacks are provided:
- (+) HAL_UART_AbortCpltCallback()
- (+) HAL_UART_AbortTransmitCpltCallback()
- (+) HAL_UART_AbortReceiveCpltCallback()
-
- (#) A Rx Event Reception Callback (Rx event notification) is available for Non_Blocking modes of enhanced
- reception services:
- (+) HAL_UARTEx_RxEventCallback()
-
- (#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
- Errors are handled as follows :
- (+) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is
- to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error
- in Interrupt mode reception .
- Received character is then retrieved and stored in Rx buffer, Error code is set to allow user
- to identify error type, and HAL_UART_ErrorCallback() user callback is executed.
- Transfer is kept ongoing on UART side.
- If user wants to abort it, Abort services should be called by user.
- (+) Error is considered as Blocking : Transfer could not be completed properly and is aborted.
- This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode.
- Error code is set to allow user to identify error type, and HAL_UART_ErrorCallback()
- user callback is executed.
-
- -@- In the Half duplex communication, it is forbidden to run the transmit
- and receive process in parallel, the UART state HAL_UART_STATE_BUSY_TX_RX can't be useful.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Send an amount of data in blocking mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the sent data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 provided through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be sent.
- * @param Timeout Timeout duration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size, uint32_t Timeout)
-{
- const uint8_t *pdata8bits;
- const uint16_t *pdata16bits;
- uint32_t tickstart;
-
- /* Check that a Tx process is not already ongoing */
- if (huart->gState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_BUSY_TX;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- huart->TxXferSize = Size;
- huart->TxXferCount = Size;
-
- /* In case of 9bits/No Parity transfer, pData needs to be handled as a uint16_t pointer */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (const uint16_t *) pData;
- }
- else
- {
- pdata8bits = pData;
- pdata16bits = NULL;
- }
-
- while (huart->TxXferCount > 0U)
- {
- if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
- {
-
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_TIMEOUT;
- }
- if (pdata8bits == NULL)
- {
- huart->Instance->TDR = (uint16_t)(*pdata16bits & 0x01FFU);
- pdata16bits++;
- }
- else
- {
- huart->Instance->TDR = (uint8_t)(*pdata8bits & 0xFFU);
- pdata8bits++;
- }
- huart->TxXferCount--;
- }
-
- if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK)
- {
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_TIMEOUT;
- }
-
- /* At end of Tx process, restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in blocking mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @param Timeout Timeout duration.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
-{
- uint8_t *pdata8bits;
- uint16_t *pdata16bits;
- uint16_t uhMask;
- uint32_t tickstart;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- huart->RxXferSize = Size;
- huart->RxXferCount = Size;
-
- /* Computation of UART mask to apply to RDR register */
- UART_MASK_COMPUTATION(huart);
- uhMask = huart->Mask;
-
- /* In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (uint16_t *) pData;
- }
- else
- {
- pdata8bits = pData;
- pdata16bits = NULL;
- }
-
- /* as long as data have to be received */
- while (huart->RxXferCount > 0U)
- {
- if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
- {
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_TIMEOUT;
- }
- if (pdata8bits == NULL)
- {
- *pdata16bits = (uint16_t)(huart->Instance->RDR & uhMask);
- pdata16bits++;
- }
- else
- {
- *pdata8bits = (uint8_t)(huart->Instance->RDR & (uint8_t)uhMask);
- pdata8bits++;
- }
- huart->RxXferCount--;
- }
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Send an amount of data in interrupt mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the sent data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 provided through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be sent.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size)
-{
- /* Check that a Tx process is not already ongoing */
- if (huart->gState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- huart->pTxBuffPtr = pData;
- huart->TxXferSize = Size;
- huart->TxXferCount = Size;
- huart->TxISR = NULL;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_BUSY_TX;
-
- /* Set the Tx ISR function pointer according to the data word length */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- huart->TxISR = UART_TxISR_16BIT;
- }
- else
- {
- huart->TxISR = UART_TxISR_8BIT;
- }
-
- /* Enable the Transmit Data Register Empty interrupt */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in interrupt mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Set Reception type to Standard reception */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Check that USART RTOEN bit is set */
- if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
- {
- /* Enable the UART Receiver Timeout Interrupt */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
- }
-
- return (UART_Start_Receive_IT(huart, pData, Size));
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Send an amount of data in DMA mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the sent data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 provided through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be sent.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size)
-{
- /* Check that a Tx process is not already ongoing */
- if (huart->gState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- huart->pTxBuffPtr = pData;
- huart->TxXferSize = Size;
- huart->TxXferCount = Size;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_BUSY_TX;
-
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA transfer complete callback */
- huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt;
-
- /* Set the UART DMA Half transfer complete callback */
- huart->hdmatx->XferHalfCpltCallback = UART_DMATxHalfCplt;
-
- /* Set the DMA error callback */
- huart->hdmatx->XferErrorCallback = UART_DMAError;
-
- /* Set the DMA abort callback */
- huart->hdmatx->XferAbortCallback = NULL;
-
- /* Enable the UART transmit DMA channel */
- if (HAL_DMA_Start_IT(huart->hdmatx, (uint32_t)huart->pTxBuffPtr, (uint32_t)&huart->Instance->TDR, Size) != HAL_OK)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- /* Restore huart->gState to ready */
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_ERROR;
- }
- }
- /* Clear the TC flag in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_TCF);
-
- /* Enable the DMA transfer for transmit request by setting the DMAT bit
- in the UART CR3 register */
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in DMA mode.
- * @note When the UART parity is enabled (PCE = 1), the received data contain
- * the parity bit (MSB position).
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Set Reception type to Standard reception */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Check that USART RTOEN bit is set */
- if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
- {
- /* Enable the UART Receiver Timeout Interrupt */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
- }
-
- return (UART_Start_Receive_DMA(huart, pData, Size));
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Pause the DMA Transfer.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
-{
- const HAL_UART_StateTypeDef gstate = huart->gState;
- const HAL_UART_StateTypeDef rxstate = huart->RxState;
-
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT)) &&
- (gstate == HAL_UART_STATE_BUSY_TX))
- {
- /* Disable the UART DMA Tx request */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
- }
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) &&
- (rxstate == HAL_UART_STATE_BUSY_RX))
- {
- /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Disable the UART DMA Rx request */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Resume the DMA Transfer.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
-{
- if (huart->gState == HAL_UART_STATE_BUSY_TX)
- {
- /* Enable the UART DMA Tx request */
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
- }
- if (huart->RxState == HAL_UART_STATE_BUSY_RX)
- {
- /* Clear the Overrun flag before resuming the Rx transfer */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
-
- /* Re-enable PE and ERR (Frame error, noise error, overrun error) interrupts */
- if (huart->Init.Parity != UART_PARITY_NONE)
- {
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- }
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Enable the UART DMA Rx request */
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Stop the DMA Transfer.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
-{
- /* The Lock is not implemented on this API to allow the user application
- to call the HAL UART API under callbacks HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback() /
- HAL_UART_TxHalfCpltCallback / HAL_UART_RxHalfCpltCallback:
- indeed, when HAL_DMA_Abort() API is called, the DMA TX/RX Transfer or Half Transfer complete
- interrupt is generated if the DMA transfer interruption occurs at the middle or at the end of
- the stream and the corresponding call back is executed. */
-
- const HAL_UART_StateTypeDef gstate = huart->gState;
- const HAL_UART_StateTypeDef rxstate = huart->RxState;
-
- /* Stop UART DMA Tx request if ongoing */
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT)) &&
- (gstate == HAL_UART_STATE_BUSY_TX))
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel */
- if (huart->hdmatx != NULL)
- {
- if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- UART_EndTxTransfer(huart);
- }
-
- /* Stop UART DMA Rx request if ongoing */
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) &&
- (rxstate == HAL_UART_STATE_BUSY_RX))
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel */
- if (huart->hdmarx != NULL)
- {
- if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- UART_EndRxTransfer(huart);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing transfers (blocking mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx and Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
- * - Set handle State to READY
- * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* Abort the UART DMA Tx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- /* Disable the UART DMA Tx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmatx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Abort the UART DMA Rx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* Disable the UART DMA Rx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Reset Tx and Rx transfer counters */
- huart->TxXferCount = 0U;
- huart->RxXferCount = 0U;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
-
- /* Discard the received data */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Transmit transfer (blocking mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
- * - Set handle State to READY
- * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE and TCIE interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
-
- /* Abort the UART DMA Tx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- /* Disable the UART DMA Tx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmatx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Reset Tx transfer counter */
- huart->TxXferCount = 0U;
-
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Receive transfer (blocking mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
- * - Set handle State to READY
- * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
-{
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* Abort the UART DMA Rx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* Disable the UART DMA Rx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Reset Rx transfer counter */
- huart->RxXferCount = 0U;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
- /* Discard the received data */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing transfers (Interrupt mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx and Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
- * - Set handle State to READY
- * - At abort completion, call user abort complete callback
- * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
- * considered as completed only when user abort complete callback is executed (not when exiting function).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
-{
- uint32_t abortcplt = 1U;
-
- /* Disable interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* If DMA Tx and/or DMA Rx Handles are associated to UART Handle, DMA Abort complete callbacks should be initialised
- before any call to DMA Abort functions */
- /* DMA Tx Handle is valid */
- if (huart->hdmatx != NULL)
- {
- /* Set DMA Abort Complete callback if UART DMA Tx request if enabled.
- Otherwise, set it to NULL */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- huart->hdmatx->XferAbortCallback = UART_DMATxAbortCallback;
- }
- else
- {
- huart->hdmatx->XferAbortCallback = NULL;
- }
- }
- /* DMA Rx Handle is valid */
- if (huart->hdmarx != NULL)
- {
- /* Set DMA Abort Complete callback if UART DMA Rx request if enabled.
- Otherwise, set it to NULL */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- huart->hdmarx->XferAbortCallback = UART_DMARxAbortCallback;
- }
- else
- {
- huart->hdmarx->XferAbortCallback = NULL;
- }
- }
-
- /* Abort the UART DMA Tx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- /* Disable DMA Tx at UART level */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
- if (huart->hdmatx != NULL)
- {
- /* UART Tx DMA Abort callback has already been initialised :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
-
- /* Abort DMA TX */
- if (HAL_DMA_Abort_IT(huart->hdmatx) != HAL_OK)
- {
- huart->hdmatx->XferAbortCallback = NULL;
- }
- else
- {
- abortcplt = 0U;
- }
- }
- }
-
- /* Abort the UART DMA Rx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* Disable the UART DMA Rx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
- if (huart->hdmarx != NULL)
- {
- /* UART Rx DMA Abort callback has already been initialised :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
-
- /* Abort DMA RX */
- if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
- {
- huart->hdmarx->XferAbortCallback = NULL;
- abortcplt = 1U;
- }
- else
- {
- abortcplt = 0U;
- }
- }
- }
-
- /* if no DMA abort complete callback execution is required => call user Abort Complete callback */
- if (abortcplt == 1U)
- {
- /* Reset Tx and Rx transfer counters */
- huart->TxXferCount = 0U;
- huart->RxXferCount = 0U;
-
- /* Clear ISR function pointers */
- huart->RxISR = NULL;
- huart->TxISR = NULL;
-
- /* Reset errorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
-
- /* Discard the received data */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort complete callback */
- huart->AbortCpltCallback(huart);
-#else
- /* Call legacy weak Abort complete callback */
- HAL_UART_AbortCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Transmit transfer (Interrupt mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
- * - Set handle State to READY
- * - At abort completion, call user abort complete callback
- * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
- * considered as completed only when user abort complete callback is executed (not when exiting function).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
-{
- /* Disable interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
-
- /* Abort the UART DMA Tx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- /* Disable the UART DMA Tx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA Abort callback :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
- huart->hdmatx->XferAbortCallback = UART_DMATxOnlyAbortCallback;
-
- /* Abort DMA TX */
- if (HAL_DMA_Abort_IT(huart->hdmatx) != HAL_OK)
- {
- /* Call Directly huart->hdmatx->XferAbortCallback function in case of error */
- huart->hdmatx->XferAbortCallback(huart->hdmatx);
- }
- }
- else
- {
- /* Reset Tx transfer counter */
- huart->TxXferCount = 0U;
-
- /* Clear TxISR function pointers */
- huart->TxISR = NULL;
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Transmit Complete Callback */
- huart->AbortTransmitCpltCallback(huart);
-#else
- /* Call legacy weak Abort Transmit Complete Callback */
- HAL_UART_AbortTransmitCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Reset Tx transfer counter */
- huart->TxXferCount = 0U;
-
- /* Clear TxISR function pointers */
- huart->TxISR = NULL;
-
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Transmit Complete Callback */
- huart->AbortTransmitCpltCallback(huart);
-#else
- /* Call legacy weak Abort Transmit Complete Callback */
- HAL_UART_AbortTransmitCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Receive transfer (Interrupt mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
- * - Set handle State to READY
- * - At abort completion, call user abort complete callback
- * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
- * considered as completed only when user abort complete callback is executed (not when exiting function).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
-{
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* Abort the UART DMA Rx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* Disable the UART DMA Rx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = UART_DMARxOnlyAbortCallback;
-
- /* Abort DMA RX */
- if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
- {
- /* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
- huart->hdmarx->XferAbortCallback(huart->hdmarx);
- }
- }
- else
- {
- /* Reset Rx transfer counter */
- huart->RxXferCount = 0U;
-
- /* Clear RxISR function pointer */
- huart->pRxBuffPtr = NULL;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
- /* Discard the received data */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Receive Complete Callback */
- huart->AbortReceiveCpltCallback(huart);
-#else
- /* Call legacy weak Abort Receive Complete Callback */
- HAL_UART_AbortReceiveCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Reset Rx transfer counter */
- huart->RxXferCount = 0U;
-
- /* Clear RxISR function pointer */
- huart->pRxBuffPtr = NULL;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Receive Complete Callback */
- huart->AbortReceiveCpltCallback(huart);
-#else
- /* Call legacy weak Abort Receive Complete Callback */
- HAL_UART_AbortReceiveCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Handle UART interrupt request.
- * @param huart UART handle.
- * @retval None
- */
-void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
-{
- uint32_t isrflags = READ_REG(huart->Instance->ISR);
- uint32_t cr1its = READ_REG(huart->Instance->CR1);
- uint32_t cr3its = READ_REG(huart->Instance->CR3);
-
- uint32_t errorflags;
- uint32_t errorcode;
-
- /* If no error occurs */
- errorflags = (isrflags & (uint32_t)(USART_ISR_PE | USART_ISR_FE | USART_ISR_ORE | USART_ISR_NE | USART_ISR_RTOF));
- if (errorflags == 0U)
- {
- /* UART in mode Receiver ---------------------------------------------------*/
- if (((isrflags & USART_ISR_RXNE) != 0U)
- && ((cr1its & USART_CR1_RXNEIE) != 0U))
- {
- if (huart->RxISR != NULL)
- {
- huart->RxISR(huart);
- }
- return;
- }
- }
-
- /* If some errors occur */
- if ((errorflags != 0U)
- && (((cr3its & USART_CR3_EIE) != 0U)
- || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_RTOIE)) != 0U)))
- {
- /* UART parity error interrupt occurred -------------------------------------*/
- if (((isrflags & USART_ISR_PE) != 0U) && ((cr1its & USART_CR1_PEIE) != 0U))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_PEF);
-
- huart->ErrorCode |= HAL_UART_ERROR_PE;
- }
-
- /* UART frame error interrupt occurred --------------------------------------*/
- if (((isrflags & USART_ISR_FE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_FEF);
-
- huart->ErrorCode |= HAL_UART_ERROR_FE;
- }
-
- /* UART noise error interrupt occurred --------------------------------------*/
- if (((isrflags & USART_ISR_NE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_NEF);
-
- huart->ErrorCode |= HAL_UART_ERROR_NE;
- }
-
- /* UART Over-Run interrupt occurred -----------------------------------------*/
- if (((isrflags & USART_ISR_ORE) != 0U)
- && (((cr1its & USART_CR1_RXNEIE) != 0U) ||
- ((cr3its & USART_CR3_EIE) != 0U)))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
-
- huart->ErrorCode |= HAL_UART_ERROR_ORE;
- }
-
- /* UART Receiver Timeout interrupt occurred ---------------------------------*/
- if (((isrflags & USART_ISR_RTOF) != 0U) && ((cr1its & USART_CR1_RTOIE) != 0U))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_RTOF);
-
- huart->ErrorCode |= HAL_UART_ERROR_RTO;
- }
-
- /* Call UART Error Call back function if need be ----------------------------*/
- if (huart->ErrorCode != HAL_UART_ERROR_NONE)
- {
- /* UART in mode Receiver --------------------------------------------------*/
- if (((isrflags & USART_ISR_RXNE) != 0U)
- && ((cr1its & USART_CR1_RXNEIE) != 0U))
- {
- if (huart->RxISR != NULL)
- {
- huart->RxISR(huart);
- }
- }
-
- /* If Error is to be considered as blocking :
- - Receiver Timeout error in Reception
- - Overrun error in Reception
- - any error occurs in DMA mode reception
- */
- errorcode = huart->ErrorCode;
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) ||
- ((errorcode & (HAL_UART_ERROR_RTO | HAL_UART_ERROR_ORE)) != 0U))
- {
- /* Blocking error : transfer is aborted
- Set the UART state ready to be able to start again the process,
- Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
- UART_EndRxTransfer(huart);
-
- /* Abort the UART DMA Rx channel if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* Disable the UART DMA Rx request if enabled */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback :
- will lead to call HAL_UART_ErrorCallback() at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = UART_DMAAbortOnError;
-
- /* Abort DMA RX */
- if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
- {
- /* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
- huart->hdmarx->XferAbortCallback(huart->hdmarx);
- }
- }
- else
- {
- /* Call user error callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
- }
- }
- else
- {
- /* Call user error callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Non Blocking error : transfer could go on.
- Error is notified to user through user error callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- }
- }
- return;
-
- } /* End if some error occurs */
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : */
- if ((huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- && ((isrflags & USART_ISR_IDLE) != 0U)
- && ((cr1its & USART_ISR_IDLE) != 0U))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
-
- /* Check if DMA mode is enabled in UART */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* DMA mode enabled */
- /* Check received length : If all expected data are received, do nothing,
- (DMA cplt callback will be called).
- Otherwise, if at least one data has already been received, IDLE event is to be notified to user */
- uint16_t nb_remaining_rx_data = (uint16_t) __HAL_DMA_GET_COUNTER(huart->hdmarx);
- if ((nb_remaining_rx_data > 0U)
- && (nb_remaining_rx_data < huart->RxXferSize))
- {
- /* Reception is not complete */
- huart->RxXferCount = nb_remaining_rx_data;
-
- /* In Normal mode, end DMA xfer and HAL UART Rx process*/
- if (huart->hdmarx->Init.Mode != DMA_CIRCULAR)
- {
- /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Disable the DMA transfer for the receiver request by resetting the DMAR bit
- in the UART CR3 register */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-
- /* Last bytes received, so no need as the abort is immediate */
- (void)HAL_DMA_Abort(huart->hdmarx);
- }
-
- /* Initialize type of RxEvent that correspond to RxEvent callback execution;
- In this case, Rx Event type is Idle Event */
- huart->RxEventType = HAL_UART_RXEVENT_IDLE;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount));
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount));
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
- return;
- }
- else
- {
- /* DMA mode not enabled */
- /* Check received length : If all expected data are received, do nothing.
- Otherwise, if at least one data has already been received, IDLE event is to be notified to user */
- uint16_t nb_rx_data = huart->RxXferSize - huart->RxXferCount;
- if ((huart->RxXferCount > 0U)
- && (nb_rx_data > 0U))
- {
- /* Disable the UART Parity Error Interrupt and RXNE interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
-
- /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Rx process is completed, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Clear RxISR function pointer */
- huart->RxISR = NULL;
-
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-
- /* Initialize type of RxEvent that correspond to RxEvent callback execution;
- In this case, Rx Event type is Idle Event */
- huart->RxEventType = HAL_UART_RXEVENT_IDLE;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxEventCallback(huart, nb_rx_data);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, nb_rx_data);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
- return;
- }
- }
-
- /* UART wakeup from Stop mode interrupt occurred ---------------------------*/
- if (((isrflags & USART_ISR_WUF) != 0U) && ((cr3its & USART_CR3_WUFIE) != 0U))
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_WUF);
-
- /* UART Rx state is not reset as a reception process might be ongoing.
- If UART handle state fields need to be reset to READY, this could be done in Wakeup callback */
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Wakeup Callback */
- huart->WakeupCallback(huart);
-#else
- /* Call legacy weak Wakeup Callback */
- HAL_UARTEx_WakeupCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- return;
- }
-
- /* UART in mode Transmitter ------------------------------------------------*/
- if (((isrflags & USART_ISR_TXE) != 0U)
- && ((cr1its & USART_CR1_TXEIE) != 0U))
- {
- if (huart->TxISR != NULL)
- {
- huart->TxISR(huart);
- }
- return;
- }
-
- /* UART in mode Transmitter (transmission end) -----------------------------*/
- if (((isrflags & USART_ISR_TC) != 0U) && ((cr1its & USART_CR1_TCIE) != 0U))
- {
- UART_EndTransmit_IT(huart);
- return;
- }
-
-}
-
-/**
- * @brief Tx Transfer completed callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_TxCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief Tx Half Transfer completed callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_TxHalfCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief Rx Transfer completed callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_RxCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief Rx Half Transfer completed callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_RxHalfCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief UART error callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_ErrorCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief UART Abort Complete callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_AbortCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief UART Abort Complete callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_AbortTransmitCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief UART Abort Receive Complete callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_AbortReceiveCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief Reception Event Callback (Rx event notification called after use of advanced reception service).
- * @param huart UART handle
- * @param Size Number of data available in application reception buffer (indicates a position in
- * reception buffer until which, data are available)
- * @retval None
- */
-__weak void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- UNUSED(Size);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UARTEx_RxEventCallback can be implemented in the user file.
- */
-}
-
-/**
- * @}
- */
-
-/** @defgroup UART_Exported_Functions_Group3 Peripheral Control functions
- * @brief UART control functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to control the UART.
- (+) HAL_UART_ReceiverTimeout_Config() API allows to configure the receiver timeout value on the fly
- (+) HAL_UART_EnableReceiverTimeout() API enables the receiver timeout feature
- (+) HAL_UART_DisableReceiverTimeout() API disables the receiver timeout feature
- (+) HAL_MultiProcessor_EnableMuteMode() API enables mute mode
- (+) HAL_MultiProcessor_DisableMuteMode() API disables mute mode
- (+) HAL_MultiProcessor_EnterMuteMode() API enters mute mode
- (+) UART_SetConfig() API configures the UART peripheral
- (+) UART_AdvFeatureConfig() API optionally configures the UART advanced features
- (+) UART_CheckIdleState() API ensures that TEACK and/or REACK are set after initialization
- (+) HAL_HalfDuplex_EnableTransmitter() API disables receiver and enables transmitter
- (+) HAL_HalfDuplex_EnableReceiver() API disables transmitter and enables receiver
- (+) HAL_LIN_SendBreak() API transmits the break characters
-@endverbatim
- * @{
- */
-
-/**
- * @brief Update on the fly the receiver timeout value in RTOR register.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param TimeoutValue receiver timeout value in number of baud blocks. The timeout
- * value must be less or equal to 0x0FFFFFFFF.
- * @retval None
- */
-void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart, uint32_t TimeoutValue)
-{
- assert_param(IS_UART_RECEIVER_TIMEOUT_VALUE(TimeoutValue));
- MODIFY_REG(huart->Instance->RTOR, USART_RTOR_RTO, TimeoutValue);
-}
-
-/**
- * @brief Enable the UART receiver timeout feature.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_EnableReceiverTimeout(UART_HandleTypeDef *huart)
-{
- if (huart->gState == HAL_UART_STATE_READY)
- {
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Set the USART RTOEN bit */
- SET_BIT(huart->Instance->CR2, USART_CR2_RTOEN);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Disable the UART receiver timeout feature.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DisableReceiverTimeout(UART_HandleTypeDef *huart)
-{
- if (huart->gState == HAL_UART_STATE_READY)
- {
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Clear the USART RTOEN bit */
- CLEAR_BIT(huart->Instance->CR2, USART_CR2_RTOEN);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Enable UART in mute mode (does not mean UART enters mute mode;
- * to enter mute mode, HAL_MultiProcessor_EnterMuteMode() API must be called).
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart)
-{
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Enable USART mute mode by setting the MME bit in the CR1 register */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_MME);
-
- huart->gState = HAL_UART_STATE_READY;
-
- return (UART_CheckIdleState(huart));
-}
-
-/**
- * @brief Disable UART mute mode (does not mean the UART actually exits mute mode
- * as it may not have been in mute mode at this very moment).
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart)
-{
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable USART mute mode by clearing the MME bit in the CR1 register */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_MME);
-
- huart->gState = HAL_UART_STATE_READY;
-
- return (UART_CheckIdleState(huart));
-}
-
-/**
- * @brief Enter UART mute mode (means UART actually enters mute mode).
- * @note To exit from mute mode, HAL_MultiProcessor_DisableMuteMode() API must be called.
- * @param huart UART handle.
- * @retval None
- */
-void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart)
-{
- __HAL_UART_SEND_REQ(huart, UART_MUTE_MODE_REQUEST);
-}
-
-/**
- * @brief Enable the UART transmitter and disable the UART receiver.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
-{
- __HAL_LOCK(huart);
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Clear TE and RE bits */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
-
- /* Enable the USART's transmit interface by setting the TE bit in the USART CR1 register */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TE);
-
- huart->gState = HAL_UART_STATE_READY;
-
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Enable the UART receiver and disable the UART transmitter.
- * @param huart UART handle.
- * @retval HAL status.
- */
-HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
-{
- __HAL_LOCK(huart);
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Clear TE and RE bits */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
-
- /* Enable the USART's receive interface by setting the RE bit in the USART CR1 register */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RE);
-
- huart->gState = HAL_UART_STATE_READY;
-
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-
-/**
- * @brief Transmit break characters.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
-{
- /* Check the parameters */
- assert_param(IS_UART_LIN_INSTANCE(huart->Instance));
-
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Send break characters */
- __HAL_UART_SEND_REQ(huart, UART_SENDBREAK_REQUEST);
-
- huart->gState = HAL_UART_STATE_READY;
-
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/** @defgroup UART_Exported_Functions_Group4 Peripheral State and Error functions
- * @brief UART Peripheral State functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral State and Error functions #####
- ==============================================================================
- [..]
- This subsection provides functions allowing to :
- (+) Return the UART handle state.
- (+) Return the UART handle error code
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Return the UART handle state.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART.
- * @retval HAL state
- */
-HAL_UART_StateTypeDef HAL_UART_GetState(const UART_HandleTypeDef *huart)
-{
- uint32_t temp1;
- uint32_t temp2;
- temp1 = huart->gState;
- temp2 = huart->RxState;
-
- return (HAL_UART_StateTypeDef)(temp1 | temp2);
-}
-
-/**
- * @brief Return the UART handle error code.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART.
- * @retval UART Error Code
- */
-uint32_t HAL_UART_GetError(const UART_HandleTypeDef *huart)
-{
- return huart->ErrorCode;
-}
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @defgroup UART_Private_Functions UART Private Functions
- * @{
- */
-
-/**
- * @brief Initialize the callbacks to their default values.
- * @param huart UART handle.
- * @retval none
- */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-void UART_InitCallbacksToDefault(UART_HandleTypeDef *huart)
-{
- /* Init the UART Callback settings */
- huart->TxHalfCpltCallback = HAL_UART_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
- huart->TxCpltCallback = HAL_UART_TxCpltCallback; /* Legacy weak TxCpltCallback */
- huart->RxHalfCpltCallback = HAL_UART_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
- huart->RxCpltCallback = HAL_UART_RxCpltCallback; /* Legacy weak RxCpltCallback */
- huart->ErrorCallback = HAL_UART_ErrorCallback; /* Legacy weak ErrorCallback */
- huart->AbortCpltCallback = HAL_UART_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
- huart->AbortTransmitCpltCallback = HAL_UART_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
- huart->AbortReceiveCpltCallback = HAL_UART_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
- huart->WakeupCallback = HAL_UARTEx_WakeupCallback; /* Legacy weak WakeupCallback */
- huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak RxEventCallback */
-
-}
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-/**
- * @brief Configure the UART peripheral.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart)
-{
- uint32_t tmpreg;
- uint16_t brrtemp;
- UART_ClockSourceTypeDef clocksource;
- uint32_t usartdiv;
- HAL_StatusTypeDef ret = HAL_OK;
- uint32_t pclk;
-
- /* Check the parameters */
- assert_param(IS_UART_BAUDRATE(huart->Init.BaudRate));
- assert_param(IS_UART_WORD_LENGTH(huart->Init.WordLength));
- assert_param(IS_UART_STOPBITS(huart->Init.StopBits));
- assert_param(IS_UART_ONE_BIT_SAMPLE(huart->Init.OneBitSampling));
-
- assert_param(IS_UART_PARITY(huart->Init.Parity));
- assert_param(IS_UART_MODE(huart->Init.Mode));
- assert_param(IS_UART_HARDWARE_FLOW_CONTROL(huart->Init.HwFlowCtl));
- assert_param(IS_UART_OVERSAMPLING(huart->Init.OverSampling));
-
- /*-------------------------- USART CR1 Configuration -----------------------*/
- /* Clear M, PCE, PS, TE, RE and OVER8 bits and configure
- * the UART Word Length, Parity, Mode and oversampling:
- * set the M bits according to huart->Init.WordLength value
- * set PCE and PS bits according to huart->Init.Parity value
- * set TE and RE bits according to huart->Init.Mode value
- * set OVER8 bit according to huart->Init.OverSampling value */
- tmpreg = (uint32_t)huart->Init.WordLength | huart->Init.Parity | huart->Init.Mode | huart->Init.OverSampling ;
- MODIFY_REG(huart->Instance->CR1, USART_CR1_FIELDS, tmpreg);
-
- /*-------------------------- USART CR2 Configuration -----------------------*/
- /* Configure the UART Stop Bits: Set STOP[13:12] bits according
- * to huart->Init.StopBits value */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_STOP, huart->Init.StopBits);
-
- /*-------------------------- USART CR3 Configuration -----------------------*/
- /* Configure
- * - UART HardWare Flow Control: set CTSE and RTSE bits according
- * to huart->Init.HwFlowCtl value
- * - one-bit sampling method versus three samples' majority rule according
- * to huart->Init.OneBitSampling (not applicable to LPUART) */
- tmpreg = (uint32_t)huart->Init.HwFlowCtl;
-
- tmpreg |= huart->Init.OneBitSampling;
- MODIFY_REG(huart->Instance->CR3, USART_CR3_FIELDS, tmpreg);
-
-
- /*-------------------------- USART BRR Configuration -----------------------*/
- UART_GETCLOCKSOURCE(huart, clocksource);
-
- if (huart->Init.OverSampling == UART_OVERSAMPLING_8)
- {
- switch (clocksource)
- {
- case UART_CLOCKSOURCE_PCLK1:
- pclk = HAL_RCC_GetPCLK1Freq();
- break;
- case UART_CLOCKSOURCE_PCLK2:
- pclk = HAL_RCC_GetPCLK2Freq();
- break;
- case UART_CLOCKSOURCE_HSI:
- pclk = (uint32_t) HSI_VALUE;
- break;
- case UART_CLOCKSOURCE_SYSCLK:
- pclk = HAL_RCC_GetSysClockFreq();
- break;
- case UART_CLOCKSOURCE_LSE:
- pclk = (uint32_t) LSE_VALUE;
- break;
- default:
- pclk = 0U;
- ret = HAL_ERROR;
- break;
- }
-
- /* USARTDIV must be greater than or equal to 0d16 */
- if (pclk != 0U)
- {
- usartdiv = (uint32_t)(UART_DIV_SAMPLING8(pclk, huart->Init.BaudRate));
- if ((usartdiv >= UART_BRR_MIN) && (usartdiv <= UART_BRR_MAX))
- {
- brrtemp = (uint16_t)(usartdiv & 0xFFF0U);
- brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
- huart->Instance->BRR = brrtemp;
- }
- else
- {
- ret = HAL_ERROR;
- }
- }
- }
- else
- {
- switch (clocksource)
- {
- case UART_CLOCKSOURCE_PCLK1:
- pclk = HAL_RCC_GetPCLK1Freq();
- break;
- case UART_CLOCKSOURCE_PCLK2:
- pclk = HAL_RCC_GetPCLK2Freq();
- break;
- case UART_CLOCKSOURCE_HSI:
- pclk = (uint32_t) HSI_VALUE;
- break;
- case UART_CLOCKSOURCE_SYSCLK:
- pclk = HAL_RCC_GetSysClockFreq();
- break;
- case UART_CLOCKSOURCE_LSE:
- pclk = (uint32_t) LSE_VALUE;
- break;
- default:
- pclk = 0U;
- ret = HAL_ERROR;
- break;
- }
-
- if (pclk != 0U)
- {
- /* USARTDIV must be greater than or equal to 0d16 */
- usartdiv = (uint32_t)(UART_DIV_SAMPLING16(pclk, huart->Init.BaudRate));
- if ((usartdiv >= UART_BRR_MIN) && (usartdiv <= UART_BRR_MAX))
- {
- huart->Instance->BRR = (uint16_t)usartdiv;
- }
- else
- {
- ret = HAL_ERROR;
- }
- }
- }
-
-
- /* Clear ISR function pointers */
- huart->RxISR = NULL;
- huart->TxISR = NULL;
-
- return ret;
-}
-
-/**
- * @brief Configure the UART peripheral advanced features.
- * @param huart UART handle.
- * @retval None
- */
-void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
-{
- /* Check whether the set of advanced features to configure is properly set */
- assert_param(IS_UART_ADVFEATURE_INIT(huart->AdvancedInit.AdvFeatureInit));
-
- /* if required, configure RX/TX pins swap */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_SWAP_INIT))
- {
- assert_param(IS_UART_ADVFEATURE_SWAP(huart->AdvancedInit.Swap));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_SWAP, huart->AdvancedInit.Swap);
- }
-
- /* if required, configure TX pin active level inversion */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_TXINVERT_INIT))
- {
- assert_param(IS_UART_ADVFEATURE_TXINV(huart->AdvancedInit.TxPinLevelInvert));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_TXINV, huart->AdvancedInit.TxPinLevelInvert);
- }
-
- /* if required, configure RX pin active level inversion */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_RXINVERT_INIT))
- {
- assert_param(IS_UART_ADVFEATURE_RXINV(huart->AdvancedInit.RxPinLevelInvert));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_RXINV, huart->AdvancedInit.RxPinLevelInvert);
- }
-
- /* if required, configure data inversion */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_DATAINVERT_INIT))
- {
- assert_param(IS_UART_ADVFEATURE_DATAINV(huart->AdvancedInit.DataInvert));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_DATAINV, huart->AdvancedInit.DataInvert);
- }
-
- /* if required, configure RX overrun detection disabling */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_RXOVERRUNDISABLE_INIT))
- {
- assert_param(IS_UART_OVERRUN(huart->AdvancedInit.OverrunDisable));
- MODIFY_REG(huart->Instance->CR3, USART_CR3_OVRDIS, huart->AdvancedInit.OverrunDisable);
- }
-
- /* if required, configure DMA disabling on reception error */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_DMADISABLEONERROR_INIT))
- {
- assert_param(IS_UART_ADVFEATURE_DMAONRXERROR(huart->AdvancedInit.DMADisableonRxError));
- MODIFY_REG(huart->Instance->CR3, USART_CR3_DDRE, huart->AdvancedInit.DMADisableonRxError);
- }
-
- /* if required, configure auto Baud rate detection scheme */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_AUTOBAUDRATE_INIT))
- {
- assert_param(IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(huart->Instance));
- assert_param(IS_UART_ADVFEATURE_AUTOBAUDRATE(huart->AdvancedInit.AutoBaudRateEnable));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_ABREN, huart->AdvancedInit.AutoBaudRateEnable);
- /* set auto Baudrate detection parameters if detection is enabled */
- if (huart->AdvancedInit.AutoBaudRateEnable == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE)
- {
- assert_param(IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(huart->AdvancedInit.AutoBaudRateMode));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_ABRMODE, huart->AdvancedInit.AutoBaudRateMode);
- }
- }
-
- /* if required, configure MSB first on communication line */
- if (HAL_IS_BIT_SET(huart->AdvancedInit.AdvFeatureInit, UART_ADVFEATURE_MSBFIRST_INIT))
- {
- assert_param(IS_UART_ADVFEATURE_MSBFIRST(huart->AdvancedInit.MSBFirst));
- MODIFY_REG(huart->Instance->CR2, USART_CR2_MSBFIRST, huart->AdvancedInit.MSBFirst);
- }
-}
-
-/**
- * @brief Check the UART Idle State.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart)
-{
- uint32_t tickstart;
-
- /* Initialize the UART ErrorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- /* Check if the Transmitter is enabled */
- if ((huart->Instance->CR1 & USART_CR1_TE) == USART_CR1_TE)
- {
- /* Wait until TEACK flag is set */
- if (UART_WaitOnFlagUntilTimeout(huart, USART_ISR_TEACK, RESET, tickstart, HAL_UART_TIMEOUT_VALUE) != HAL_OK)
- {
- /* Disable TXE interrupt for the interrupt process */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE));
-
- huart->gState = HAL_UART_STATE_READY;
-
- __HAL_UNLOCK(huart);
-
- /* Timeout occurred */
- return HAL_TIMEOUT;
- }
- }
-
- /* Check if the Receiver is enabled */
- if ((huart->Instance->CR1 & USART_CR1_RE) == USART_CR1_RE)
- {
- /* Wait until REACK flag is set */
- if (UART_WaitOnFlagUntilTimeout(huart, USART_ISR_REACK, RESET, tickstart, HAL_UART_TIMEOUT_VALUE) != HAL_OK)
- {
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error)
- interrupts for the interrupt process */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- huart->RxState = HAL_UART_STATE_READY;
-
- __HAL_UNLOCK(huart);
-
- /* Timeout occurred */
- return HAL_TIMEOUT;
- }
- }
-
- /* Initialize the UART State */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief This function handles UART Communication Timeout. It waits
- * until a flag is no longer in the specified status.
- * @param huart UART handle.
- * @param Flag Specifies the UART flag to check
- * @param Status The actual Flag status (SET or RESET)
- * @param Tickstart Tick start value
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status,
- uint32_t Tickstart, uint32_t Timeout)
-{
- /* Wait until flag is set */
- while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status)
- {
- /* Check for the Timeout */
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
- {
-
- return HAL_TIMEOUT;
- }
-
- if ((READ_BIT(huart->Instance->CR1, USART_CR1_RE) != 0U) && (Flag != UART_FLAG_TXE) && (Flag != UART_FLAG_TC))
- {
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE) == SET)
- {
- /* Clear Overrun Error flag*/
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
-
- /* Blocking error : transfer is aborted
- Set the UART state ready to be able to start again the process,
- Disable Rx Interrupts if ongoing */
- UART_EndRxTransfer(huart);
-
- huart->ErrorCode = HAL_UART_ERROR_ORE;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_ERROR;
- }
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RTOF) == SET)
- {
- /* Clear Receiver Timeout flag*/
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_RTOF);
-
- /* Blocking error : transfer is aborted
- Set the UART state ready to be able to start again the process,
- Disable Rx Interrupts if ongoing */
- UART_EndRxTransfer(huart);
-
- huart->ErrorCode = HAL_UART_ERROR_RTO;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
- return HAL_OK;
-}
-
-/**
- * @brief Start Receive operation in interrupt mode.
- * @note This function could be called by all HAL UART API providing reception in Interrupt mode.
- * @note When calling this function, parameters validity is considered as already checked,
- * i.e. Rx State, buffer address, ...
- * UART Handle is assumed as Locked.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- huart->pRxBuffPtr = pData;
- huart->RxXferSize = Size;
- huart->RxXferCount = Size;
- huart->RxISR = NULL;
-
- /* Computation of UART mask to apply to RDR register */
- UART_MASK_COMPUTATION(huart);
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
-
- /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Set the Rx ISR function pointer according to the data word length */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- huart->RxISR = UART_RxISR_16BIT;
- }
- else
- {
- huart->RxISR = UART_RxISR_8BIT;
- }
-
- /* Enable the UART Parity Error interrupt and Data Register Not Empty interrupt */
- if (huart->Init.Parity != UART_PARITY_NONE)
- {
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE);
- }
- else
- {
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RXNEIE);
- }
- return HAL_OK;
-}
-
-/**
- * @brief Start Receive operation in DMA mode.
- * @note This function could be called by all HAL UART API providing reception in DMA mode.
- * @note When calling this function, parameters validity is considered as already checked,
- * i.e. Rx State, buffer address, ...
- * UART Handle is assumed as Locked.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- huart->pRxBuffPtr = pData;
- huart->RxXferSize = Size;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
-
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA transfer complete callback */
- huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt;
-
- /* Set the UART DMA Half transfer complete callback */
- huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt;
-
- /* Set the DMA error callback */
- huart->hdmarx->XferErrorCallback = UART_DMAError;
-
- /* Set the DMA abort callback */
- huart->hdmarx->XferAbortCallback = NULL;
-
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(huart->hdmarx, (uint32_t)&huart->Instance->RDR, (uint32_t)huart->pRxBuffPtr, Size) != HAL_OK)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- /* Restore huart->RxState to ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_ERROR;
- }
- }
-
- /* Enable the UART Parity Error Interrupt */
- if (huart->Init.Parity != UART_PARITY_NONE)
- {
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- }
-
- /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Enable the DMA transfer for the receiver request by setting the DMAR bit
- in the UART CR3 register */
- ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- return HAL_OK;
-}
-
-
-/**
- * @brief End ongoing Tx transfer on UART peripheral (following error detection or Transmit completion).
- * @param huart UART handle.
- * @retval None
- */
-static void UART_EndTxTransfer(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE and TCIE interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
-
- /* At end of Tx process, restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-}
-
-
-/**
- * @brief End ongoing Rx transfer on UART peripheral (following error detection or Reception completion).
- * @param huart UART handle.
- * @retval None
- */
-static void UART_EndRxTransfer(UART_HandleTypeDef *huart)
-{
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* In case of reception waiting for IDLE event, disable also the IDLE IE interrupt source */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Reset RxIsr function pointer */
- huart->RxISR = NULL;
-}
-
-
-/**
- * @brief DMA UART transmit process complete callback.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- /* DMA Normal mode */
- if (hdma->Init.Mode != DMA_CIRCULAR)
- {
- huart->TxXferCount = 0U;
-
- /* Disable the DMA transfer for transmit request by resetting the DMAT bit
- in the UART CR3 register */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Enable the UART Transmit Complete Interrupt */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
- }
- /* DMA Circular mode */
- else
- {
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Tx complete callback*/
- huart->TxCpltCallback(huart);
-#else
- /*Call legacy weak Tx complete callback*/
- HAL_UART_TxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief DMA UART transmit process half complete callback.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Tx Half complete callback*/
- huart->TxHalfCpltCallback(huart);
-#else
- /*Call legacy weak Tx Half complete callback*/
- HAL_UART_TxHalfCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART receive process complete callback.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- /* DMA Normal mode */
- if (hdma->Init.Mode != DMA_CIRCULAR)
- {
- huart->RxXferCount = 0U;
-
- /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Disable the DMA transfer for the receiver request by resetting the DMAR bit
- in the UART CR3 register */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- /* If Reception till IDLE event has been selected, Disable IDLE Interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
- }
-
- /* Initialize type of RxEvent that correspond to RxEvent callback execution;
- In this case, Rx Event type is Transfer Complete */
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : use Rx Event callback */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- else
- {
- /* In other cases : use Rx Complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxCpltCallback(huart);
-#else
- /*Call legacy weak Rx complete callback*/
- HAL_UART_RxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief DMA UART receive process half complete callback.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- /* Initialize type of RxEvent that correspond to RxEvent callback execution;
- In this case, Rx Event type is Half Transfer */
- huart->RxEventType = HAL_UART_RXEVENT_HT;
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : use Rx Event callback */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize / 2U);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize / 2U);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- else
- {
- /* In other cases : use Rx Half Complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Half complete callback*/
- huart->RxHalfCpltCallback(huart);
-#else
- /*Call legacy weak Rx Half complete callback*/
- HAL_UART_RxHalfCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief DMA UART communication error callback.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMAError(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- const HAL_UART_StateTypeDef gstate = huart->gState;
- const HAL_UART_StateTypeDef rxstate = huart->RxState;
-
- /* Stop UART DMA Tx request if ongoing */
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT)) &&
- (gstate == HAL_UART_STATE_BUSY_TX))
- {
- huart->TxXferCount = 0U;
- UART_EndTxTransfer(huart);
- }
-
- /* Stop UART DMA Rx request if ongoing */
- if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) &&
- (rxstate == HAL_UART_STATE_BUSY_RX))
- {
- huart->RxXferCount = 0U;
- UART_EndRxTransfer(huart);
- }
-
- huart->ErrorCode |= HAL_UART_ERROR_DMA;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART communication abort callback, when initiated by HAL services on Error
- * (To be called at end of DMA Abort procedure following error occurrence).
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
- huart->RxXferCount = 0U;
- huart->TxXferCount = 0U;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART Tx communication abort callback, when initiated by user
- * (To be called at end of DMA Tx Abort procedure following user abort request).
- * @note When this callback is executed, User Abort complete call back is called only if no
- * Abort still ongoing for Rx DMA Handle.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- huart->hdmatx->XferAbortCallback = NULL;
-
- /* Check if an Abort process is still ongoing */
- if (huart->hdmarx != NULL)
- {
- if (huart->hdmarx->XferAbortCallback != NULL)
- {
- return;
- }
- }
-
- /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
- huart->TxXferCount = 0U;
- huart->RxXferCount = 0U;
-
- /* Reset errorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort complete callback */
- huart->AbortCpltCallback(huart);
-#else
- /* Call legacy weak Abort complete callback */
- HAL_UART_AbortCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-
-/**
- * @brief DMA UART Rx communication abort callback, when initiated by user
- * (To be called at end of DMA Rx Abort procedure following user abort request).
- * @note When this callback is executed, User Abort complete call back is called only if no
- * Abort still ongoing for Tx DMA Handle.
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- huart->hdmarx->XferAbortCallback = NULL;
-
- /* Check if an Abort process is still ongoing */
- if (huart->hdmatx != NULL)
- {
- if (huart->hdmatx->XferAbortCallback != NULL)
- {
- return;
- }
- }
-
- /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
- huart->TxXferCount = 0U;
- huart->RxXferCount = 0U;
-
- /* Reset errorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
- /* Discard the received data */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort complete callback */
- huart->AbortCpltCallback(huart);
-#else
- /* Call legacy weak Abort complete callback */
- HAL_UART_AbortCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-
-/**
- * @brief DMA UART Tx communication abort callback, when initiated by user by a call to
- * HAL_UART_AbortTransmit_IT API (Abort only Tx transfer)
- * (This callback is executed at end of DMA Tx Abort procedure following user abort request,
- * and leads to user Tx Abort Complete callback execution).
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent);
-
- huart->TxXferCount = 0U;
-
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Transmit Complete Callback */
- huart->AbortTransmitCpltCallback(huart);
-#else
- /* Call legacy weak Abort Transmit Complete Callback */
- HAL_UART_AbortTransmitCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART Rx communication abort callback, when initiated by user by a call to
- * HAL_UART_AbortReceive_IT API (Abort only Rx transfer)
- * (This callback is executed at end of DMA Rx Abort procedure following user abort request,
- * and leads to user Rx Abort Complete callback execution).
- * @param hdma DMA handle.
- * @retval None
- */
-static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- huart->RxXferCount = 0U;
-
- /* Clear the Error flags in the ICR register */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF);
-
- /* Discard the received data */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Receive Complete Callback */
- huart->AbortReceiveCpltCallback(huart);
-#else
- /* Call legacy weak Abort Receive Complete Callback */
- HAL_UART_AbortReceiveCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief TX interrupt handler for 7 or 8 bits data word length .
- * @note Function is called under interruption only, once
- * interruptions have been enabled by HAL_UART_Transmit_IT().
- * @param huart UART handle.
- * @retval None
- */
-static void UART_TxISR_8BIT(UART_HandleTypeDef *huart)
-{
- /* Check that a Tx process is ongoing */
- if (huart->gState == HAL_UART_STATE_BUSY_TX)
- {
- if (huart->TxXferCount == 0U)
- {
- /* Disable the UART Transmit Data Register Empty Interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
-
- /* Enable the UART Transmit Complete Interrupt */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
- }
- else
- {
- huart->Instance->TDR = (uint8_t)(*huart->pTxBuffPtr & (uint8_t)0xFF);
- huart->pTxBuffPtr++;
- huart->TxXferCount--;
- }
- }
-}
-
-/**
- * @brief TX interrupt handler for 9 bits data word length.
- * @note Function is called under interruption only, once
- * interruptions have been enabled by HAL_UART_Transmit_IT().
- * @param huart UART handle.
- * @retval None
- */
-static void UART_TxISR_16BIT(UART_HandleTypeDef *huart)
-{
- const uint16_t *tmp;
-
- /* Check that a Tx process is ongoing */
- if (huart->gState == HAL_UART_STATE_BUSY_TX)
- {
- if (huart->TxXferCount == 0U)
- {
- /* Disable the UART Transmit Data Register Empty Interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
-
- /* Enable the UART Transmit Complete Interrupt */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
- }
- else
- {
- tmp = (const uint16_t *) huart->pTxBuffPtr;
- huart->Instance->TDR = (((uint32_t)(*tmp)) & 0x01FFUL);
- huart->pTxBuffPtr += 2U;
- huart->TxXferCount--;
- }
- }
-}
-
-
-/**
- * @brief Wrap up transmission in non-blocking mode.
- * @param huart pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-static void UART_EndTransmit_IT(UART_HandleTypeDef *huart)
-{
- /* Disable the UART Transmit Complete Interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_TCIE);
-
- /* Tx process is ended, restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* Cleat TxISR function pointer */
- huart->TxISR = NULL;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Tx complete callback*/
- huart->TxCpltCallback(huart);
-#else
- /*Call legacy weak Tx complete callback*/
- HAL_UART_TxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief RX interrupt handler for 7 or 8 bits data word length .
- * @param huart UART handle.
- * @retval None
- */
-static void UART_RxISR_8BIT(UART_HandleTypeDef *huart)
-{
- uint16_t uhMask = huart->Mask;
- uint16_t uhdata;
-
- /* Check that a Rx process is ongoing */
- if (huart->RxState == HAL_UART_STATE_BUSY_RX)
- {
- uhdata = (uint16_t) READ_REG(huart->Instance->RDR);
- *huart->pRxBuffPtr = (uint8_t)(uhdata & (uint8_t)uhMask);
- huart->pRxBuffPtr++;
- huart->RxXferCount--;
-
- if (huart->RxXferCount == 0U)
- {
- /* Disable the UART Parity Error Interrupt and RXNE interrupts */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
-
- /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Rx process is completed, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- /* Clear RxISR function pointer */
- huart->RxISR = NULL;
-
- /* Initialize type of RxEvent to Transfer Complete */
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- /* Check that USART RTOEN bit is set */
- if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
- {
- /* Enable the UART Receiver Timeout Interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
- }
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- /* Set reception type to Standard */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Disable IDLE interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) == SET)
- {
- /* Clear IDLE Flag */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
- }
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
- else
- {
- /* Standard reception API called */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxCpltCallback(huart);
-#else
- /*Call legacy weak Rx complete callback*/
- HAL_UART_RxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- }
- else
- {
- /* Clear RXNE interrupt flag */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
- }
-}
-
-/**
- * @brief RX interrupt handler for 9 bits data word length .
- * @note Function is called under interruption only, once
- * interruptions have been enabled by HAL_UART_Receive_IT()
- * @param huart UART handle.
- * @retval None
- */
-static void UART_RxISR_16BIT(UART_HandleTypeDef *huart)
-{
- uint16_t *tmp;
- uint16_t uhMask = huart->Mask;
- uint16_t uhdata;
-
- /* Check that a Rx process is ongoing */
- if (huart->RxState == HAL_UART_STATE_BUSY_RX)
- {
- uhdata = (uint16_t) READ_REG(huart->Instance->RDR);
- tmp = (uint16_t *) huart->pRxBuffPtr ;
- *tmp = (uint16_t)(uhdata & uhMask);
- huart->pRxBuffPtr += 2U;
- huart->RxXferCount--;
-
- if (huart->RxXferCount == 0U)
- {
- /* Disable the UART Parity Error Interrupt and RXNE interrupt*/
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
-
- /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Rx process is completed, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- /* Clear RxISR function pointer */
- huart->RxISR = NULL;
-
- /* Initialize type of RxEvent to Transfer Complete */
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- /* Check that USART RTOEN bit is set */
- if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
- {
- /* Enable the UART Receiver Timeout Interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
- }
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- /* Set reception type to Standard */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Disable IDLE interrupt */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) == SET)
- {
- /* Clear IDLE Flag */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
- }
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
- else
- {
- /* Standard reception API called */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxCpltCallback(huart);
-#else
- /*Call legacy weak Rx complete callback*/
- HAL_UART_RxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- }
- else
- {
- /* Clear RXNE interrupt flag */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
- }
-}
-
-
-/**
- * @}
- */
-
-#endif /* HAL_UART_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
diff --git a/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart_ex.c b/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart_ex.c
deleted file mode 100644
index c63133c..0000000
--- a/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart_ex.c
+++ /dev/null
@@ -1,773 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32f3xx_hal_uart_ex.c
- * @author MCD Application Team
- * @brief Extended UART HAL module driver.
- * This file provides firmware functions to manage the following extended
- * functionalities of the Universal Asynchronous Receiver Transmitter Peripheral (UART).
- * + Initialization and de-initialization functions
- * + Peripheral Control functions
- *
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2016 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- @verbatim
- ==============================================================================
- ##### UART peripheral extended features #####
- ==============================================================================
-
- (#) Declare a UART_HandleTypeDef handle structure.
-
- (#) For the UART RS485 Driver Enable mode, initialize the UART registers
- by calling the HAL_RS485Ex_Init() API.
-
- @endverbatim
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f3xx_hal.h"
-
-/** @addtogroup STM32F3xx_HAL_Driver
- * @{
- */
-
-/** @defgroup UARTEx UARTEx
- * @brief UART Extended HAL module driver
- * @{
- */
-
-#ifdef HAL_UART_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-
-/* Private macros ------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup UARTEx_Private_Functions UARTEx Private Functions
- * @{
- */
-static void UARTEx_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-
-/** @defgroup UARTEx_Exported_Functions UARTEx Exported Functions
- * @{
- */
-
-/** @defgroup UARTEx_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Extended Initialization and Configuration Functions
- *
-@verbatim
-===============================================================================
- ##### Initialization and Configuration functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
- in asynchronous mode.
- (+) For the asynchronous mode the parameters below can be configured:
- (++) Baud Rate
- (++) Word Length
- (++) Stop Bit
- (++) Parity: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- (++) Hardware flow control
- (++) Receiver/transmitter modes
- (++) Over Sampling Method
- (++) One-Bit Sampling Method
- (+) For the asynchronous mode, the following advanced features can be configured as well:
- (++) TX and/or RX pin level inversion
- (++) data logical level inversion
- (++) RX and TX pins swap
- (++) RX overrun detection disabling
- (++) DMA disabling on RX error
- (++) MSB first on communication line
- (++) auto Baud rate detection
- [..]
- The HAL_RS485Ex_Init() API follows the UART RS485 mode configuration
- procedures (details for the procedures are available in reference manual).
-
-@endverbatim
-
- Depending on the frame length defined by the M1 and M0 bits (7-bit,
- 8-bit or 9-bit), the possible UART formats are listed in the
- following table.
-
- Table 1. UART frame format.
- +-----------------------------------------------------------------------+
- | M1 bit | M0 bit | PCE bit | UART frame |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 0 | 0 | | SB | 8 bit data | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 0 | 1 | | SB | 7 bit data | PB | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 1 | 0 | | SB | 9 bit data | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 0 | 1 | 1 | | SB | 8 bit data | PB | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 1 | 0 | 0 | | SB | 7 bit data | STB | |
- |---------|---------|-----------|---------------------------------------|
- | 1 | 0 | 1 | | SB | 6 bit data | PB | STB | |
- +-----------------------------------------------------------------------+
-
- * @{
- */
-
-/**
- * @brief Initialize the RS485 Driver enable feature according to the specified
- * parameters in the UART_InitTypeDef and creates the associated handle.
- * @param huart UART handle.
- * @param Polarity Select the driver enable polarity.
- * This parameter can be one of the following values:
- * @arg @ref UART_DE_POLARITY_HIGH DE signal is active high
- * @arg @ref UART_DE_POLARITY_LOW DE signal is active low
- * @param AssertionTime Driver Enable assertion time:
- * 5-bit value defining the time between the activation of the DE (Driver Enable)
- * signal and the beginning of the start bit. It is expressed in sample time
- * units (1/8 or 1/16 bit time, depending on the oversampling rate)
- * @param DeassertionTime Driver Enable deassertion time:
- * 5-bit value defining the time between the end of the last stop bit, in a
- * transmitted message, and the de-activation of the DE (Driver Enable) signal.
- * It is expressed in sample time units (1/8 or 1/16 bit time, depending on the
- * oversampling rate).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime,
- uint32_t DeassertionTime)
-{
- uint32_t temp;
-
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
- /* Check the Driver Enable UART instance */
- assert_param(IS_UART_DRIVER_ENABLE_INSTANCE(huart->Instance));
-
- /* Check the Driver Enable polarity */
- assert_param(IS_UART_DE_POLARITY(Polarity));
-
- /* Check the Driver Enable assertion time */
- assert_param(IS_UART_ASSERTIONTIME(AssertionTime));
-
- /* Check the Driver Enable deassertion time */
- assert_param(IS_UART_DEASSERTIONTIME(DeassertionTime));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK, CORTEX */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the Peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Perform advanced settings configuration */
- /* For some items, configuration requires to be done prior TE and RE bits are set */
- if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
- {
- UART_AdvFeatureConfig(huart);
- }
-
- /* Set the UART Communication parameters */
- if (UART_SetConfig(huart) == HAL_ERROR)
- {
- return HAL_ERROR;
- }
-
- /* Enable the Driver Enable mode by setting the DEM bit in the CR3 register */
- SET_BIT(huart->Instance->CR3, USART_CR3_DEM);
-
- /* Set the Driver Enable polarity */
- MODIFY_REG(huart->Instance->CR3, USART_CR3_DEP, Polarity);
-
- /* Set the Driver Enable assertion and deassertion times */
- temp = (AssertionTime << UART_CR1_DEAT_ADDRESS_LSB_POS);
- temp |= (DeassertionTime << UART_CR1_DEDT_ADDRESS_LSB_POS);
- MODIFY_REG(huart->Instance->CR1, (USART_CR1_DEDT | USART_CR1_DEAT), temp);
-
- /* Enable the Peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* TEACK and/or REACK to check before moving huart->gState and huart->RxState to Ready */
- return (UART_CheckIdleState(huart));
-}
-
-/**
- * @}
- */
-
-/** @defgroup UARTEx_Exported_Functions_Group2 IO operation functions
- * @brief Extended functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- This subsection provides a set of Wakeup and FIFO mode related callback functions.
-
- (#) Wakeup from Stop mode Callback:
- (+) HAL_UARTEx_WakeupCallback()
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief UART wakeup from Stop mode callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UARTEx_WakeupCallback can be implemented in the user file.
- */
-}
-
-
-/**
- * @}
- */
-
-/** @defgroup UARTEx_Exported_Functions_Group3 Peripheral Control functions
- * @brief Extended Peripheral Control functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
- [..] This section provides the following functions:
- (+) HAL_MultiProcessorEx_AddressLength_Set() API optionally sets the UART node address
- detection length to more than 4 bits for multiprocessor address mark wake up.
- (+) HAL_UARTEx_StopModeWakeUpSourceConfig() API defines the wake-up from stop mode
- trigger: address match, Start Bit detection or RXNE bit status.
- (+) HAL_UARTEx_EnableStopMode() API enables the UART to wake up the MCU from stop mode
- (+) HAL_UARTEx_DisableStopMode() API disables the above functionality
-
- [..] This subsection also provides a set of additional functions providing enhanced reception
- services to user. (For example, these functions allow application to handle use cases
- where number of data to be received is unknown).
-
- (#) Compared to standard reception services which only consider number of received
- data elements as reception completion criteria, these functions also consider additional events
- as triggers for updating reception status to caller :
- (+) Detection of inactivity period (RX line has not been active for a given period).
- (++) RX inactivity detected by IDLE event, i.e. RX line has been in idle state (normally high state)
- for 1 frame time, after last received byte.
- (++) RX inactivity detected by RTO, i.e. line has been in idle state
- for a programmable time, after last received byte.
- (+) Detection that a specific character has been received.
-
- (#) There are two mode of transfer:
- (+) Blocking mode: The reception is performed in polling mode, until either expected number of data is received,
- or till IDLE event occurs. Reception is handled only during function execution.
- When function exits, no data reception could occur. HAL status and number of actually received data elements,
- are returned by function after finishing transfer.
- (+) Non-Blocking mode: The reception is performed using Interrupts or DMA.
- These API's return the HAL status.
- The end of the data processing will be indicated through the
- dedicated UART IRQ when using Interrupt mode or the DMA IRQ when using DMA mode.
- The HAL_UARTEx_RxEventCallback() user callback will be executed during Receive process
- The HAL_UART_ErrorCallback()user callback will be executed when a reception error is detected.
-
- (#) Blocking mode API:
- (+) HAL_UARTEx_ReceiveToIdle()
-
- (#) Non-Blocking mode API with Interrupt:
- (+) HAL_UARTEx_ReceiveToIdle_IT()
-
- (#) Non-Blocking mode API with DMA:
- (+) HAL_UARTEx_ReceiveToIdle_DMA()
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief By default in multiprocessor mode, when the wake up method is set
- * to address mark, the UART handles only 4-bit long addresses detection;
- * this API allows to enable longer addresses detection (6-, 7- or 8-bit
- * long).
- * @note Addresses detection lengths are: 6-bit address detection in 7-bit data mode,
- * 7-bit address detection in 8-bit data mode, 8-bit address detection in 9-bit data mode.
- * @param huart UART handle.
- * @param AddressLength This parameter can be one of the following values:
- * @arg @ref UART_ADDRESS_DETECT_4B 4-bit long address
- * @arg @ref UART_ADDRESS_DETECT_7B 6-, 7- or 8-bit long address
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the address length parameter */
- assert_param(IS_UART_ADDRESSLENGTH_DETECT(AddressLength));
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the Peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Set the address length */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_ADDM7, AddressLength);
-
- /* Enable the Peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* TEACK and/or REACK to check before moving huart->gState to Ready */
- return (UART_CheckIdleState(huart));
-}
-
-/**
- * @brief Set Wakeup from Stop mode interrupt flag selection.
- * @note It is the application responsibility to enable the interrupt used as
- * usart_wkup interrupt source before entering low-power mode.
- * @param huart UART handle.
- * @param WakeUpSelection Address match, Start Bit detection or RXNE/RXFNE bit status.
- * This parameter can be one of the following values:
- * @arg @ref UART_WAKEUP_ON_ADDRESS
- * @arg @ref UART_WAKEUP_ON_STARTBIT
- * @arg @ref UART_WAKEUP_ON_READDATA_NONEMPTY
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection)
-{
- HAL_StatusTypeDef status = HAL_OK;
- uint32_t tickstart;
-
- /* check the wake-up from stop mode UART instance */
- assert_param(IS_UART_WAKEUP_FROMSTOP_INSTANCE(huart->Instance));
- /* check the wake-up selection parameter */
- assert_param(IS_UART_WAKEUP_SELECTION(WakeUpSelection.WakeUpEvent));
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the Peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Set the wake-up selection scheme */
- MODIFY_REG(huart->Instance->CR3, USART_CR3_WUS, WakeUpSelection.WakeUpEvent);
-
- if (WakeUpSelection.WakeUpEvent == UART_WAKEUP_ON_ADDRESS)
- {
- UARTEx_Wakeup_AddressConfig(huart, WakeUpSelection);
- }
-
- /* Enable the Peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- /* Wait until REACK flag is set */
- if (UART_WaitOnFlagUntilTimeout(huart, USART_ISR_REACK, RESET, tickstart, HAL_UART_TIMEOUT_VALUE) != HAL_OK)
- {
- status = HAL_TIMEOUT;
- }
- else
- {
- /* Initialize the UART State */
- huart->gState = HAL_UART_STATE_READY;
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return status;
-}
-
-/**
- * @brief Enable UART Stop Mode.
- * @note The UART is able to wake up the MCU from Stop 1 mode as long as UART clock is HSI or LSE.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart)
-{
- /* Process Locked */
- __HAL_LOCK(huart);
-
- /* Set UESM bit */
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_UESM);
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Disable UART Stop Mode.
- * @param huart UART handle.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart)
-{
- /* Process Locked */
- __HAL_LOCK(huart);
-
- /* Clear UESM bit */
- ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_UESM);
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Receive an amount of data in blocking mode till either the expected number of data
- * is received or an IDLE event occurs.
- * @note HAL_OK is returned if reception is completed (expected number of data has been received)
- * or if reception is stopped after IDLE event (less than the expected number of data has been received)
- * In this case, RxLen output parameter indicates number of data available in reception buffer.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of uint16_t. In this case, Size must indicate the number
- * of uint16_t available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (uint8_t or uint16_t data elements).
- * @param Size Amount of data elements (uint8_t or uint16_t) to be received.
- * @param RxLen Number of data elements finally received
- * (could be lower than Size, in case reception ends on IDLE event)
- * @param Timeout Timeout duration expressed in ms (covers the whole reception sequence).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint16_t *RxLen,
- uint32_t Timeout)
-{
- uint8_t *pdata8bits;
- uint16_t *pdata16bits;
- uint16_t uhMask;
- uint32_t tickstart;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
- huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- huart->RxXferSize = Size;
- huart->RxXferCount = Size;
-
- /* Computation of UART mask to apply to RDR register */
- UART_MASK_COMPUTATION(huart);
- uhMask = huart->Mask;
-
- /* In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (uint16_t *) pData;
- }
- else
- {
- pdata8bits = pData;
- pdata16bits = NULL;
- }
-
- /* Initialize output number of received elements */
- *RxLen = 0U;
-
- /* as long as data have to be received */
- while (huart->RxXferCount > 0U)
- {
- /* Check if IDLE flag is set */
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE))
- {
- /* Clear IDLE flag in ISR */
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
-
- /* If Set, but no data ever received, clear flag without exiting loop */
- /* If Set, and data has already been received, this means Idle Event is valid : End reception */
- if (*RxLen > 0U)
- {
- huart->RxEventType = HAL_UART_RXEVENT_IDLE;
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- }
-
- /* Check if RXNE flag is set */
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE))
- {
- if (pdata8bits == NULL)
- {
- *pdata16bits = (uint16_t)(huart->Instance->RDR & uhMask);
- pdata16bits++;
- }
- else
- {
- *pdata8bits = (uint8_t)(huart->Instance->RDR & (uint8_t)uhMask);
- pdata8bits++;
- }
- /* Increment number of received elements */
- *RxLen += 1U;
- huart->RxXferCount--;
- }
-
- /* Check for the Timeout */
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Set number of received elements in output parameter : RxLen */
- *RxLen = huart->RxXferSize - huart->RxXferCount;
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in interrupt mode till either the expected number of data
- * is received or an IDLE event occurs.
- * @note Reception is initiated by this function call. Further progress of reception is achieved thanks
- * to UART interrupts raised by RXNE and IDLE events. Callback is called at end of reception indicating
- * number of received data elements.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of uint16_t. In this case, Size must indicate the number
- * of uint16_t available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (uint8_t or uint16_t data elements).
- * @param Size Amount of data elements (uint8_t or uint16_t) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Set Reception type to reception till IDLE Event*/
- huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- (void)UART_Start_Receive_IT(huart, pData, Size);
-
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
- else
- {
- /* In case of errors already pending when reception is started,
- Interrupts may have already been raised and lead to reception abortion.
- (Overrun error for instance).
- In such case Reception Type has been reset to HAL_UART_RECEPTION_STANDARD. */
- status = HAL_ERROR;
- }
-
- return status;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in DMA mode till either the expected number
- * of data is received or an IDLE event occurs.
- * @note Reception is initiated by this function call. Further progress of reception is achieved thanks
- * to DMA services, transferring automatically received data elements in user reception buffer and
- * calling registered callbacks at half/end of reception. UART IDLE events are also used to consider
- * reception phase as ended. In all cases, callback execution will indicate number of received data elements.
- * @note When the UART parity is enabled (PCE = 1), the received data contain
- * the parity bit (MSB position).
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of uint16_t. In this case, Size must indicate the number
- * of uint16_t available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (uint8_t or uint16_t data elements).
- * @param Size Amount of data elements (uint8_t or uint16_t) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- HAL_StatusTypeDef status;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Set Reception type to reception till IDLE Event*/
- huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
- huart->RxEventType = HAL_UART_RXEVENT_TC;
-
- status = UART_Start_Receive_DMA(huart, pData, Size);
-
- /* Check Rx process has been successfully started */
- if (status == HAL_OK)
- {
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
- ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
- else
- {
- /* In case of errors already pending when reception is started,
- Interrupts may have already been raised and lead to reception abortion.
- (Overrun error for instance).
- In such case Reception Type has been reset to HAL_UART_RECEPTION_STANDARD. */
- status = HAL_ERROR;
- }
- }
-
- return status;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Provide Rx Event type that has lead to RxEvent callback execution.
- * @note When HAL_UARTEx_ReceiveToIdle_IT() or HAL_UARTEx_ReceiveToIdle_DMA() API are called, progress
- * of reception process is provided to application through calls of Rx Event callback (either default one
- * HAL_UARTEx_RxEventCallback() or user registered one). As several types of events could occur (IDLE event,
- * Half Transfer, or Transfer Complete), this function allows to retrieve the Rx Event type that has lead
- * to Rx Event callback execution.
- * @note This function is expected to be called within the user implementation of Rx Event Callback,
- * in order to provide the accurate value :
- * In Interrupt Mode :
- * - HAL_UART_RXEVENT_TC : when Reception has been completed (expected nb of data has been received)
- * - HAL_UART_RXEVENT_IDLE : when Idle event occurred prior reception has been completed (nb of
- * received data is lower than expected one)
- * In DMA Mode :
- * - HAL_UART_RXEVENT_TC : when Reception has been completed (expected nb of data has been received)
- * - HAL_UART_RXEVENT_HT : when half of expected nb of data has been received
- * - HAL_UART_RXEVENT_IDLE : when Idle event occurred prior reception has been completed (nb of
- * received data is lower than expected one).
- * In DMA mode, RxEvent callback could be called several times;
- * When DMA is configured in Normal Mode, HT event does not stop Reception process;
- * When DMA is configured in Circular Mode, HT, TC or IDLE events don't stop Reception process;
- * @param huart UART handle.
- * @retval Rx Event Type (return vale will be a value of @ref UART_RxEvent_Type_Values)
- */
-HAL_UART_RxEventTypeTypeDef HAL_UARTEx_GetRxEventType(const UART_HandleTypeDef *huart)
-{
- /* Return Rx Event type value, as stored in UART handle */
- return (huart->RxEventType);
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @addtogroup UARTEx_Private_Functions
- * @{
- */
-
-/**
- * @brief Initialize the UART wake-up from stop mode parameters when triggered by address detection.
- * @param huart UART handle.
- * @param WakeUpSelection UART wake up from stop mode parameters.
- * @retval None
- */
-static void UARTEx_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection)
-{
- assert_param(IS_UART_ADDRESSLENGTH_DETECT(WakeUpSelection.AddressLength));
-
- /* Set the USART address length */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_ADDM7, WakeUpSelection.AddressLength);
-
- /* Set the USART address node */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_ADD, ((uint32_t)WakeUpSelection.Address << UART_CR2_ADDRESS_LSB_POS));
-}
-
-/**
- * @}
- */
-
-#endif /* HAL_UART_MODULE_ENABLED */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
diff --git a/Nucleo-F303RE.ioc b/Nucleo-F303RE.ioc
index ef85f27..9208731 100644
--- a/Nucleo-F303RE.ioc
+++ b/Nucleo-F303RE.ioc
@@ -11,6 +11,27 @@ ADC1.master=1
CAD.formats=
CAD.pinconfig=
CAD.provider=
+Dma.Request0=USART2_RX
+Dma.Request1=USART2_TX
+Dma.RequestsNb=2
+Dma.USART2_RX.0.Direction=DMA_PERIPH_TO_MEMORY
+Dma.USART2_RX.0.Instance=DMA1_Channel6
+Dma.USART2_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.USART2_RX.0.MemInc=DMA_MINC_ENABLE
+Dma.USART2_RX.0.Mode=DMA_NORMAL
+Dma.USART2_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.USART2_RX.0.PeriphInc=DMA_PINC_DISABLE
+Dma.USART2_RX.0.Priority=DMA_PRIORITY_LOW
+Dma.USART2_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
+Dma.USART2_TX.1.Direction=DMA_MEMORY_TO_PERIPH
+Dma.USART2_TX.1.Instance=DMA1_Channel7
+Dma.USART2_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.USART2_TX.1.MemInc=DMA_MINC_ENABLE
+Dma.USART2_TX.1.Mode=DMA_NORMAL
+Dma.USART2_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.USART2_TX.1.PeriphInc=DMA_PINC_DISABLE
+Dma.USART2_TX.1.Priority=DMA_PRIORITY_LOW
+Dma.USART2_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
File.Version=6
GPIO.groupedBy=Expand Peripherals
KeepUserPlacement=false
@@ -19,13 +40,14 @@ Mcu.Family=STM32F3
Mcu.IP0=ADC1
Mcu.IP1=CRC
Mcu.IP2=DAC1
-Mcu.IP3=NVIC
-Mcu.IP4=RCC
-Mcu.IP5=SYS
-Mcu.IP6=UART5
-Mcu.IP7=USART2
-Mcu.IP8=USART3
-Mcu.IPNb=9
+Mcu.IP3=DMA
+Mcu.IP4=NVIC
+Mcu.IP5=RCC
+Mcu.IP6=SYS
+Mcu.IP7=UART5
+Mcu.IP8=USART2
+Mcu.IP9=USART3
+Mcu.IPNb=10
Mcu.Name=STM32F303R(D-E)Tx
Mcu.Package=LQFP64
Mcu.Pin0=PC13
@@ -79,6 +101,8 @@ Mcu.UserName=STM32F303RETx
MxCube.Version=6.14.1
MxDb.Version=DB.6.0.141
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
+NVIC.DMA1_Channel6_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
+NVIC.DMA1_Channel7_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:false
@@ -122,7 +146,7 @@ PA2.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_Mode
PA2.GPIO_Label=USART2_TX
PA2.GPIO_Mode=GPIO_MODE_AF_PP
PA2.GPIO_PuPd=GPIO_NOPULL
-PA2.GPIO_Speed=GPIO_SPEED_FREQ_LOW
+PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA2.Locked=true
PA2.Mode=Asynchronous
PA2.Signal=USART2_TX
@@ -271,7 +295,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=true
-ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_ADC1_Init-ADC1-false-LL-true,4-MX_CRC_Init-CRC-false-LL-true,5-MX_DAC1_Init-DAC1-false-LL-true,6-MX_UART5_Init-UART5-false-LL-true,7-MX_USART2_UART_Init-USART2-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-LL-true,5-MX_CRC_Init-CRC-false-LL-true,6-MX_DAC1_Init-DAC1-false-LL-true,7-MX_UART5_Init-UART5-false-LL-true,8-MX_USART2_UART_Init-USART2-false-LL-true,9-MX_USART3_UART_Init-USART3-false-LL-true
RCC.ADC12outputFreq_Value=40000000
RCC.ADC34outputFreq_Value=40000000
RCC.AHBFreq_Value=40000000
@@ -331,7 +355,9 @@ SH.ADCx_IN9.0=ADC1_IN9,IN9-Single-Ended
SH.ADCx_IN9.ConfNb=1
SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1
SH.COMP_DAC11_group.ConfNb=1
-USART2.IPParameters=VirtualMode-Asynchronous,VirtualMode-Hardware Flow Control (RS485)
+USART2.BaudRate=5000000
+USART2.IPParameters=VirtualMode-Asynchronous,VirtualMode-Hardware Flow Control (RS485),BaudRate,OverSampling
+USART2.OverSampling=UART_OVERSAMPLING_8
USART2.VirtualMode-Asynchronous=VM_ASYNC
USART2.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC
USART3.BaudRate=115200