diff --git a/.mxproject b/.mxproject index e61285e..b4e7714 100644 --- a/.mxproject +++ b/.mxproject @@ -1,27 +1,31 @@ [PreviousLibFiles] -LibFiles=Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_utils.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f103xb.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.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\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usart.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_utils.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usart.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_system.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_bus.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_utils.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usart.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f103xb.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.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; [PreviousUsedKeilFiles] -SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\tim.c;..\Core\Src\stm32f1xx_it.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_tim.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_utils.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_tim.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_utils.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;;; +SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\dma.c;..\Core\Src\tim.c;..\Core\Src\usart.c;..\Core\Src\stm32f1xx_it.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_tim.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_utils.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usart.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_tim.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_utils.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usart.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;;; HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Core\Inc; CDefines=USE_FULL_LL_DRIVER;HSE_VALUE:8000000;HSE_STARTUP_TIMEOUT:100;LSE_STARTUP_TIMEOUT:5000;LSE_VALUE:32768;HSI_VALUE:8000000;LSI_VALUE:40000;VDD_VALUE:3300;PREFETCH_ENABLE:1;STM32F103xB;USE_FULL_LL_DRIVER;HSE_VALUE:8000000;HSE_STARTUP_TIMEOUT:100;LSE_STARTUP_TIMEOUT:5000;LSE_VALUE:32768;HSI_VALUE:8000000;LSI_VALUE:40000;VDD_VALUE:3300;PREFETCH_ENABLE:1; [PreviousGenFiles] AdvancedFolderStructure=true -HeaderFileListSize=5 +HeaderFileListSize=7 HeaderFiles#0=..\Core\Inc\gpio.h -HeaderFiles#1=..\Core\Inc\tim.h -HeaderFiles#2=..\Core\Inc\stm32f1xx_it.h -HeaderFiles#3=..\Core\Inc\stm32_assert.h -HeaderFiles#4=..\Core\Inc\main.h +HeaderFiles#1=..\Core\Inc\dma.h +HeaderFiles#2=..\Core\Inc\tim.h +HeaderFiles#3=..\Core\Inc\usart.h +HeaderFiles#4=..\Core\Inc\stm32f1xx_it.h +HeaderFiles#5=..\Core\Inc\stm32_assert.h +HeaderFiles#6=..\Core\Inc\main.h HeaderFolderListSize=1 HeaderPath#0=..\Core\Inc HeaderFiles=; -SourceFileListSize=4 +SourceFileListSize=6 SourceFiles#0=..\Core\Src\gpio.c -SourceFiles#1=..\Core\Src\tim.c -SourceFiles#2=..\Core\Src\stm32f1xx_it.c -SourceFiles#3=..\Core\Src\main.c +SourceFiles#1=..\Core\Src\dma.c +SourceFiles#2=..\Core\Src\tim.c +SourceFiles#3=..\Core\Src\usart.c +SourceFiles#4=..\Core\Src\stm32f1xx_it.c +SourceFiles#5=..\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..f3b1a09 --- /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) 2024 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/main.h b/Core/Inc/main.h index c0e874a..c4eaede 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -28,6 +28,7 @@ extern "C" { /* Includes ------------------------------------------------------------------*/ +#include "stm32f1xx_ll_dma.h" #include "stm32f1xx_ll_rcc.h" #include "stm32f1xx_ll_bus.h" #include "stm32f1xx_ll_system.h" @@ -35,8 +36,8 @@ extern "C" { #include "stm32f1xx_ll_cortex.h" #include "stm32f1xx_ll_utils.h" #include "stm32f1xx_ll_pwr.h" -#include "stm32f1xx_ll_dma.h" #include "stm32f1xx_ll_tim.h" +#include "stm32f1xx_ll_usart.h" #include "stm32f1xx_ll_gpio.h" #if defined(USE_FULL_ASSERT) diff --git a/Core/Inc/stm32f1xx_it.h b/Core/Inc/stm32f1xx_it.h index 4e9f758..da8c5a7 100644 --- a/Core/Inc/stm32f1xx_it.h +++ b/Core/Inc/stm32f1xx_it.h @@ -55,7 +55,10 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); +void DMA1_Channel4_IRQHandler(void); +void DMA1_Channel5_IRQHandler(void); void TIM2_IRQHandler(void); +void USART1_IRQHandler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/Core/Inc/usart.h b/Core/Inc/usart.h new file mode 100644 index 0000000..3fc152e --- /dev/null +++ b/Core/Inc/usart.h @@ -0,0 +1,50 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file usart.h + * @brief This file contains all the function prototypes for + * the usart.c file + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 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 __USART_H__ +#define __USART_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* USER CODE BEGIN Private defines */ + +/* USER CODE END Private defines */ + +void MX_USART1_UART_Init(void); + +/* USER CODE BEGIN Prototypes */ + +/* USER CODE END Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USART_H__ */ + diff --git a/Core/Src/dma.c b/Core/Src/dma.c new file mode 100644 index 0000000..fc35945 --- /dev/null +++ b/Core/Src/dma.c @@ -0,0 +1,59 @@ +/* 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) 2024 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) +{ + + /* Init with LL driver */ + /* DMA controller clock enable */ + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); + + /* DMA interrupt init */ + /* DMA1_Channel4_IRQn interrupt configuration */ + NVIC_SetPriority(DMA1_Channel4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); + NVIC_EnableIRQ(DMA1_Channel4_IRQn); + /* DMA1_Channel5_IRQn interrupt configuration */ + NVIC_SetPriority(DMA1_Channel5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); + NVIC_EnableIRQ(DMA1_Channel5_IRQn); + +} + +/* USER CODE BEGIN 2 */ + +/* USER CODE END 2 */ + diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 0760ad6..164a159 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -76,8 +76,7 @@ void MX_GPIO_Init(void) /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_2|LL_GPIO_PIN_3|LL_GPIO_PIN_4 |LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|LL_GPIO_PIN_8 - |LL_GPIO_PIN_9|LL_GPIO_PIN_10|LL_GPIO_PIN_11|LL_GPIO_PIN_12 - |LL_GPIO_PIN_15; + |LL_GPIO_PIN_11|LL_GPIO_PIN_12|LL_GPIO_PIN_15; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); diff --git a/Core/Src/main.c b/Core/Src/main.c index e0e66dc..781c45d 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -18,7 +18,9 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" +#include "dma.h" #include "tim.h" +#include "usart.h" #include "gpio.h" /* Private includes ----------------------------------------------------------*/ @@ -95,7 +97,9 @@ int main(void) /* Initialize all configured peripherals */ MX_GPIO_Init(); + MX_DMA_Init(); MX_TIM2_Init(); + MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ my_mem_init(SRAMIN); // Initialize internal memory pool 1 board_init(); diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c index 82fed9b..c46b6ba 100644 --- a/Core/Src/stm32f1xx_it.c +++ b/Core/Src/stm32f1xx_it.c @@ -67,8 +67,8 @@ /* Cortex-M3 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** - * @brief This function handles Non maskable interrupt. - */ + * @brief This function handles Non maskable interrupt. + */ void NMI_Handler(void) { /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ @@ -82,8 +82,8 @@ void NMI_Handler(void) } /** - * @brief This function handles Hard fault interrupt. - */ + * @brief This function handles Hard fault interrupt. + */ void HardFault_Handler(void) { /* USER CODE BEGIN HardFault_IRQn 0 */ @@ -97,8 +97,8 @@ void HardFault_Handler(void) } /** - * @brief This function handles Memory management fault. - */ + * @brief This function handles Memory management fault. + */ void MemManage_Handler(void) { /* USER CODE BEGIN MemoryManagement_IRQn 0 */ @@ -112,8 +112,8 @@ void MemManage_Handler(void) } /** - * @brief This function handles Prefetch fault, memory access fault. - */ + * @brief This function handles Prefetch fault, memory access fault. + */ void BusFault_Handler(void) { /* USER CODE BEGIN BusFault_IRQn 0 */ @@ -127,8 +127,8 @@ void BusFault_Handler(void) } /** - * @brief This function handles Undefined instruction or illegal state. - */ + * @brief This function handles Undefined instruction or illegal state. + */ void UsageFault_Handler(void) { /* USER CODE BEGIN UsageFault_IRQn 0 */ @@ -142,8 +142,8 @@ void UsageFault_Handler(void) } /** - * @brief This function handles System service call via SWI instruction. - */ + * @brief This function handles System service call via SWI instruction. + */ void SVC_Handler(void) { /* USER CODE BEGIN SVCall_IRQn 0 */ @@ -155,8 +155,8 @@ void SVC_Handler(void) } /** - * @brief This function handles Debug monitor. - */ + * @brief This function handles Debug monitor. + */ void DebugMon_Handler(void) { /* USER CODE BEGIN DebugMonitor_IRQn 0 */ @@ -168,8 +168,8 @@ void DebugMon_Handler(void) } /** - * @brief This function handles Pendable request for system service. - */ + * @brief This function handles Pendable request for system service. + */ void PendSV_Handler(void) { /* USER CODE BEGIN PendSV_IRQn 0 */ @@ -181,8 +181,8 @@ void PendSV_Handler(void) } /** - * @brief This function handles System tick timer. - */ + * @brief This function handles System tick timer. + */ void SysTick_Handler(void) { /* USER CODE BEGIN SysTick_IRQn 0 */ @@ -202,8 +202,36 @@ void SysTick_Handler(void) /******************************************************************************/ /** - * @brief This function handles TIM2 global interrupt. - */ + * @brief This function handles DMA1 channel4 global interrupt. + */ +void DMA1_Channel4_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Channel4_IRQn 0 */ + + /* USER CODE END DMA1_Channel4_IRQn 0 */ + + /* USER CODE BEGIN DMA1_Channel4_IRQn 1 */ + uart_dma_reception_callback(uart); + /* USER CODE END DMA1_Channel4_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 channel5 global interrupt. + */ +void DMA1_Channel5_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */ + + /* USER CODE END DMA1_Channel5_IRQn 0 */ + + /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */ + uart_dma_reception_callback(uart); + /* USER CODE END DMA1_Channel5_IRQn 1 */ +} + +/** + * @brief This function handles TIM2 global interrupt. + */ void TIM2_IRQHandler(void) { /* USER CODE BEGIN TIM2_IRQn 0 */ @@ -219,6 +247,19 @@ void TIM2_IRQHandler(void) /* USER CODE END TIM2_IRQn 1 */ } +/** + * @brief This function handles USART1 global interrupt. + */ +void USART1_IRQHandler(void) +{ + /* USER CODE BEGIN USART1_IRQn 0 */ + + /* USER CODE END USART1_IRQn 0 */ + /* USER CODE BEGIN USART1_IRQn 1 */ + uart_reception_callback(uart); + /* USER CODE END USART1_IRQn 1 */ +} + /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ diff --git a/Core/Src/usart.c b/Core/Src/usart.c new file mode 100644 index 0000000..e15ef4a --- /dev/null +++ b/Core/Src/usart.c @@ -0,0 +1,115 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file usart.c + * @brief This file provides code for the configuration + * of the USART instances. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 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 "usart.h" + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USART1 init function */ + +void MX_USART1_UART_Init(void) +{ + + /* USER CODE BEGIN USART1_Init 0 */ + + /* USER CODE END USART1_Init 0 */ + + LL_USART_InitTypeDef USART_InitStruct = {0}; + + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* Peripheral clock enable */ + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); + + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); + /**USART1 GPIO Configuration + PA9 ------> USART1_TX + PA10 ------> USART1_RX + */ + GPIO_InitStruct.Pin = LL_GPIO_PIN_9; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = LL_GPIO_PIN_10; + GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USART1 DMA Init */ + + /* USART1_RX Init */ + LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_5, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); + + LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_5, LL_DMA_PRIORITY_LOW); + + LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_5, LL_DMA_MODE_NORMAL); + + LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_5, LL_DMA_PERIPH_NOINCREMENT); + + LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_5, LL_DMA_MEMORY_INCREMENT); + + LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_5, LL_DMA_PDATAALIGN_BYTE); + + LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_5, LL_DMA_MDATAALIGN_BYTE); + + /* USART1_TX Init */ + LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_4, LL_DMA_DIRECTION_MEMORY_TO_PERIPH); + + LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_4, LL_DMA_PRIORITY_LOW); + + LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_4, LL_DMA_MODE_NORMAL); + + LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_4, LL_DMA_PERIPH_NOINCREMENT); + + LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_4, LL_DMA_MEMORY_INCREMENT); + + LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_4, LL_DMA_PDATAALIGN_BYTE); + + LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_4, LL_DMA_MDATAALIGN_BYTE); + + /* USART1 interrupt Init */ + NVIC_SetPriority(USART1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); + NVIC_EnableIRQ(USART1_IRQn); + + /* USER CODE BEGIN USART1_Init 1 */ + + /* USER CODE END USART1_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(USART1, &USART_InitStruct); + LL_USART_ConfigAsyncMode(USART1); + LL_USART_Enable(USART1); + /* USER CODE BEGIN USART1_Init 2 */ + + /* USER CODE END USART1_Init 2 */ + +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ diff --git a/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h b/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h new file mode 100644 index 0000000..ffe4192 --- /dev/null +++ b/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usart.h @@ -0,0 +1,2569 @@ +/** + ****************************************************************************** + * @file stm32f1xx_ll_usart.h + * @author MCD Application Team + * @brief Header file of USART LL 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 __STM32F1xx_LL_USART_H +#define __STM32F1xx_LL_USART_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f1xx.h" + +/** @addtogroup STM32F1xx_LL_Driver + * @{ + */ + +#if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5) + +/** @defgroup USART_LL USART + * @{ + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/* Private constants ---------------------------------------------------------*/ +/** @defgroup USART_LL_Private_Constants USART Private Constants + * @{ + */ + +/* Defines used for the bit position in the register and perform offsets*/ +#define USART_POSITION_GTPR_GT USART_GTPR_GT_Pos +/** + * @} + */ + +/* Private macros ------------------------------------------------------------*/ +#if defined(USE_FULL_LL_DRIVER) +/** @defgroup USART_LL_Private_Macros USART Private Macros + * @{ + */ +/** + * @} + */ +#endif /*USE_FULL_LL_DRIVER*/ + +/* Exported types ------------------------------------------------------------*/ +#if defined(USE_FULL_LL_DRIVER) +/** @defgroup USART_LL_ES_INIT USART Exported Init structures + * @{ + */ + +/** + * @brief LL USART Init Structure definition + */ +typedef struct +{ + uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/ + + uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. + This parameter can be a value of @ref USART_LL_EC_DATAWIDTH. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/ + + uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. + This parameter can be a value of @ref USART_LL_EC_STOPBITS. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/ + + uint32_t Parity; /*!< Specifies the parity mode. + This parameter can be a value of @ref USART_LL_EC_PARITY. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/ + + uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. + This parameter can be a value of @ref USART_LL_EC_DIRECTION. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/ + + uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. + This parameter can be a value of @ref USART_LL_EC_HWCONTROL. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/ + + uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8. + This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING. + + This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/ + +} LL_USART_InitTypeDef; + +/** + * @brief LL USART Clock Init Structure definition + */ +typedef struct +{ + uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled. + This parameter can be a value of @ref USART_LL_EC_CLOCK. + + USART HW configuration can be modified afterwards using unitary functions + @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput(). + For more details, refer to description of this function. */ + + uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock. + This parameter can be a value of @ref USART_LL_EC_POLARITY. + + USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity(). + For more details, refer to description of this function. */ + + uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made. + This parameter can be a value of @ref USART_LL_EC_PHASE. + + USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase(). + For more details, refer to description of this function. */ + + uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted + data bit (MSB) has to be output on the SCLK pin in synchronous mode. + This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE. + + USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput(). + For more details, refer to description of this function. */ + +} LL_USART_ClockInitTypeDef; + +/** + * @} + */ +#endif /* USE_FULL_LL_DRIVER */ + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup USART_LL_Exported_Constants USART Exported Constants + * @{ + */ + +/** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines + * @brief Flags defines which can be used with LL_USART_ReadReg function + * @{ + */ +#define LL_USART_SR_PE USART_SR_PE /*!< Parity error flag */ +#define LL_USART_SR_FE USART_SR_FE /*!< Framing error flag */ +#define LL_USART_SR_NE USART_SR_NE /*!< Noise detected flag */ +#define LL_USART_SR_ORE USART_SR_ORE /*!< Overrun error flag */ +#define LL_USART_SR_IDLE USART_SR_IDLE /*!< Idle line detected flag */ +#define LL_USART_SR_RXNE USART_SR_RXNE /*!< Read data register not empty flag */ +#define LL_USART_SR_TC USART_SR_TC /*!< Transmission complete flag */ +#define LL_USART_SR_TXE USART_SR_TXE /*!< Transmit data register empty flag */ +#define LL_USART_SR_LBD USART_SR_LBD /*!< LIN break detection flag */ +#define LL_USART_SR_CTS USART_SR_CTS /*!< CTS flag */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_IT IT Defines + * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions + * @{ + */ +#define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ +#define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */ +#define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ +#define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */ +#define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ +#define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */ +#define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ +#define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_DIRECTION Communication Direction + * @{ + */ +#define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ +#define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ +#define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ +#define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_PARITY Parity Control + * @{ + */ +#define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ +#define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ +#define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_WAKEUP Wakeup + * @{ + */ +#define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */ +#define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_DATAWIDTH Datawidth + * @{ + */ +#define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ +#define LL_USART_DATAWIDTH_9B USART_CR1_M /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_OVERSAMPLING Oversampling + * @{ + */ +#define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ +#if defined(USART_CR1_OVER8) +#define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ +#endif /* USART_OverSampling_Feature */ +/** + * @} + */ + +#if defined(USE_FULL_LL_DRIVER) +/** @defgroup USART_LL_EC_CLOCK Clock Signal + * @{ + */ + +#define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */ +#define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */ +/** + * @} + */ +#endif /*USE_FULL_LL_DRIVER*/ + +/** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse + * @{ + */ +#define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */ +#define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_PHASE Clock Phase + * @{ + */ +#define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */ +#define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_POLARITY Clock Polarity + * @{ + */ +#define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/ +#define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_STOPBITS Stop Bits + * @{ + */ +#define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */ +#define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ +#define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */ +#define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_HWCONTROL Hardware Control + * @{ + */ +#define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ +#define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ +#define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ +#define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_IRDA_POWER IrDA Power + * @{ + */ +#define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */ +#define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */ +/** + * @} + */ + +/** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length + * @{ + */ +#define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */ +#define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */ +/** + * @} + */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup USART_LL_Exported_Macros USART Exported Macros + * @{ + */ + +/** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros + * @{ + */ + +/** + * @brief Write a value in USART register + * @param __INSTANCE__ USART Instance + * @param __REG__ Register to be written + * @param __VALUE__ Value to be written in the register + * @retval None + */ +#define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) + +/** + * @brief Read a value in USART register + * @param __INSTANCE__ USART Instance + * @param __REG__ Register to be read + * @retval Register value + */ +#define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) +/** + * @} + */ + +/** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper + * @{ + */ + +/** + * @brief Compute USARTDIV value according to Peripheral Clock and + * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned) + * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance + * @param __BAUDRATE__ Baud rate value to achieve + * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case + */ +#define __LL_USART_DIV_SAMPLING8_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(2*(__BAUDRATE__))) +#define __LL_USART_DIVMANT_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__))/100) +#define __LL_USART_DIVFRAQ_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 8\ + + 50) / 100) +/* UART BRR = mantissa + overflow + fraction + = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07) */ +#define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \ + ((__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0xF8) << 1)) + \ + (__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0x07)) + +/** + * @brief Compute USARTDIV value according to Peripheral Clock and + * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned) + * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance + * @param __BAUDRATE__ Baud rate value to achieve + * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case + */ +#define __LL_USART_DIV_SAMPLING16_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(4*(__BAUDRATE__))) +#define __LL_USART_DIVMANT_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__))/100) +#define __LL_USART_DIVFRAQ_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) ((((__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 16)\ + + 50) / 100) +/* USART BRR = mantissa + overflow + fraction + = (USART DIVMANT << 4) + (USART DIVFRAQ & 0xF0) + (USART DIVFRAQ & 0x0F) */ +#define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \ + (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0xF0)) + \ + (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0x0F)) + +/** + * @} + */ + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ + +/** @defgroup USART_LL_Exported_Functions USART Exported Functions + * @{ + */ + +/** @defgroup USART_LL_EF_Configuration Configuration functions + * @{ + */ + +/** + * @brief USART Enable + * @rmtoll CR1 UE LL_USART_Enable + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR1, USART_CR1_UE); +} + +/** + * @brief USART Disable (all USART prescalers and outputs are disabled) + * @note When USART is disabled, USART prescalers and outputs are stopped immediately, + * and current operations are discarded. The configuration of the USART is kept, but all the status + * flags, in the USARTx_SR are set to their default values. + * @rmtoll CR1 UE LL_USART_Disable + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR1, USART_CR1_UE); +} + +/** + * @brief Indicate if USART is enabled + * @rmtoll CR1 UE LL_USART_IsEnabled + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabled(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)); +} + +/** + * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) + * @rmtoll CR1 RE LL_USART_EnableDirectionRx + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RE); +} + +/** + * @brief Receiver Disable + * @rmtoll CR1 RE LL_USART_DisableDirectionRx + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RE); +} + +/** + * @brief Transmitter Enable + * @rmtoll CR1 TE LL_USART_EnableDirectionTx + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TE); +} + +/** + * @brief Transmitter Disable + * @rmtoll CR1 TE LL_USART_DisableDirectionTx + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TE); +} + +/** + * @brief Configure simultaneously enabled/disabled states + * of Transmitter and Receiver + * @rmtoll CR1 RE LL_USART_SetTransferDirection\n + * CR1 TE LL_USART_SetTransferDirection + * @param USARTx USART Instance + * @param TransferDirection This parameter can be one of the following values: + * @arg @ref LL_USART_DIRECTION_NONE + * @arg @ref LL_USART_DIRECTION_RX + * @arg @ref LL_USART_DIRECTION_TX + * @arg @ref LL_USART_DIRECTION_TX_RX + * @retval None + */ +__STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection) +{ + ATOMIC_MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); +} + +/** + * @brief Return enabled/disabled states of Transmitter and Receiver + * @rmtoll CR1 RE LL_USART_GetTransferDirection\n + * CR1 TE LL_USART_GetTransferDirection + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_DIRECTION_NONE + * @arg @ref LL_USART_DIRECTION_RX + * @arg @ref LL_USART_DIRECTION_TX + * @arg @ref LL_USART_DIRECTION_TX_RX + */ +__STATIC_INLINE uint32_t LL_USART_GetTransferDirection(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE)); +} + +/** + * @brief Configure Parity (enabled/disabled and parity mode if enabled). + * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. + * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position + * (9th or 8th bit depending on data width) and parity is checked on the received data. + * @rmtoll CR1 PS LL_USART_SetParity\n + * CR1 PCE LL_USART_SetParity + * @param USARTx USART Instance + * @param Parity This parameter can be one of the following values: + * @arg @ref LL_USART_PARITY_NONE + * @arg @ref LL_USART_PARITY_EVEN + * @arg @ref LL_USART_PARITY_ODD + * @retval None + */ +__STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity) +{ + MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); +} + +/** + * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) + * @rmtoll CR1 PS LL_USART_GetParity\n + * CR1 PCE LL_USART_GetParity + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_PARITY_NONE + * @arg @ref LL_USART_PARITY_EVEN + * @arg @ref LL_USART_PARITY_ODD + */ +__STATIC_INLINE uint32_t LL_USART_GetParity(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); +} + +/** + * @brief Set Receiver Wake Up method from Mute mode. + * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod + * @param USARTx USART Instance + * @param Method This parameter can be one of the following values: + * @arg @ref LL_USART_WAKEUP_IDLELINE + * @arg @ref LL_USART_WAKEUP_ADDRESSMARK + * @retval None + */ +__STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method) +{ + MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method); +} + +/** + * @brief Return Receiver Wake Up method from Mute mode + * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_WAKEUP_IDLELINE + * @arg @ref LL_USART_WAKEUP_ADDRESSMARK + */ +__STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE)); +} + +/** + * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits) + * @rmtoll CR1 M LL_USART_SetDataWidth + * @param USARTx USART Instance + * @param DataWidth This parameter can be one of the following values: + * @arg @ref LL_USART_DATAWIDTH_8B + * @arg @ref LL_USART_DATAWIDTH_9B + * @retval None + */ +__STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth) +{ + MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth); +} + +/** + * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) + * @rmtoll CR1 M LL_USART_GetDataWidth + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_DATAWIDTH_8B + * @arg @ref LL_USART_DATAWIDTH_9B + */ +__STATIC_INLINE uint32_t LL_USART_GetDataWidth(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M)); +} + +#if defined(USART_CR1_OVER8) +/** + * @brief Set Oversampling to 8-bit or 16-bit mode + * @rmtoll CR1 OVER8 LL_USART_SetOverSampling + * @param USARTx USART Instance + * @param OverSampling This parameter can be one of the following values: + * @arg @ref LL_USART_OVERSAMPLING_16 + * @arg @ref LL_USART_OVERSAMPLING_8 + * @retval None + */ +__STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling) +{ + MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling); +} + +/** + * @brief Return Oversampling mode + * @rmtoll CR1 OVER8 LL_USART_GetOverSampling + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_OVERSAMPLING_16 + * @arg @ref LL_USART_OVERSAMPLING_8 + */ +__STATIC_INLINE uint32_t LL_USART_GetOverSampling(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8)); +} + +#endif /* USART_OverSampling_Feature */ +/** + * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput + * @param USARTx USART Instance + * @param LastBitClockPulse This parameter can be one of the following values: + * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT + * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT + * @retval None + */ +__STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse); +} + +/** + * @brief Retrieve Clock pulse of the last data bit output configuration + * (Last bit Clock pulse output to the SCLK pin or not) + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT + * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT + */ +__STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL)); +} + +/** + * @brief Select the phase of the clock output on the SCLK pin in synchronous mode + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CPHA LL_USART_SetClockPhase + * @param USARTx USART Instance + * @param ClockPhase This parameter can be one of the following values: + * @arg @ref LL_USART_PHASE_1EDGE + * @arg @ref LL_USART_PHASE_2EDGE + * @retval None + */ +__STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase); +} + +/** + * @brief Return phase of the clock output on the SCLK pin in synchronous mode + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CPHA LL_USART_GetClockPhase + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_PHASE_1EDGE + * @arg @ref LL_USART_PHASE_2EDGE + */ +__STATIC_INLINE uint32_t LL_USART_GetClockPhase(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA)); +} + +/** + * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CPOL LL_USART_SetClockPolarity + * @param USARTx USART Instance + * @param ClockPolarity This parameter can be one of the following values: + * @arg @ref LL_USART_POLARITY_LOW + * @arg @ref LL_USART_POLARITY_HIGH + * @retval None + */ +__STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity); +} + +/** + * @brief Return polarity of the clock output on the SCLK pin in synchronous mode + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CPOL LL_USART_GetClockPolarity + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_POLARITY_LOW + * @arg @ref LL_USART_POLARITY_HIGH + */ +__STATIC_INLINE uint32_t LL_USART_GetClockPolarity(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL)); +} + +/** + * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse) + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @note Call of this function is equivalent to following function call sequence : + * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function + * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function + * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function + * @rmtoll CR2 CPHA LL_USART_ConfigClock\n + * CR2 CPOL LL_USART_ConfigClock\n + * CR2 LBCL LL_USART_ConfigClock + * @param USARTx USART Instance + * @param Phase This parameter can be one of the following values: + * @arg @ref LL_USART_PHASE_1EDGE + * @arg @ref LL_USART_PHASE_2EDGE + * @param Polarity This parameter can be one of the following values: + * @arg @ref LL_USART_POLARITY_LOW + * @arg @ref LL_USART_POLARITY_HIGH + * @param LBCPOutput This parameter can be one of the following values: + * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT + * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput); +} + +/** + * @brief Enable Clock output on SCLK pin + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR2, USART_CR2_CLKEN); +} + +/** + * @brief Disable Clock output on SCLK pin + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN); +} + +/** + * @brief Indicate if Clock output on SCLK pin is enabled + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)); +} + +/** + * @brief Set the length of the stop bits + * @rmtoll CR2 STOP LL_USART_SetStopBitsLength + * @param USARTx USART Instance + * @param StopBits This parameter can be one of the following values: + * @arg @ref LL_USART_STOPBITS_0_5 + * @arg @ref LL_USART_STOPBITS_1 + * @arg @ref LL_USART_STOPBITS_1_5 + * @arg @ref LL_USART_STOPBITS_2 + * @retval None + */ +__STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); +} + +/** + * @brief Retrieve the length of the stop bits + * @rmtoll CR2 STOP LL_USART_GetStopBitsLength + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_STOPBITS_0_5 + * @arg @ref LL_USART_STOPBITS_1 + * @arg @ref LL_USART_STOPBITS_1_5 + * @arg @ref LL_USART_STOPBITS_2 + */ +__STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP)); +} + +/** + * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) + * @note Call of this function is equivalent to following function call sequence : + * - Data Width configuration using @ref LL_USART_SetDataWidth() function + * - Parity Control and mode configuration using @ref LL_USART_SetParity() function + * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function + * @rmtoll CR1 PS LL_USART_ConfigCharacter\n + * CR1 PCE LL_USART_ConfigCharacter\n + * CR1 M LL_USART_ConfigCharacter\n + * CR2 STOP LL_USART_ConfigCharacter + * @param USARTx USART Instance + * @param DataWidth This parameter can be one of the following values: + * @arg @ref LL_USART_DATAWIDTH_8B + * @arg @ref LL_USART_DATAWIDTH_9B + * @param Parity This parameter can be one of the following values: + * @arg @ref LL_USART_PARITY_NONE + * @arg @ref LL_USART_PARITY_EVEN + * @arg @ref LL_USART_PARITY_ODD + * @param StopBits This parameter can be one of the following values: + * @arg @ref LL_USART_STOPBITS_0_5 + * @arg @ref LL_USART_STOPBITS_1 + * @arg @ref LL_USART_STOPBITS_1_5 + * @arg @ref LL_USART_STOPBITS_2 + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity, + uint32_t StopBits) +{ + MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); + MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); +} + +/** + * @brief Set Address of the USART node. + * @note This is used in multiprocessor communication during Mute mode or Stop mode, + * for wake up with address mark detection. + * @rmtoll CR2 ADD LL_USART_SetNodeAddress + * @param USARTx USART Instance + * @param NodeAddress 4 bit Address of the USART node. + * @retval None + */ +__STATIC_INLINE void LL_USART_SetNodeAddress(USART_TypeDef *USARTx, uint32_t NodeAddress) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_ADD, (NodeAddress & USART_CR2_ADD)); +} + +/** + * @brief Return 4 bit Address of the USART node as set in ADD field of CR2. + * @note only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) + * @rmtoll CR2 ADD LL_USART_GetNodeAddress + * @param USARTx USART Instance + * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255) + */ +__STATIC_INLINE uint32_t LL_USART_GetNodeAddress(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD)); +} + +/** + * @brief Enable RTS HW Flow Control + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_RTSE); +} + +/** + * @brief Disable RTS HW Flow Control + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE); +} + +/** + * @brief Enable CTS HW Flow Control + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_CTSE); +} + +/** + * @brief Disable CTS HW Flow Control + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE); +} + +/** + * @brief Configure HW Flow Control mode (both CTS and RTS) + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n + * CR3 CTSE LL_USART_SetHWFlowCtrl + * @param USARTx USART Instance + * @param HardwareFlowControl This parameter can be one of the following values: + * @arg @ref LL_USART_HWCONTROL_NONE + * @arg @ref LL_USART_HWCONTROL_RTS + * @arg @ref LL_USART_HWCONTROL_CTS + * @arg @ref LL_USART_HWCONTROL_RTS_CTS + * @retval None + */ +__STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl) +{ + MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); +} + +/** + * @brief Return HW Flow Control configuration (both CTS and RTS) + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n + * CR3 CTSE LL_USART_GetHWFlowCtrl + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_HWCONTROL_NONE + * @arg @ref LL_USART_HWCONTROL_RTS + * @arg @ref LL_USART_HWCONTROL_CTS + * @arg @ref LL_USART_HWCONTROL_RTS_CTS + */ +__STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); +} + +#if defined(USART_CR3_ONEBIT) +/** + * @brief Enable One bit sampling method + * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_ONEBIT); +} + +/** + * @brief Disable One bit sampling method + * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT); +} + +/** + * @brief Indicate if One bit sampling method is enabled + * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)); +} +#endif /* USART_OneBitSampling_Feature */ + +#if defined(USART_CR1_OVER8) +/** + * @brief Configure USART BRR register for achieving expected Baud Rate value. + * @note Compute and set USARTDIV value in BRR Register (full BRR content) + * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values + * @note Peripheral clock and Baud rate values provided as function parameters should be valid + * (Baud rate value != 0) + * @rmtoll BRR BRR LL_USART_SetBaudRate + * @param USARTx USART Instance + * @param PeriphClk Peripheral Clock + * @param OverSampling This parameter can be one of the following values: + * @arg @ref LL_USART_OVERSAMPLING_16 + * @arg @ref LL_USART_OVERSAMPLING_8 + * @param BaudRate Baud Rate + * @retval None + */ +__STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling, + uint32_t BaudRate) +{ + if (OverSampling == LL_USART_OVERSAMPLING_8) + { + USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate)); + } + else + { + USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate)); + } +} + +/** + * @brief Return current Baud Rate value, according to USARTDIV present in BRR register + * (full BRR content), and to used Peripheral Clock and Oversampling mode values + * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. + * @rmtoll BRR BRR LL_USART_GetBaudRate + * @param USARTx USART Instance + * @param PeriphClk Peripheral Clock + * @param OverSampling This parameter can be one of the following values: + * @arg @ref LL_USART_OVERSAMPLING_16 + * @arg @ref LL_USART_OVERSAMPLING_8 + * @retval Baud Rate + */ +__STATIC_INLINE uint32_t LL_USART_GetBaudRate(const USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling) +{ + uint32_t usartdiv = 0x0U; + uint32_t brrresult = 0x0U; + + usartdiv = USARTx->BRR; + + if (OverSampling == LL_USART_OVERSAMPLING_8) + { + if ((usartdiv & 0xFFF7U) != 0U) + { + usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ; + brrresult = (PeriphClk * 2U) / usartdiv; + } + } + else + { + if ((usartdiv & 0xFFFFU) != 0U) + { + brrresult = PeriphClk / usartdiv; + } + } + return (brrresult); +} +#else +/** + * @brief Configure USART BRR register for achieving expected Baud Rate value. + * @note Compute and set USARTDIV value in BRR Register (full BRR content) + * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values + * @note Peripheral clock and Baud rate values provided as function parameters should be valid + * (Baud rate value != 0) + * @rmtoll BRR BRR LL_USART_SetBaudRate + * @param USARTx USART Instance + * @param PeriphClk Peripheral Clock + * @param BaudRate Baud Rate + * @retval None + */ +__STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t BaudRate) +{ + USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate)); +} + +/** + * @brief Return current Baud Rate value, according to USARTDIV present in BRR register + * (full BRR content), and to used Peripheral Clock and Oversampling mode values + * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. + * @rmtoll BRR BRR LL_USART_GetBaudRate + * @param USARTx USART Instance + * @param PeriphClk Peripheral Clock + * @retval Baud Rate + */ +__STATIC_INLINE uint32_t LL_USART_GetBaudRate(const USART_TypeDef *USARTx, uint32_t PeriphClk) +{ + uint32_t usartdiv = 0x0U; + uint32_t brrresult = 0x0U; + + usartdiv = USARTx->BRR; + + if ((usartdiv & 0xFFFFU) != 0U) + { + brrresult = PeriphClk / usartdiv; + } + return (brrresult); +} +#endif /* USART_OverSampling_Feature */ + +/** + * @} + */ + +/** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature + * @{ + */ + +/** + * @brief Enable IrDA mode + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll CR3 IREN LL_USART_EnableIrda + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_IREN); +} + +/** + * @brief Disable IrDA mode + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll CR3 IREN LL_USART_DisableIrda + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_IREN); +} + +/** + * @brief Indicate if IrDA mode is enabled + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll CR3 IREN LL_USART_IsEnabledIrda + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)); +} + +/** + * @brief Configure IrDA Power Mode (Normal or Low Power) + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode + * @param USARTx USART Instance + * @param PowerMode This parameter can be one of the following values: + * @arg @ref LL_USART_IRDA_POWER_NORMAL + * @arg @ref LL_USART_IRDA_POWER_LOW + * @retval None + */ +__STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode) +{ + MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode); +} + +/** + * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power) + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_IRDA_POWER_NORMAL + * @arg @ref LL_USART_PHASE_2EDGE + */ +__STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP)); +} + +/** + * @brief Set Irda prescaler value, used for dividing the USART clock source + * to achieve the Irda Low Power frequency (8 bits value) + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler + * @param USARTx USART Instance + * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF + * @retval None + */ +__STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) +{ + MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); +} + +/** + * @brief Return Irda prescaler value, used for dividing the USART clock source + * to achieve the Irda Low Power frequency (8 bits value) + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler + * @param USARTx USART Instance + * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF) + */ +__STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature + * @{ + */ + +/** + * @brief Enable Smartcard NACK transmission + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_NACK); +} + +/** + * @brief Disable Smartcard NACK transmission + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_NACK); +} + +/** + * @brief Indicate if Smartcard NACK transmission is enabled + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)); +} + +/** + * @brief Enable Smartcard mode + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll CR3 SCEN LL_USART_EnableSmartcard + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_SCEN); +} + +/** + * @brief Disable Smartcard mode + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll CR3 SCEN LL_USART_DisableSmartcard + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN); +} + +/** + * @brief Indicate if Smartcard mode is enabled + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)); +} + +/** + * @brief Set Smartcard prescaler value, used for dividing the USART clock + * source to provide the SMARTCARD Clock (5 bits value) + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler + * @param USARTx USART Instance + * @param PrescalerValue Value between Min_Data=0 and Max_Data=31 + * @retval None + */ +__STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) +{ + MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); +} + +/** + * @brief Return Smartcard prescaler value, used for dividing the USART clock + * source to provide the SMARTCARD Clock (5 bits value) + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler + * @param USARTx USART Instance + * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31) + */ +__STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); +} + +/** + * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods + * (GT[7:0] bits : Guard time value) + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime + * @param USARTx USART Instance + * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF + * @retval None + */ +__STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime) +{ + MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT); +} + +/** + * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods + * (GT[7:0] bits : Guard time value) + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime + * @param USARTx USART Instance + * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF) + */ +__STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature + * @{ + */ + +/** + * @brief Enable Single Wire Half-Duplex mode + * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not + * Half-Duplex mode is supported by the USARTx instance. + * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR3, USART_CR3_HDSEL); +} + +/** + * @brief Disable Single Wire Half-Duplex mode + * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not + * Half-Duplex mode is supported by the USARTx instance. + * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL); +} + +/** + * @brief Indicate if Single Wire Half-Duplex mode is enabled + * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not + * Half-Duplex mode is supported by the USARTx instance. + * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature + * @{ + */ + +/** + * @brief Set LIN Break Detection Length + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen + * @param USARTx USART Instance + * @param LINBDLength This parameter can be one of the following values: + * @arg @ref LL_USART_LINBREAK_DETECT_10B + * @arg @ref LL_USART_LINBREAK_DETECT_11B + * @retval None + */ +__STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength) +{ + MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength); +} + +/** + * @brief Return LIN Break Detection Length + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen + * @param USARTx USART Instance + * @retval Returned value can be one of the following values: + * @arg @ref LL_USART_LINBREAK_DETECT_10B + * @arg @ref LL_USART_LINBREAK_DETECT_11B + */ +__STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(const USART_TypeDef *USARTx) +{ + return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL)); +} + +/** + * @brief Enable LIN mode + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LINEN LL_USART_EnableLIN + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR2, USART_CR2_LINEN); +} + +/** + * @brief Disable LIN mode + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LINEN LL_USART_DisableLIN + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN); +} + +/** + * @brief Indicate if LIN mode is enabled + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services + * @{ + */ + +/** + * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART) + * @note In UART mode, the following bits must be kept cleared: + * - LINEN bit in the USART_CR2 register, + * - CLKEN bit in the USART_CR2 register, + * - SCEN bit in the USART_CR3 register, + * - IREN bit in the USART_CR3 register, + * - HDSEL bit in the USART_CR3 register. + * @note Call of this function is equivalent to following function call sequence : + * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function + * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function + * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function + * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function + * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function + * @note Other remaining configurations items related to Asynchronous Mode + * (as Baud Rate, Word length, Parity, ...) should be set using + * dedicated functions + * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n + * CR2 CLKEN LL_USART_ConfigAsyncMode\n + * CR3 SCEN LL_USART_ConfigAsyncMode\n + * CR3 IREN LL_USART_ConfigAsyncMode\n + * CR3 HDSEL LL_USART_ConfigAsyncMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx) +{ + /* In Asynchronous mode, the following bits must be kept cleared: + - LINEN, CLKEN bits in the USART_CR2 register, + - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ + CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); +} + +/** + * @brief Perform basic configuration of USART for enabling use in Synchronous Mode + * @note In Synchronous mode, the following bits must be kept cleared: + * - LINEN bit in the USART_CR2 register, + * - SCEN bit in the USART_CR3 register, + * - IREN bit in the USART_CR3 register, + * - HDSEL bit in the USART_CR3 register. + * This function also sets the USART in Synchronous mode. + * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not + * Synchronous mode is supported by the USARTx instance. + * @note Call of this function is equivalent to following function call sequence : + * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function + * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function + * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function + * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function + * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function + * @note Other remaining configurations items related to Synchronous Mode + * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using + * dedicated functions + * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n + * CR2 CLKEN LL_USART_ConfigSyncMode\n + * CR3 SCEN LL_USART_ConfigSyncMode\n + * CR3 IREN LL_USART_ConfigSyncMode\n + * CR3 HDSEL LL_USART_ConfigSyncMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx) +{ + /* In Synchronous mode, the following bits must be kept cleared: + - LINEN bit in the USART_CR2 register, + - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ + CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); + /* set the UART/USART in Synchronous mode */ + SET_BIT(USARTx->CR2, USART_CR2_CLKEN); +} + +/** + * @brief Perform basic configuration of USART for enabling use in LIN Mode + * @note In LIN mode, the following bits must be kept cleared: + * - STOP and CLKEN bits in the USART_CR2 register, + * - SCEN bit in the USART_CR3 register, + * - IREN bit in the USART_CR3 register, + * - HDSEL bit in the USART_CR3 register. + * This function also set the UART/USART in LIN mode. + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @note Call of this function is equivalent to following function call sequence : + * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function + * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function + * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function + * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function + * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function + * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function + * @note Other remaining configurations items related to LIN Mode + * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using + * dedicated functions + * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n + * CR2 STOP LL_USART_ConfigLINMode\n + * CR2 LINEN LL_USART_ConfigLINMode\n + * CR3 IREN LL_USART_ConfigLINMode\n + * CR3 SCEN LL_USART_ConfigLINMode\n + * CR3 HDSEL LL_USART_ConfigLINMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx) +{ + /* In LIN mode, the following bits must be kept cleared: + - STOP and CLKEN bits in the USART_CR2 register, + - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ + CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL)); + /* Set the UART/USART in LIN mode */ + SET_BIT(USARTx->CR2, USART_CR2_LINEN); +} + +/** + * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode + * @note In Half Duplex mode, the following bits must be kept cleared: + * - LINEN bit in the USART_CR2 register, + * - CLKEN bit in the USART_CR2 register, + * - SCEN bit in the USART_CR3 register, + * - IREN bit in the USART_CR3 register, + * This function also sets the UART/USART in Half Duplex mode. + * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not + * Half-Duplex mode is supported by the USARTx instance. + * @note Call of this function is equivalent to following function call sequence : + * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function + * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function + * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function + * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function + * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function + * @note Other remaining configurations items related to Half Duplex Mode + * (as Baud Rate, Word length, Parity, ...) should be set using + * dedicated functions + * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n + * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n + * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n + * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n + * CR3 IREN LL_USART_ConfigHalfDuplexMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx) +{ + /* 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(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN)); + /* set the UART/USART in Half Duplex mode */ + SET_BIT(USARTx->CR3, USART_CR3_HDSEL); +} + +/** + * @brief Perform basic configuration of USART for enabling use in Smartcard Mode + * @note In Smartcard mode, the following bits must be kept cleared: + * - LINEN bit in the USART_CR2 register, + * - IREN bit in the USART_CR3 register, + * - HDSEL bit in the USART_CR3 register. + * This function also configures Stop bits to 1.5 bits and + * sets the USART in Smartcard mode (SCEN bit). + * Clock Output is also enabled (CLKEN). + * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not + * Smartcard feature is supported by the USARTx instance. + * @note Call of this function is equivalent to following function call sequence : + * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function + * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function + * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function + * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function + * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function + * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function + * @note Other remaining configurations items related to Smartcard Mode + * (as Baud Rate, Word length, Parity, ...) should be set using + * dedicated functions + * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n + * CR2 STOP LL_USART_ConfigSmartcardMode\n + * CR2 CLKEN LL_USART_ConfigSmartcardMode\n + * CR3 HDSEL LL_USART_ConfigSmartcardMode\n + * CR3 SCEN LL_USART_ConfigSmartcardMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx) +{ + /* In Smartcard mode, the following bits must be kept cleared: + - LINEN bit in the USART_CR2 register, + - IREN and HDSEL bits in the USART_CR3 register.*/ + CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL)); + /* Configure Stop bits to 1.5 bits */ + /* Synchronous mode is activated by default */ + SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN)); + /* set the UART/USART in Smartcard mode */ + SET_BIT(USARTx->CR3, USART_CR3_SCEN); +} + +/** + * @brief Perform basic configuration of USART for enabling use in Irda Mode + * @note In IRDA mode, the following bits must be kept cleared: + * - LINEN bit in the USART_CR2 register, + * - STOP and CLKEN bits in the USART_CR2 register, + * - SCEN bit in the USART_CR3 register, + * - HDSEL bit in the USART_CR3 register. + * This function also sets the UART/USART in IRDA mode (IREN bit). + * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not + * IrDA feature is supported by the USARTx instance. + * @note Call of this function is equivalent to following function call sequence : + * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function + * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function + * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function + * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function + * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function + * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function + * @note Other remaining configurations items related to Irda Mode + * (as Baud Rate, Word length, Power mode, ...) should be set using + * dedicated functions + * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n + * CR2 CLKEN LL_USART_ConfigIrdaMode\n + * CR2 STOP LL_USART_ConfigIrdaMode\n + * CR3 SCEN LL_USART_ConfigIrdaMode\n + * CR3 HDSEL LL_USART_ConfigIrdaMode\n + * CR3 IREN LL_USART_ConfigIrdaMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx) +{ + /* In IRDA mode, the following bits must be kept cleared: + - LINEN, STOP and CLKEN bits in the USART_CR2 register, + - SCEN and HDSEL bits in the USART_CR3 register.*/ + CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL)); + /* set the UART/USART in IRDA mode */ + SET_BIT(USARTx->CR3, USART_CR3_IREN); +} + +/** + * @brief Perform basic configuration of USART for enabling use in Multi processor Mode + * (several USARTs connected in a network, one of the USARTs can be the master, + * its TX output connected to the RX inputs of the other slaves USARTs). + * @note In MultiProcessor mode, the following bits must be kept cleared: + * - LINEN bit in the USART_CR2 register, + * - CLKEN bit in the USART_CR2 register, + * - SCEN bit in the USART_CR3 register, + * - IREN bit in the USART_CR3 register, + * - HDSEL bit in the USART_CR3 register. + * @note Call of this function is equivalent to following function call sequence : + * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function + * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function + * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function + * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function + * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function + * @note Other remaining configurations items related to Multi processor Mode + * (as Baud Rate, Wake Up Method, Node address, ...) should be set using + * dedicated functions + * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n + * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n + * CR3 SCEN LL_USART_ConfigMultiProcessMode\n + * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n + * CR3 IREN LL_USART_ConfigMultiProcessMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx) +{ + /* In Multi Processor mode, the following bits must be kept cleared: + - LINEN and CLKEN bits in the USART_CR2 register, + - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ + CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); + CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_FLAG_Management FLAG_Management + * @{ + */ + +/** + * @brief Check if the USART Parity Error Flag is set or not + * @rmtoll SR PE LL_USART_IsActiveFlag_PE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_PE) == (USART_SR_PE)); +} + +/** + * @brief Check if the USART Framing Error Flag is set or not + * @rmtoll SR FE LL_USART_IsActiveFlag_FE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_FE) == (USART_SR_FE)); +} + +/** + * @brief Check if the USART Noise error detected Flag is set or not + * @rmtoll SR NF LL_USART_IsActiveFlag_NE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_NE) == (USART_SR_NE)); +} + +/** + * @brief Check if the USART OverRun Error Flag is set or not + * @rmtoll SR ORE LL_USART_IsActiveFlag_ORE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_ORE) == (USART_SR_ORE)); +} + +/** + * @brief Check if the USART IDLE line detected Flag is set or not + * @rmtoll SR IDLE LL_USART_IsActiveFlag_IDLE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_IDLE) == (USART_SR_IDLE)); +} + +/** + * @brief Check if the USART Read Data Register Not Empty Flag is set or not + * @rmtoll SR RXNE LL_USART_IsActiveFlag_RXNE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_RXNE) == (USART_SR_RXNE)); +} + +/** + * @brief Check if the USART Transmission Complete Flag is set or not + * @rmtoll SR TC LL_USART_IsActiveFlag_TC + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_TC) == (USART_SR_TC)); +} + +/** + * @brief Check if the USART Transmit Data Register Empty Flag is set or not + * @rmtoll SR TXE LL_USART_IsActiveFlag_TXE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_TXE) == (USART_SR_TXE)); +} + +/** + * @brief Check if the USART LIN Break Detection Flag is set or not + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll SR LBD LL_USART_IsActiveFlag_LBD + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_LBD) == (USART_SR_LBD)); +} + +/** + * @brief Check if the USART CTS Flag is set or not + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll SR CTS LL_USART_IsActiveFlag_nCTS + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->SR, USART_SR_CTS) == (USART_SR_CTS)); +} + +/** + * @brief Check if the USART Send Break Flag is set or not + * @rmtoll CR1 SBK LL_USART_IsActiveFlag_SBK + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_SBK) == (USART_CR1_SBK)); +} + +/** + * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not + * @rmtoll CR1 RWU LL_USART_IsActiveFlag_RWU + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_RWU) == (USART_CR1_RWU)); +} + +/** + * @brief Clear Parity Error Flag + * @note Clearing this flag is done by a read access to the USARTx_SR + * register followed by a read access to the USARTx_DR register. + * @note Please also consider that when clearing this flag, other flags as + * NE, FE, ORE, IDLE would also be cleared. + * @rmtoll SR PE LL_USART_ClearFlag_PE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx) +{ + __IO uint32_t tmpreg; + tmpreg = USARTx->SR; + (void) tmpreg; + tmpreg = USARTx->DR; + (void) tmpreg; +} + +/** + * @brief Clear Framing Error Flag + * @note Clearing this flag is done by a read access to the USARTx_SR + * register followed by a read access to the USARTx_DR register. + * @note Please also consider that when clearing this flag, other flags as + * PE, NE, ORE, IDLE would also be cleared. + * @rmtoll SR FE LL_USART_ClearFlag_FE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx) +{ + __IO uint32_t tmpreg; + tmpreg = USARTx->SR; + (void) tmpreg; + tmpreg = USARTx->DR; + (void) tmpreg; +} + +/** + * @brief Clear Noise detected Flag + * @note Clearing this flag is done by a read access to the USARTx_SR + * register followed by a read access to the USARTx_DR register. + * @note Please also consider that when clearing this flag, other flags as + * PE, FE, ORE, IDLE would also be cleared. + * @rmtoll SR NF LL_USART_ClearFlag_NE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx) +{ + __IO uint32_t tmpreg; + tmpreg = USARTx->SR; + (void) tmpreg; + tmpreg = USARTx->DR; + (void) tmpreg; +} + +/** + * @brief Clear OverRun Error Flag + * @note Clearing this flag is done by a read access to the USARTx_SR + * register followed by a read access to the USARTx_DR register. + * @note Please also consider that when clearing this flag, other flags as + * PE, NE, FE, IDLE would also be cleared. + * @rmtoll SR ORE LL_USART_ClearFlag_ORE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx) +{ + __IO uint32_t tmpreg; + tmpreg = USARTx->SR; + (void) tmpreg; + tmpreg = USARTx->DR; + (void) tmpreg; +} + +/** + * @brief Clear IDLE line detected Flag + * @note Clearing this flag is done by a read access to the USARTx_SR + * register followed by a read access to the USARTx_DR register. + * @note Please also consider that when clearing this flag, other flags as + * PE, NE, FE, ORE would also be cleared. + * @rmtoll SR IDLE LL_USART_ClearFlag_IDLE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx) +{ + __IO uint32_t tmpreg; + tmpreg = USARTx->SR; + (void) tmpreg; + tmpreg = USARTx->DR; + (void) tmpreg; +} + +/** + * @brief Clear Transmission Complete Flag + * @rmtoll SR TC LL_USART_ClearFlag_TC + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx) +{ + WRITE_REG(USARTx->SR, ~(USART_SR_TC)); +} + +/** + * @brief Clear RX Not Empty Flag + * @rmtoll SR RXNE LL_USART_ClearFlag_RXNE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_RXNE(USART_TypeDef *USARTx) +{ + WRITE_REG(USARTx->SR, ~(USART_SR_RXNE)); +} + +/** + * @brief Clear LIN Break Detection Flag + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll SR LBD LL_USART_ClearFlag_LBD + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx) +{ + WRITE_REG(USARTx->SR, ~(USART_SR_LBD)); +} + +/** + * @brief Clear CTS Interrupt Flag + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll SR CTS LL_USART_ClearFlag_nCTS + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx) +{ + WRITE_REG(USARTx->SR, ~(USART_SR_CTS)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_IT_Management IT_Management + * @{ + */ + +/** + * @brief Enable IDLE Interrupt + * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_IDLEIE); +} + +/** + * @brief Enable RX Not Empty Interrupt + * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RXNEIE); +} + +/** + * @brief Enable Transmission Complete Interrupt + * @rmtoll CR1 TCIE LL_USART_EnableIT_TC + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TCIE); +} + +/** + * @brief Enable TX Empty Interrupt + * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TXEIE); +} + +/** + * @brief Enable Parity Error Interrupt + * @rmtoll CR1 PEIE LL_USART_EnableIT_PE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_PEIE); +} + +/** + * @brief Enable LIN Break Detection Interrupt + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR2, USART_CR2_LBDIE); +} + +/** + * @brief Enable Error Interrupt + * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing + * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register). + * 0: Interrupt is inhibited + * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register. + * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_EIE); +} + +/** + * @brief Enable CTS Interrupt + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_CTSIE); +} + +/** + * @brief Disable IDLE Interrupt + * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE); +} + +/** + * @brief Disable RX Not Empty Interrupt + * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE); +} + +/** + * @brief Disable Transmission Complete Interrupt + * @rmtoll CR1 TCIE LL_USART_DisableIT_TC + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE); +} + +/** + * @brief Disable TX Empty Interrupt + * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE); +} + +/** + * @brief Disable Parity Error Interrupt + * @rmtoll CR1 PEIE LL_USART_DisableIT_PE + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE); +} + +/** + * @brief Disable LIN Break Detection Interrupt + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE); +} + +/** + * @brief Disable Error Interrupt + * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing + * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register). + * 0: Interrupt is inhibited + * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register. + * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_EIE); +} + +/** + * @brief Disable CTS Interrupt + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE); +} + +/** + * @brief Check if the USART IDLE Interrupt source is enabled or disabled. + * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)); +} + +/** + * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled. + * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)); +} + +/** + * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled. + * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)); +} + +/** + * @brief Check if the USART TX Empty Interrupt is enabled or disabled. + * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)); +} + +/** + * @brief Check if the USART Parity Error Interrupt is enabled or disabled. + * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)); +} + +/** + * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled. + * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not + * LIN feature is supported by the USARTx instance. + * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)); +} + +/** + * @brief Check if the USART Error Interrupt is enabled or disabled. + * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)); +} + +/** + * @brief Check if the USART CTS Interrupt is enabled or disabled. + * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not + * Hardware Flow control feature is supported by the USARTx instance. + * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_DMA_Management DMA_Management + * @{ + */ + +/** + * @brief Enable DMA Mode for reception + * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_DMAR); +} + +/** + * @brief Disable DMA Mode for reception + * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR); +} + +/** + * @brief Check if DMA Mode is enabled for reception + * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)); +} + +/** + * @brief Enable DMA Mode for transmission + * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx) +{ + ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_DMAT); +} + +/** + * @brief Disable DMA Mode for transmission + * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx) +{ + ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT); +} + +/** + * @brief Check if DMA Mode is enabled for transmission + * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX + * @param USARTx USART Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(const USART_TypeDef *USARTx) +{ + return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)); +} + +/** + * @brief Get the data register address used for DMA transfer + * @rmtoll DR DR LL_USART_DMA_GetRegAddr + * @note Address of Data Register is valid for both Transmit and Receive transfers. + * @param USARTx USART Instance + * @retval Address of data register + */ +__STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(const USART_TypeDef *USARTx) +{ + /* return address of DR register */ + return ((uint32_t) &(USARTx->DR)); +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_Data_Management Data_Management + * @{ + */ + +/** + * @brief Read Receiver Data register (Receive Data value, 8 bits) + * @rmtoll DR DR LL_USART_ReceiveData8 + * @param USARTx USART Instance + * @retval Value between Min_Data=0x00 and Max_Data=0xFF + */ +__STATIC_INLINE uint8_t LL_USART_ReceiveData8(const USART_TypeDef *USARTx) +{ + return (uint8_t)(READ_BIT(USARTx->DR, USART_DR_DR)); +} + +/** + * @brief Read Receiver Data register (Receive Data value, 9 bits) + * @rmtoll DR DR LL_USART_ReceiveData9 + * @param USARTx USART Instance + * @retval Value between Min_Data=0x00 and Max_Data=0x1FF + */ +__STATIC_INLINE uint16_t LL_USART_ReceiveData9(const USART_TypeDef *USARTx) +{ + return (uint16_t)(READ_BIT(USARTx->DR, USART_DR_DR)); +} + +/** + * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) + * @rmtoll DR DR LL_USART_TransmitData8 + * @param USARTx USART Instance + * @param Value between Min_Data=0x00 and Max_Data=0xFF + * @retval None + */ +__STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value) +{ + USARTx->DR = Value; +} + +/** + * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) + * @rmtoll DR DR LL_USART_TransmitData9 + * @param USARTx USART Instance + * @param Value between Min_Data=0x00 and Max_Data=0x1FF + * @retval None + */ +__STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value) +{ + USARTx->DR = Value & 0x1FFU; +} + +/** + * @} + */ + +/** @defgroup USART_LL_EF_Execution Execution + * @{ + */ + +/** + * @brief Request Break sending + * @rmtoll CR1 SBK LL_USART_RequestBreakSending + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR1, USART_CR1_SBK); +} + +/** + * @brief Put USART in Mute mode + * @rmtoll CR1 RWU LL_USART_RequestEnterMuteMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx) +{ + SET_BIT(USARTx->CR1, USART_CR1_RWU); +} + +/** + * @brief Put USART in Active mode + * @rmtoll CR1 RWU LL_USART_RequestExitMuteMode + * @param USARTx USART Instance + * @retval None + */ +__STATIC_INLINE void LL_USART_RequestExitMuteMode(USART_TypeDef *USARTx) +{ + CLEAR_BIT(USARTx->CR1, USART_CR1_RWU); +} + +/** + * @} + */ + +#if defined(USE_FULL_LL_DRIVER) +/** @defgroup USART_LL_EF_Init Initialization and de-initialization functions + * @{ + */ +ErrorStatus LL_USART_DeInit(const USART_TypeDef *USARTx); +ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, const LL_USART_InitTypeDef *USART_InitStruct); +void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct); +ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, const LL_USART_ClockInitTypeDef *USART_ClockInitStruct); +void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct); +/** + * @} + */ +#endif /* USE_FULL_LL_DRIVER */ + +/** + * @} + */ + +/** + * @} + */ + +#endif /* USART1 || USART2 || USART3 || UART4 || UART5 */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F1xx_LL_USART_H */ + diff --git a/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c b/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c new file mode 100644 index 0000000..4301d09 --- /dev/null +++ b/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c @@ -0,0 +1,438 @@ +/** + ****************************************************************************** + * @file stm32f1xx_ll_usart.c + * @author MCD Application Team + * @brief USART LL module driver. + ****************************************************************************** + * @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. + * + ****************************************************************************** + */ + +#if defined(USE_FULL_LL_DRIVER) + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f1xx_ll_usart.h" +#include "stm32f1xx_ll_rcc.h" +#include "stm32f1xx_ll_bus.h" +#ifdef USE_FULL_ASSERT +#include "stm32_assert.h" +#else +#define assert_param(expr) ((void)0U) +#endif + +/** @addtogroup STM32F1xx_LL_Driver + * @{ + */ + +#if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5) + +/** @addtogroup USART_LL + * @{ + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/** @addtogroup USART_LL_Private_Constants + * @{ + */ + +/** + * @} + */ + + +/* Private macros ------------------------------------------------------------*/ +/** @addtogroup USART_LL_Private_Macros + * @{ + */ + +/* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available + * divided by the smallest oversampling used on the USART (i.e. 8) */ +#define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 4500000U) + +/* __VALUE__ In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. */ +#define IS_LL_USART_BRR_MIN(__VALUE__) ((__VALUE__) >= 16U) + +#define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \ + || ((__VALUE__) == LL_USART_DIRECTION_RX) \ + || ((__VALUE__) == LL_USART_DIRECTION_TX) \ + || ((__VALUE__) == LL_USART_DIRECTION_TX_RX)) + +#define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \ + || ((__VALUE__) == LL_USART_PARITY_EVEN) \ + || ((__VALUE__) == LL_USART_PARITY_ODD)) + +#define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_8B) \ + || ((__VALUE__) == LL_USART_DATAWIDTH_9B)) + +#define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \ + || ((__VALUE__) == LL_USART_OVERSAMPLING_8)) + +#define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \ + || ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT)) + +#define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \ + || ((__VALUE__) == LL_USART_PHASE_2EDGE)) + +#define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \ + || ((__VALUE__) == LL_USART_POLARITY_HIGH)) + +#define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \ + || ((__VALUE__) == LL_USART_CLOCK_ENABLE)) + +#define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_0_5) \ + || ((__VALUE__) == LL_USART_STOPBITS_1) \ + || ((__VALUE__) == LL_USART_STOPBITS_1_5) \ + || ((__VALUE__) == LL_USART_STOPBITS_2)) + +#define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \ + || ((__VALUE__) == LL_USART_HWCONTROL_RTS) \ + || ((__VALUE__) == LL_USART_HWCONTROL_CTS) \ + || ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS)) + +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------*/ + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup USART_LL_Exported_Functions + * @{ + */ + +/** @addtogroup USART_LL_EF_Init + * @{ + */ + +/** + * @brief De-initialize USART registers (Registers restored to their default values). + * @param USARTx USART Instance + * @retval An ErrorStatus enumeration value: + * - SUCCESS: USART registers are de-initialized + * - ERROR: USART registers are not de-initialized + */ +ErrorStatus LL_USART_DeInit(const USART_TypeDef *USARTx) +{ + ErrorStatus status = SUCCESS; + + /* Check the parameters */ + assert_param(IS_UART_INSTANCE(USARTx)); + + if (USARTx == USART1) + { + /* Force reset of USART clock */ + LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART1); + + /* Release reset of USART clock */ + LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART1); + } + else if (USARTx == USART2) + { + /* Force reset of USART clock */ + LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2); + + /* Release reset of USART clock */ + LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2); + } +#if defined(USART3) + else if (USARTx == USART3) + { + /* Force reset of USART clock */ + LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART3); + + /* Release reset of USART clock */ + LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART3); + } +#endif /* USART3 */ +#if defined(UART4) + else if (USARTx == UART4) + { + /* Force reset of UART clock */ + LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART4); + + /* Release reset of UART clock */ + LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART4); + } +#endif /* UART4 */ +#if defined(UART5) + else if (USARTx == UART5) + { + /* Force reset of UART clock */ + LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART5); + + /* Release reset of UART clock */ + LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART5); + } +#endif /* UART5 */ + else + { + status = ERROR; + } + + return (status); +} + +/** + * @brief Initialize USART registers according to the specified + * parameters in USART_InitStruct. + * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0), + * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. + * @note Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0). + * @param USARTx USART Instance + * @param USART_InitStruct pointer to a LL_USART_InitTypeDef structure + * that contains the configuration information for the specified USART peripheral. + * @retval An ErrorStatus enumeration value: + * - SUCCESS: USART registers are initialized according to USART_InitStruct content + * - ERROR: Problem occurred during USART Registers initialization + */ +ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, const LL_USART_InitTypeDef *USART_InitStruct) +{ + ErrorStatus status = ERROR; + uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO; + LL_RCC_ClocksTypeDef rcc_clocks; + + /* Check the parameters */ + assert_param(IS_UART_INSTANCE(USARTx)); + assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate)); + assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth)); + assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits)); + assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity)); + assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection)); + assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl)); +#if defined(USART_CR1_OVER8) + assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling)); +#endif /* USART_OverSampling_Feature */ + + /* USART needs to be in disabled state, in order to be able to configure some bits in + CRx registers */ + if (LL_USART_IsEnabled(USARTx) == 0U) + { + /*---------------------------- USART CR1 Configuration ----------------------- + * Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters: + * - DataWidth: USART_CR1_M bits according to USART_InitStruct->DataWidth value + * - Parity: USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value + * - TransferDirection: USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value + * - Oversampling: USART_CR1_OVER8 bit according to USART_InitStruct->OverSampling value. + */ +#if defined(USART_CR1_OVER8) + MODIFY_REG(USARTx->CR1, + (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | + USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8), + (USART_InitStruct->DataWidth | USART_InitStruct->Parity | + USART_InitStruct->TransferDirection | USART_InitStruct->OverSampling)); +#else + MODIFY_REG(USARTx->CR1, + (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | + USART_CR1_TE | USART_CR1_RE), + (USART_InitStruct->DataWidth | USART_InitStruct->Parity | + USART_InitStruct->TransferDirection)); +#endif /* USART_OverSampling_Feature */ + + /*---------------------------- USART CR2 Configuration ----------------------- + * Configure USARTx CR2 (Stop bits) with parameters: + * - Stop Bits: USART_CR2_STOP bits according to USART_InitStruct->StopBits value. + * - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit(). + */ + LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits); + + /*---------------------------- USART CR3 Configuration ----------------------- + * Configure USARTx CR3 (Hardware Flow Control) with parameters: + * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value. + */ + LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl); + + /*---------------------------- USART BRR Configuration ----------------------- + * Retrieve Clock frequency used for USART Peripheral + */ + LL_RCC_GetSystemClocksFreq(&rcc_clocks); + if (USARTx == USART1) + { + periphclk = rcc_clocks.PCLK2_Frequency; + } + else if (USARTx == USART2) + { + periphclk = rcc_clocks.PCLK1_Frequency; + } +#if defined(USART3) + else if (USARTx == USART3) + { + periphclk = rcc_clocks.PCLK1_Frequency; + } +#endif /* USART3 */ +#if defined(UART4) + else if (USARTx == UART4) + { + periphclk = rcc_clocks.PCLK1_Frequency; + } +#endif /* UART4 */ +#if defined(UART5) + else if (USARTx == UART5) + { + periphclk = rcc_clocks.PCLK1_Frequency; + } +#endif /* UART5 */ + else + { + /* Nothing to do, as error code is already assigned to ERROR value */ + } + + /* Configure the USART Baud Rate : + - valid baud rate value (different from 0) is required + - Peripheral clock as returned by RCC service, should be valid (different from 0). + */ + if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO) + && (USART_InitStruct->BaudRate != 0U)) + { + status = SUCCESS; +#if defined(USART_CR1_OVER8) + LL_USART_SetBaudRate(USARTx, + periphclk, + USART_InitStruct->OverSampling, + USART_InitStruct->BaudRate); +#else + LL_USART_SetBaudRate(USARTx, + periphclk, + USART_InitStruct->BaudRate); +#endif /* USART_OverSampling_Feature */ + + /* Check BRR is greater than or equal to 16d */ + assert_param(IS_LL_USART_BRR_MIN(USARTx->BRR)); + } + } + /* Endif (=> USART not in Disabled state => return ERROR) */ + + return (status); +} + +/** + * @brief Set each @ref LL_USART_InitTypeDef field to default value. + * @param USART_InitStruct Pointer to a @ref LL_USART_InitTypeDef structure + * whose fields will be set to default values. + * @retval None + */ + +void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct) +{ + /* Set USART_InitStruct fields to default values */ + USART_InitStruct->BaudRate = 9600U; + 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; +#if defined(USART_CR1_OVER8) + USART_InitStruct->OverSampling = LL_USART_OVERSAMPLING_16; +#endif /* USART_OverSampling_Feature */ +} + +/** + * @brief Initialize USART Clock related settings according to the + * specified parameters in the USART_ClockInitStruct. + * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0), + * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. + * @param USARTx USART Instance + * @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure + * that contains the Clock configuration information for the specified USART peripheral. + * @retval An ErrorStatus enumeration value: + * - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content + * - ERROR: Problem occurred during USART Registers initialization + */ +ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, const LL_USART_ClockInitTypeDef *USART_ClockInitStruct) +{ + ErrorStatus status = SUCCESS; + + /* Check USART Instance and Clock signal output parameters */ + assert_param(IS_UART_INSTANCE(USARTx)); + assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput)); + + /* USART needs to be in disabled state, in order to be able to configure some bits in + CRx registers */ + if (LL_USART_IsEnabled(USARTx) == 0U) + { + /*---------------------------- USART CR2 Configuration -----------------------*/ + /* If Clock signal has to be output */ + if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE) + { + /* Deactivate Clock signal delivery : + * - Disable Clock Output: USART_CR2_CLKEN cleared + */ + LL_USART_DisableSCLKOutput(USARTx); + } + else + { + /* Ensure USART instance is USART capable */ + assert_param(IS_USART_INSTANCE(USARTx)); + + /* Check clock related parameters */ + assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity)); + assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase)); + assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse)); + + /*---------------------------- USART CR2 Configuration ----------------------- + * Configure USARTx CR2 (Clock signal related bits) with parameters: + * - Enable Clock Output: USART_CR2_CLKEN set + * - Clock Polarity: USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value + * - Clock Phase: USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value + * - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value. + */ + MODIFY_REG(USARTx->CR2, + USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, + USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity | + USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse); + } + } + /* Else (USART not in Disabled state => return ERROR */ + else + { + status = ERROR; + } + + return (status); +} + +/** + * @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value. + * @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure + * whose fields will be set to default values. + * @retval None + */ +void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct) +{ + /* Set LL_USART_ClockInitStruct fields with default values */ + USART_ClockInitStruct->ClockOutput = LL_USART_CLOCK_DISABLE; + USART_ClockInitStruct->ClockPolarity = LL_USART_POLARITY_LOW; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ + USART_ClockInitStruct->ClockPhase = LL_USART_PHASE_1EDGE; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ + USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#endif /* USART1 || USART2 || USART3 || UART4 || UART5 */ + +/** + * @} + */ + +#endif /* USE_FULL_LL_DRIVER */ + + diff --git a/MDK-ARM/motor.uvoptx b/MDK-ARM/motor.uvoptx index 1348ec6..1316bd9 100644 --- a/MDK-ARM/motor.uvoptx +++ b/MDK-ARM/motor.uvoptx @@ -125,7 +125,7 @@ 0 CMSIS_AGDI - -X"" -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) + -X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) 0 @@ -258,6 +258,18 @@ 0 0 0 + ../Core/Src/dma.c + dma.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 ../Core/Src/tim.c tim.c 0 @@ -265,7 +277,19 @@ 2 - 5 + 6 + 1 + 0 + 0 + 0 + ../Core/Src/usart.c + usart.c + 0 + 0 + + + 2 + 7 1 0 0 @@ -285,7 +309,7 @@ 0 3 - 6 + 8 1 0 0 @@ -305,7 +329,7 @@ 0 4 - 7 + 9 1 0 0 @@ -325,7 +349,7 @@ 0 5 - 8 + 10 1 0 0 @@ -337,7 +361,7 @@ 5 - 9 + 11 1 0 0 @@ -349,7 +373,7 @@ 5 - 10 + 12 1 0 0 @@ -361,7 +385,7 @@ 5 - 11 + 13 1 0 0 @@ -373,7 +397,7 @@ 5 - 12 + 14 1 0 0 @@ -385,7 +409,7 @@ 5 - 13 + 15 1 0 0 @@ -397,7 +421,7 @@ 5 - 14 + 16 1 0 0 @@ -409,7 +433,7 @@ 5 - 15 + 17 1 0 0 @@ -429,7 +453,7 @@ 0 6 - 16 + 18 1 0 0 @@ -441,7 +465,7 @@ 6 - 17 + 19 1 0 0 @@ -453,7 +477,7 @@ 6 - 18 + 20 1 0 0 @@ -465,7 +489,7 @@ 6 - 19 + 21 1 0 0 @@ -477,7 +501,7 @@ 6 - 20 + 22 1 0 0 @@ -489,7 +513,7 @@ 6 - 21 + 23 1 0 0 @@ -501,7 +525,7 @@ 6 - 22 + 24 1 0 0 @@ -513,7 +537,7 @@ 6 - 23 + 25 1 0 0 @@ -525,7 +549,7 @@ 6 - 24 + 26 1 0 0 @@ -537,7 +561,7 @@ 6 - 25 + 27 1 0 0 @@ -549,7 +573,7 @@ 6 - 26 + 28 1 0 0 @@ -561,7 +585,7 @@ 6 - 27 + 29 1 0 0 @@ -573,7 +597,7 @@ 6 - 28 + 30 1 0 0 @@ -585,7 +609,7 @@ 6 - 29 + 31 1 0 0 @@ -597,7 +621,7 @@ 6 - 30 + 32 1 0 0 @@ -617,7 +641,7 @@ 0 7 - 31 + 33 1 0 0 @@ -627,30 +651,6 @@ 0 0 - - 7 - 32 - 1 - 0 - 0 - 0 - ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c - stm32f1xx_ll_pwr.c - 0 - 0 - - - 7 - 33 - 1 - 0 - 0 - 0 - ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c - stm32f1xx_ll_exti.c - 0 - 0 - 7 34 @@ -658,23 +658,23 @@ 0 0 0 - ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c - stm32f1xx_ll_tim.c - 0 - 0 - - - 7 - 35 - 1 - 0 - 0 - 0 ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c stm32f1xx_ll_dma.c 0 0 + + 7 + 35 + 1 + 0 + 0 + 0 + ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c + stm32f1xx_ll_pwr.c + 0 + 0 + 7 36 @@ -682,6 +682,30 @@ 0 0 0 + ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c + stm32f1xx_ll_exti.c + 0 + 0 + + + 7 + 37 + 1 + 0 + 0 + 0 + ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c + stm32f1xx_ll_tim.c + 0 + 0 + + + 7 + 38 + 1 + 0 + 0 + 0 ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c stm32f1xx_ll_rcc.c 0 @@ -689,7 +713,7 @@ 7 - 37 + 39 1 0 0 @@ -699,6 +723,18 @@ 0 0 + + 7 + 40 + 1 + 0 + 0 + 0 + ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c + stm32f1xx_ll_usart.c + 0 + 0 + @@ -709,7 +745,7 @@ 0 8 - 38 + 41 1 0 0 @@ -721,7 +757,7 @@ 8 - 39 + 42 1 0 0 diff --git a/MDK-ARM/motor.uvprojx b/MDK-ARM/motor.uvprojx index 8a50db2..10540b2 100644 --- a/MDK-ARM/motor.uvprojx +++ b/MDK-ARM/motor.uvprojx @@ -403,6 +403,62 @@ 1 ../Core/Src/gpio.c + + dma.c + 1 + ../Core/Src/dma.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + tim.c 1 @@ -459,6 +515,62 @@ + + usart.c + 1 + ../Core/Src/usart.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + stm32f1xx_it.c 1 @@ -523,57 +635,6 @@ uarts.c 1 ..\User\system\bsp\uarts.c - - - 2 - 0 - 0 - 0 - 0 - 0 - 0 - 2 - 2 - 2 - 11 - - - 1 - - - - 2 - 0 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 0 - 2 - 2 - 2 - 2 - 2 - 0 - 0 - 2 - 2 - 2 - 2 - 2 - - - - - - - - - i2cs.c @@ -790,6 +851,62 @@ + + stm32f1xx_ll_dma.c + 1 + ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + stm32f1xx_ll_pwr.c 1 @@ -958,62 +1075,6 @@ - - stm32f1xx_ll_dma.c - 1 - ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c - - - 2 - 0 - 0 - 0 - 0 - 1 - 2 - 2 - 2 - 2 - 11 - - - 1 - - - - 2 - 0 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 0 - 2 - 2 - 2 - 2 - 2 - 0 - 0 - 2 - 2 - 2 - 2 - 2 - - - - - - - - - - stm32f1xx_ll_rcc.c 1 @@ -1126,6 +1187,62 @@ + + stm32f1xx_ll_usart.c + 1 + ../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + diff --git a/MDK-ARM/motor/motor.hex b/MDK-ARM/motor/motor.hex index f066dca..3c71829 100644 --- a/MDK-ARM/motor/motor.hex +++ b/MDK-ARM/motor/motor.hex @@ -1,630 +1,502 @@ :020000040800F2 -:10000000801C002005010008250B0008930600084D -:10001000210B00088D060008250D000800000000D7 -:100020000000000000000000000000002B0B000892 -:100030009106000800000000290B00082D0B0008A5 +:10000000801C002005010008C10B0008B301000896 +:10001000BD0B0008710100080D0F00080000000072 +:10002000000000000000000000000000050D0008B6 +:10003000B101000800000000050C0008070D0008D1 :100040001F0100081F0100081F0100081F01000810 :100050001F0100081F0100081F0100081F01000800 :100060001F0100081F0100081F0100081F010008F0 -:100070001F0100081F0100081F0100081F010008E0 +:100070001F0100081F01000891010008A1010008EC :100080001F0100081F0100081F0100081F010008D0 :100090001F0100081F0100081F0100081F010008C0 :1000A0001F0100081F0100081F0100081F010008B0 -:1000B000250C00081F0100081F0100081F0100088F +:1000B000FD0D00081F0100081F0100081F010008B6 :1000C0001F0100081F0100081F0100081F01000890 -:1000D0001F0100081F0100081F0100081F01000880 +:1000D0001F010008FD0E00081F0100081F01000895 :1000E0001F0100081F0100081F010008DFF810D0E1 -:1000F00000F0BAFA0048004785100008AFF300800E +:1000F00000F02CF800480047F9120008AFF3008028 :10010000801C00200648804706480047FEE7FEE7BF :10011000FEE7FEE7FEE7FEE7FEE7FEE7FEE7FEE7B7 -:10012000210C0008ED000008D2B201E000F8012B1C +:10012000F90D0008ED000008D2B201E000F8012B43 :10013000491EFBD270470022F6E710B513460A4667 -:1001400004461946FFF7F0FF204610BDF0B480EAE0 -:100150000102D40F4200B2EB410F02D20246084620 -:1001600011464A0042D0C30DDDB2C1F3C752AD1AE9 -:10017000202D35DAC1F3160141F4000204B15242D8 -:10018000C5F1200602FA06F12A411044B3EBD05F14 -:1001900023D0C4B1012DA0EBC35009DCF0BC4FF05B -:1001A000004202EAC352DBB200F5000000F0D0B911 -:1001B000400000F1807000EBC350A0F1807040EA75 -:1001C000D170490009E0490841EAC071A0EBC35071 -:1001D00000F50000400800EBC350F0BC00F0AFB9E0 -:1001E0006142012202EB4101001BF6E7F0BC7047BF -:1001F00081F00041AAE780F00040A7E780EA010211 -:1002000010B502F00043400022D04A001FD0010E7A -:1002100001EB1261C0F35600C2F3560240F4000035 -:1002200042F40002A0FB022000047F39140400D035 -:10023000401C50EA124001D44000491EC2B20C06D4 -:1002400004EBD010401C4008802A02D003E00020BC -:1002500010BD20F00100002900DA0020184310BD75 -:1002600030B480EA010202F0004530F0004221F093 -:10027000004013D090B1C30DD40DC2F31601C0F3EA -:100280001600E41A41F4000140F400027D3491426A -:1002900001D3641C00E04900002C02DA30BC0020CD -:1002A00070474FF400000023914201D3891A0343A1 -:1002B00040084FEA4101F7D151B1914202D14FF0CC -:1002C000004105E002D24FF0010101E06FF00101B1 -:1002D00003EBC450284430BC00F031B92DE9FE4F87 -:1002E000804681EA0300C00F0C46009021F00041D7 -:1002F00023F00045B8EB0200A94105D24046214653 -:1003000090461C460B46024623F00040104347D05F -:10031000270DC7F30A00C3F30A510290401A019057 -:1003200040286BDAC3F3130040F4801B0098924618 -:1003300020B10023D2EB030A63EB0B0B0198594663 -:10034000C0F14002504600F0C9F806460D4650463E -:100350005946019A00F0E1F810EB080061410024D1 -:1003600087EA115284EAE7731A4340D0009A62B3D5 -:10037000019A012A4FEA075215DC001B61EB0201CA -:100380004FF0004202EA0752CDE90042001C41F55D -:10039000801132462B4600F018F903B0BDE8F08F0B -:1003A00040462146F9E7001B61EB0201001C41F5C4 -:1003B000801300185B412018A2F5001747EB0301DA -:1003C00040EAD570B6196D4111E06D084FEA360666 -:1003D00045EAC0754FEA0752001B61EB0201001CA1 -:1003E00041F5801149084FEA300000195141324669 -:1003F0002B4603B0BDE8F04F00F0D8B800980122BA -:1004000040000023D0EB020263EBE073009821462A -:100410004FEAE074B8EB000061EB0401E9E783F018 -:1004200000435BE781F0004158E796230022114624 -:1004300000F08EB820F00040C10DC0F3160040F46B -:1004400000007F2901DA00207047962903DCC1F102 -:100450009601C8407047963988407047C1F30A52E8 -:1004600010B5C1F3130140F2FF3341F480119A42F9 -:1004700001DA002010BD40F233439A42A2F2334227 -:1004800003DC524200F039F810BD904010BD00F07E -:10049000004230F000400AD0C10D01F56071C0F398 -:1004A000160042EA0151C20840071143704700207C -:1004B00001467047002801DBC0F10040002901DB44 -:1004C000C1F1004181427047002801DBC0F10040CA -:1004D000002901DBC1F1004188427047202A04DB7A -:1004E000203A00FA02F1002070479140C2F1200347 -:1004F00020FA03F3194390407047202A04DB203A86 -:1005000021FA02F00021704721FA02F3D040C2F133 -:1005100020029140084319467047202A06DBCB177A -:10052000203A41FA02F043EAE07306E041FA02F3AE -:10053000D040C2F12002914008431946704700297B -:10054000A8BF7047401C490008BF20F00100704759 -:1005500010B4B0FA80FC00FA0CF050EA010404BFB9 -:1005600010BC704749B1CCF1200421FA04F411FA0F -:100570000CF118BF012121430843A3EB0C01CB1D53 -:100580004FEA00614FEA102042BF002010BC7047C4 -:1005900000EBC35010440029A4BF10BC7047401C9E -:1005A000490008BF20F0010010BC704710B5141EB0 -:1005B00073F1000408DA401C41F1000192185B411C -:1005C0001A4301D120F0010010BD2DE9F04D9246F3 -:1005D0009B4611B1B1FA81F202E0B0FA80F220320A -:1005E0009046FFF77BFF04460F4640EA0A0041EAC7 -:1005F0000B0153465A46084313D0114653EA0100F3 -:1006000019D0C8F140025046FFF777FF05460E4665 -:10061000504659464246FFF761FF084305D0012086 -:1006200004E020463946BDE8F08D0020054346EA47 -:10063000E0762C4337430A986305E40AA0EB0800F0 -:100640000022FD0A44EA47540A3002D50020014640 -:10065000E9E7010510196941DDE90845001969411B -:10066000BDE8F04DA2E70000064C074D06E0E0684B -:1006700040F0010394E8070098471034AC42F6D3E9 -:10068000FFF738FD94260008B426000800BFFEE7F7 -:10069000704700BFFEE7000008B5054989690143BE -:1006A000034A9161114689690140009100BF08BD6C -:1006B000001002402DE9F04102460B461868C0F3D5 -:1006C0000F2595FAA5F0B0FA80F480E00120A04053 -:1006D000284000287AD0082C04D240F2011000FAF9 -:1006E00004F106E0A4F108004FF00116864046F040 -:1006F0008061586808280ED11869D66826EA112644 -:100700000F0A97FAA7F7B7FA87F700FA07F73E43F9 -:10071000D66000BF00BF586802EB116691FAA1FCD9 -:10072000BCFA8CFC4FEA8C084FF00F0C0CFA08FC5A -:10073000376827EA0C0791FAA1FCBCFA8CFC4FEA57 -:100740008C0C00FA0CFC47EA0C07376000BF5868B5 -:10075000012802D05868092838D1986802EB116640 -:1007600091FAA1FCBCFA8CFC4FEA8C084FF0030C08 -:100770000CFA08FC376827EA0C0791FAA1FCBCFACE -:100780008CFC4FEA8C0C00FA0CFC47EA0C07376033 -:1007900000BFD86802EB116691FAA1FCBCFA8CFC90 -:1007A0004FEA8C084FF0040C0CFA08FC376827EA73 -:1007B0000C0791FAA1FCBCFA8CFC4FEA8C0C00FAF5 -:1007C0000CFC47EA0C07376000BF00BF641C25FA29 -:1007D00004F000287FF47AAFBDE8F081024690680B -:1007E000C1F30F231840C1F30F23984201D1012018 -:1007F00070470020FCE7C1F30F2242617047C1F34C -:100800000F2242617047C1F30F220261704770B539 -:1008100000EB116391FAA1F5B5FA85F5AE000F254D -:10082000B5401C68AC4391FAA1F5B5FA85F5AD0069 -:1008300002FA05F52C431C6070BD000002480068F8 -:10084000401C014908607047100000204FF47A7185 -:10085000B0FBF1F2521E4FF0E0235A6100229A6180 -:1008600005221A6100BF7047014908607047000007 -:100870000000002010B5024613681C48824208D0D0 -:10088000B2F1804F05D01A48824202D01948824204 -:1008900004D123F070004C6840EA040313488242FC -:1008A00008D0B2F1804F05D01148824202D01148E1 -:1008B000824204D123F44070CC6840EA0403136000 -:1008C0008868D06200BF0888906200BF07488242F3 -:1008D00003D10869106300BF00BF00BF506940F03A -:1008E0000100506100BF002010BD0000002C01403D -:1008F00000040040000800400146086900F00100C3 -:100900007047000000B585B014216846FFF713FC5E -:100910001020FFF7C1FE2020FFF7BEFE0420FFF7E6 -:10092000BBFE0820FFF7B8FE25492648FFF763FF06 -:1009300040F202212448FFF75EFF24492448FFF7D4 -:100940005AFF1F48009001200190022002900020D1 -:10095000039069461B48FFF7ADFE1E48009000203B -:10096000019069461748FFF7A5FE1B48009000203C -:10097000019069461448FFF79DFE40F20220009066 -:1009800001200190022002900020039069460E4849 -:10099000FFF790FE114800900020019069460C4836 -:1009A000FFF788FE09480090012001900320029083 -:1009B0000020039069460648FFF77CFE05B000BDA5 -:1009C00020002004001001400008014030003004E5 -:1009D000000C0140C000C004FFFD9F04FFFFCF04D6 -:1009E0002DE9F04186B0142101A8FFF7A4FB0120F6 -:1009F0004849C9690143474AD1611146C969014063 -:100A0000009100BF00BF1C21434B1B68C3F30220B1 -:100A10000F2400250346C3F1070CBCF1040F02D9D3 -:100A20004FF0040C01E0C3F1070C674603F1040C1E -:100A3000BCF1070F02D24FF0000C01E0A3F1030C50 -:100A400066464FF0010C0CFA07FCACF1010C0CEA05 -:100A5000040C0CFA06FC4FF0010808FA06F8A8F19D -:100A6000010808EA05084CEA080200BF002904DB77 -:100A70001007030E2948435407E01007040E2648C8 -:100A80000C3001F00F031B1FC45400BF1C200028B2 -:100A900009DB00F01F02012191404209920002F19E -:100AA000E022C2F8001100BF41F61F40ADF804007B -:100AB00000200290632003900020049001A94FF0D1 -:100AC0008040FFF7D7FE00BF4FF08040006820F065 -:100AD00080004FF08041086000BF0020896844F228 -:100AE0000702914301434FF08042916000BF00BF75 -:100AF0001146496821F070010143516000BF00BFF9 -:100B00001046806820F080001146886000BF06B063 -:100B1000BDE8F081001002400CED00E000E400E0D0 -:100B200000BFFEE700BFFEE7704770477047000058 -:100B300010B502203749096821F007010143354A01 -:100B4000116000BF00BF00BF3248006800F007001E -:100B50000228F8D100BF3048006840F480302E49A8 -:100B6000086000BF00BF00BF2B480068C0F34040D2 -:100B70000028F8D04FF480304FF4E011264A526834 -:100B800022F47C1200F440330B431A43224B5A6088 -:100B900000BF00BF1846006840F08070194608602A -:100BA00000BF00BF00BF1C480068C0F340600028C1 -:100BB000F8D000201849496821F0F0010143164A95 -:100BC000516000BF10151146496821F4E0610143EE -:100BD000516000BF00201146496821F46051014373 -:100BE000516000BF02201146496821F00301014312 -:100BF000516000BF00BF00BF0748406800F00C0014 -:100C00000828F8D10548FFF721FE0448FFF72CFE1D -:100C100010BD0000002002400010024000A24A0463 -:100C20007047000010B54FF08040FFF765FE0128C7 -:100C300074D100BF00BF80070069C0F3400068B1F5 -:100C400000BF4FF08040C068C0F3400030B100BF2B -:100C50006FF002008107086100BF00BF00BF4FF0C6 -:100C600080400069C0F3800070B100BF4FF0804049 -:100C7000C068C0F3800038B100BF6FF004004FF0CF -:100C80008041086100BF00BF00BF4FF08040006995 -:100C9000C0F3C00070B100BF4FF08040C068C0F327 -:100CA000C00038B100BF6FF008004FF0804108610C -:100CB00000BF00BF00BF4FF080400069C0F30010CC -:100CC00070B100BF4FF08040C068C0F3001038B171 -:100CD00000BF6FF010004FF08041086100BF00BFFF -:100CE0004FF08040FFF708FE01280DD100BF8007BC -:100CF000C06800F0010038B100BF6FF001004FF094 -:100D00008041086100BF00BF00BFFFF797FD00BF33 -:100D100003480068401C0249086000BF10BD000085 -:100D20006000002000BFFEE702E008C8121F08C1F3 -:100D3000002AFAD170477047002001E001C1121F5C -:100D4000002AFBD170470000014601F1100000E0CD -:100D5000001D02681AB9024A12689042F8D370471F -:100D60002400002010B50648046803E02046FFF781 -:100D7000EBFF0446034800688442F7D310BD00002F -:100D8000200000202400002010B501E000F8011B25 -:100D9000131EA2F10104A2B2F8D110BD00200B492C -:100DA000086000BF00BF4FF08040006840F00100C5 -:100DB0004FF08041086000BF00BF0846C06840F0A7 -:100DC0000100C86000BF00BF7047000004000020A1 -:100DD00010B5024800F020F910BD0000040000200A -:100DE00010B500F01FFD10BD0149086070470000FC -:100DF0000C00002070B5034600224FF0E026756914 -:100E00000D4E366803FB06F44FF0E026B16910E0A2 -:100E10004FF0E026B06988420BD0884202D20E1A09 -:100E2000324402E02E1A0E4432440146A24200D35C -:100E300000E0EDE700BF70BD0C00002010B500BF62 -:100E400001220E490E48FFF7E2FC00BF0B490C4897 -:100E5000FFF7D9FC0B490A48FFF7D5FC0420FFF740 -:100E6000C9FF06490648FFF7CAFC0420FFF7C2FF86 -:100E700004490348FFF7C3FC10BD00001000100434 -:100E8000000C01402000200410B500BF01220E49D3 -:100E90000E48FFF7BCFC00BF0D490C48FFF7AFFC44 -:100EA00009490A48FFF7ABFC0420FFF7A3FF0849F4 -:100EB0000648FFF7A8FC04490448FFF7A4FC0420F7 -:100EC000FFF798FF10BD000010001004000C014057 -:100ED0002000200410B50024082213491348FFF70E -:100EE00096FC11491148FFF78EFC0420FFF782FFA2 -:100EF0000F490E48FFF787FC0420FFF77BFF07E050 -:100F0000601CC4B2FA2C03DDFFF7BEFF002010BD49 -:100F100005490648FFF762FC0028F1D1044903485F -:100F2000FFF76DFC0120F2E710001004000C0140F7 -:100F30002000200470B50446002500BF0122174997 -:100F40001748FFF764FC00BF16491548FFF757FC28 -:100F500000BF1FE0E00920B110491148FFF753FC22 -:100F600003E00E490E48FFF74AFC6006040E02201B -:100F7000FFF740FF0B490A48FFF745FC0220FFF747 -:100F800039FF08490648FFF73AFC0220FFF732FF15 -:100F9000681CC5B2082DDDDB70BD00001000100418 -:100FA000000C01402000200438B5044600208DF8D4 -:100FB00000008DF80140FFF741FF7820FFF7BAFFEE -:100FC000FFF788FF9DF80000FFF7B4FFFFF782FFEF -:100FD0009DF80100FFF7AEFFFFF77CFFFFF754FF1E -:100FE00038BD38B5044640208DF800008DF801402A -:100FF000FFF724FF7820FFF79DFFFFF76BFF9DF8B9 -:101000000000FFF797FFFFF765FF9DF80100FFF76E -:1010100091FFFFF75FFF38BD38B501460020009013 -:10102000086810B1152821D116E000BF124B134CEF -:10103000E068C3F30F2222EA000400EA020544EA52 -:1010400005440E4D2C6100BF00BF0D48006848608C -:1010500000BF1520086000BF094A48681268101ACE -:10106000642801D2002038BD00BFDFE700200860FF -:1010700000900320F7E7000020002004001001404A -:101080006000002008B50120234989690143224AF4 -:101090009161114689690140009100BF00BF0007BE -:1010A0001146C9690143D1611146C96901400091E6 -:1010B00000BF00BF03200246184B19684FF6FF031C -:1010C0001940174B0B4343EA0221144B196000BF30 -:1010D00000BF1448406820F0E06040F00070114903 -:1010E000486000BFFFF724FD0F4800680F49B0FBC0 -:1010F000F1F084B22046FFF777FEFFF703FCFFF71D -:101100006FFC002000F014F8FFF76AFEFFF746FEC0 -:1011100001E0FFF75DFEFCE7001002400CED00E08F -:101120000000FA05000001400000002040420F00CE -:1011300010B504460C4951F824104A000B4951F8E7 -:101140002400002100F036F8094951F8242007490D -:10115000083951F82400002100F02CF8012103483F -:101160000830015510BD0000781900085400002017 -:101170008819000810B501460023002207E00B483B -:1011800050F8210030F8120000B15B1C521C0848D6 -:1011900050F821009042F2D864205843044C54F88F -:1011A0002140B0FBF4F0C0B210BD0000540000209C -:1011B0007819000830B5034601E003F8011B141E3E -:1011C000A2F10102F9D130BD2DE9FF4F83B00746EE -:1011D0000E4692464FF0000B0024A14657A103C9CA -:1011E000CDE9010120E01AF80900203800F0FF0BDA -:1011F0007E2F02DD0027701CC6B200240CE00BEB32 -:101200004B00504901EB4000005D07EBC611214443 -:101210004D4A5054601CC4B2062CF0DBB81DC7B256 -:1012200009F1010000F0FF091AF809000028DAD1DD -:1012300046481099FEF7E2FF0090FFF7FBF8804662 -:1012400000250EE00A20B8FBF0F100FB118040B24F -:10125000C5F1060101AA50540A20B8FBF0F8681C39 -:1012600045B2032DEEDB04250EE00A20B8FBF0F1B9 -:1012700000FB118040B2C5F1060101AA50540A20BA -:10128000B8FBF0F8681C45B2072DEEDB304910982A -:10129000FFF71AF901D800250CE02E491098FFF746 -:1012A00013F901D8012505E000211098FFF70CF98A -:1012B00000D8022522E001A8405D103000F0FF0BAD -:1012C0007E2F02DD0027701CC6B200240CE00BEB61 -:1012D0004B001C4901EB4000005D07EBC6112144A7 -:1012E000194A5054601CC4B2062CF0DBB81DC7B2BA -:1012F00009F1010000F0FF09681C45B2072DDADB97 -:10130000002015E00699203901F0FF0B00240CE0C5 -:101310000BEB4B010B4A02EB4101095D07EBC612D7 -:101320002244094B9954611CCCB2062CF0DB401CC2 -:101330000728E7DB07B0BDE8F08F0000000000FEE3 -:10134000000000007A1A00088014002000007A448F -:101350000000C842000020412DE9F04F87B005464B -:101360000E46174698460020049005900690814648 -:101370000024824600213846FFF79CF807D22D2230 -:101380002046611CCCB204A90A5487F00047F549F5 -:101390003846FFF799F802D207B0BDE8F08FC4F1E4 -:1013A000080000F0FF09F0493846FFF78DF85DD2DC -:1013B000ED493846FEF754FFEC490390FEF7C6FEB0 -:1013C0008346FFF737F8C2B22046611CCCB204A9AD -:1013D0000A543846FFF72EF8C0B242F2107190FB63 -:1013E000F1F201FB12004FF47A7190FBF1F0303012 -:1013F000C2B22046611CCCB204A90A543846FFF799 -:1014000019F8C0B24FF47A7190FBF1F201FB1200AF -:10141000642190FBF1F03030C2B22046611CCCB2A6 -:1014200004A90A543846FFF705F8C0B2642190FBBE -:10143000F1F201FB12000A2190FBF1F03030C2B250 -:101440002046611CCCB204A90A543846FEF7F2FFCC -:10145000C0B20A2190FBF1F201FB12003030C2B29F -:101460002046611CCCB204A90A54CCE0C0493846DD -:10147000FFF72AF84CD23846FEF7DCFFC0B242F242 -:10148000107190FBF1F201FB12004FF47A7190FBA6 -:10149000F1F03030C2B22046611CCCB204A90A542B -:1014A0003846FEF7C7FFC0B24FF47A7190FBF1F2F5 -:1014B00001FB1200642190FBF1F03030C2B22046F3 -:1014C000611CCCB204A90A543846FEF7B3FFC0B27F -:1014D000642190FBF1F201FB12000A2190FBF1F074 -:1014E0003030C2B22046611CCCB204A90A5438463E -:1014F000FEF7A0FFC0B20A2190FBF1F201FB12003F -:101500003030C2B22046611CCCB204A90A547AE041 -:1015100098493846FEF7D8FF37D23846FEF78AFF9B -:10152000C0B24FF47A7190FBF1F201FB120064211A -:1015300090FBF1F03030C2B22046611CCCB204A95D -:101540000A543846FEF776FFC0B2642190FBF1F2F0 -:1015500001FB12000A2190FBF1F03030C2B22046AC -:10156000611CCCB204A90A543846FEF763FFC0B22E -:101570000A2190FBF1F201FB12003030C2B220468A -:10158000611CCCB204A90A543DE07B493846FEF701 -:101590009BFF23D23846FEF74DFFC0B2642190FB7B -:1015A000F1F201FB12000A2190FBF1F03030C2B2DF -:1015B0002046611CCCB204A90A543846FEF73AFF13 -:1015C000C0B20A2190FBF1F201FB12003030C2B22E -:1015D0002046611CCCB204A90A5414E0002138460C -:1015E000FEF772FF0FD83846FEF724FFC0B20A217B -:1015F00090FBF1F201FB12003030C2B22046611CB8 -:10160000CCB204A90A54B8F1000F71DD072C6FDACF -:101610002E222046611CCCB204A90A543846FEF79B -:1016200009FF00F0FF0B5846FEF7FFFE3946039016 -:10163000FEF7E1FD0746B8F1010F20D1082C1EDAB4 -:101640004D493846FEF7DAFD07463846FEF71FFFDC -:1016500000224A4BCDE90001FEF740FECDE9020130 -:10166000FEF7FCFEC0B20A2190FBF1F201FB120072 -:101670003030C2B22046611CCCB204A90A54B8F181 -:10168000020F35DB082C33DA3A493846FEF7B6FD4F -:1016900007463846FEF7CEFEC0B2642190FBF1F259 -:1016A00001FB12000A2190FBF1F03030C2B220465B -:1016B000611CCCB204A90A54082C19DA3846FEF78A -:1016C000E6FE00222D4BCDE90001FEF707FECDE935 -:1016D0000201FEF7C3FEC0B20A2190FBF1F201FB4A -:1016E00012003030C2B22046611CCCB204A90A54A8 -:1016F00031E004A810F80A00203800F0FF09782D26 -:1017000002DD0025701CC6B200240AE004EB0910BB -:101710001B49085C05EBC61121441A4A5054601C51 -:10172000C4B2082CF2DB00240CE004EB09100830F2 -:101730001349095C701C05EBC0102044114A115478 -:10174000601CC4B2082CF0DB05F10800C5B20AF138 -:10175000010000F0FF0A04A810F80A000028C8D110 -:1017600000BF19E60000FA4600401C460000404257 -:1017700000007A440000C842000020410000E03F21 -:10178000A21C000880140020F0B503461446002275 -:101790000020002530E0665D203EF2B2782B02DDAD -:1017A00000234E1CF1B200200CE000EB0216144F97 -:1017B000BE5D03EBC1170744DFF848C00CF80760B3 -:1017C000461CF0B20828F0DB00200EE000EB021609 -:1017D00008360B4FBF5D4E1C03EBC6160644DFF800 -:1017E00024C00CF80670461CF0B20828EEDB03F1AA -:1017F0000806F3B26E1CF5B2665D002ECBD1F0BDCB -:10180000A21C00088014002010B504464FF480622A -:1018100021460348FFF7B8FA00F080F810BD000039 -:101820008014002010B5AE20FFF7BEFB2020FFF78C -:10183000BBFB1020FFF7B8FBC820FFF7B5FB00206B -:10184000FFF7B2FB1020FFF7AFFB4020FFF7ACFB28 -:101850008120FFF7A9FBFF20FFF7A6FBA120FFF7E0 -:10186000A3FBA620FFF7A0FBA820FFF79DFB3F20CE -:10187000FFF79AFBA420FFF797FBD320FFF794FB19 -:101880000020FFF791FBD520FFF78EFBF020FFF73C -:101890008BFBD920FFF788FB2220FFF785FBDA209E -:1018A000FFF782FB1220FFF77FFBDB20FFF77CFBBB -:1018B0002020FFF779FB8D20FFF776FB1420FFF740 -:1018C00073FBAF20FFF770FB0020FFF79DFF00F0D8 -:1018D00001F810BD08B50BA200210846FFF754FF20 -:1018E00002230A4A00212820FFF736FD0848562324 -:1018F00008A2032100900020FFF766FC00F00EF81C -:1019000008BD00005445535400000000F62874C17F -:101910000000C0412040414443313A0070B50024EA -:1019200018E004F1B001C8B2FFF73EFB0120FFF759 -:101930003BFB1020FFF738FB002507E005EBC41147 -:10194000064A505CFFF74DFB681CC5B2802DF5DBE5 -:10195000601CC4B2082CE4DB70BD000080140020C1 -:101960005F6C697374006C69737420616C6C2063C4 -:101970006F6D6D616E6400000002000000000000E9 -:101980000800000008000000001000000000000037 -:10199000081C3044586C800000000004040400005F -:1019A000080000000800000800000008000204060B -:1019B000080A0C0001020304050600F808888808DC -:1019C000080000E010080810E00000192120201194 -:1019D0000E00000F102020100F001060028C0080FD -:1019E00000F0020418000080000004047E010807D3 -:1019F000003F4040404078000700202424A4FE23FC -:101A0000222000F8080808F8000010080601FF016D -:101A10000600003F1010103F0000109453321E3299 -:101A20005210007E4242427E0000000000FF494901 -:101A30004949494949FF0000000008CC4A49484A41 -:101A4000CC18007F88888482E00000FF1212529236 -:101A50007F00007E88888482E00000000000000093 -:101A6000000000000000000000000000363600000A -:101A70000000000000000000000000000000000066 -:101A80000000002F000000000700070000147F1472 -:101A90007F1400242A7F2A12006264081323003670 -:101AA0004955225000000503000000001C2241009F -:101AB000000041221C000014083E08140008083EE3 -:101AC0000808000000A060000008080808080000DE -:101AD00060600000002010080402003E5149453EAD -:101AE0000000427F400000426151494600214145CB -:101AF0004B31001814127F10002745454539003C32 -:101B00004A494930000171090503003649494936FF -:101B100000064949291E00003636000000005636EE -:101B200000000008142241000014141414140000D2 -:101B30004122140800020151090600324959513E60 -:101B4000007C1211127C007F49494936003E414118 -:101B50004122007F4141221C007F49494941007FC9 -:101B600009090901003E4149497A007F0808087FB8 -:101B70000000417F4100002040413F01007F0814E8 -:101B80002241007F40404040007F020C027F007FE6 -:101B90000408107F003E4141413E007F09090906CB -:101BA000003E4151215E007F0919294600464949FE -:101BB00049310001017F0101003F4040403F001FCB -:101BC0002040201F003F4038403F0063140814634A -:101BD00000070870080700615149454300007F4134 -:101BE000410000552A552A55000041417F0000045C -:101BF0000201020400404040404000000102040095 -:101C0000002054545478007F4844443800384444F9 -:101C1000442000384444487F003854545418000885 -:101C20007E0901020018A4A4A47C007F08040478A3 -:101C30000000447D4000004080847D00007F10282B -:101C400044000000417F4000007C04180478007CC0 -:101C50000804047800384444443800FC2424241840 -:101C60000018242418FC007C08040408004854547C -:101C7000542000043F444020003C4040207C001C95 -:101C80002040201C003C4030403C004428102844A8 -:101C9000001CA0A0A07C004464544C4414141414F0 -:101CA000141400000000000000000000000000000C -:101CB0000000000000F800000000000000333000C9 -:101CC000000000100C06100C0600000000000000D0 -:101CD000000040C07840C0784000043F04043F0446 -:101CE0000400007088FC08300000001820FF211E4E -:101CF0000000F008F000E018000000211C031E2185 -:101D00001E0000F00888700000001E2123241927FF -:101D1000211010160E00000000000000000000005E -:101D20000000000000E01804020000000007182076 -:101D3000400000020418E0000000004020180700E6 -:101D40000000404080F0804040000202010F01028C -:101D50000200000000F0000000000101011F01016D -:101D60000100000000000000000080B070000000D2 -:101D7000000000000000000000000001010101015E -:101D800001010000000000000000003030000000F1 -:101D900000000000000080601804006018060100C8 -:101DA000000000E010080810E000000F10202010D4 -:101DB0000F00001010F8000000000020203F20203D -:101DC00000000070080808887000003028242221D4 -:101DD000300000300888884830000018202020118A -:101DE0000E000000C02010F8000000070424243F6B -:101DF000240000F808888808080000192120201114 -:101E00000E0000E0108888180000000F112020113B -:101E10000E0000380808C83808000000003F000025 -:101E200000000070880808887000001C2221212210 -:101E30001C0000E010080810E00000003122221110 -:101E40000F00000000C0C0000000000000303000A3 -:101E50000000000000800000000000008060000022 -:101E6000000000008040201008000001020408105B -:101E7000200040404040404040000404040404046A -:101E80000400000810204080000000201008040218 -:101E90000100007048080808F0000000003036011A -:101EA0000000C030C828E810E000071827242314D9 -:101EB0000B000000C038E0000000203C2302022795 -:101EC000382008F8888888700000203F20202011E2 -:101ED0000E00C0300808080838000718202020101D -:101EE000080008F808080810E000203F2020201013 -:101EF0000F0008F88888E8081000203F20202320E1 -:101F0000180008F88888E8081000203F2000030027 -:101F10000000C03008080838000007182020221EE2 -:101F2000020008F808000008F808203F21010121FC -:101F30003F20000808F8080800000020203F20206B -:101F4000000000000808F8080800C08080807F00BA -:101F5000000008F888C028180800203F2001263813 -:101F6000200008F8080000000000203F202020206A -:101F7000300008F8F800F8F80800203F003F003F64 -:101F8000200008F830C00008F808203F200007189B -:101F90003F00E01008080810E0000F10202020107B -:101FA0000F0008F808080808F000203F210101018F -:101FB0000000E01008080810E0000F182424385032 -:101FC0004F0008F8888888887000203F2000030CA4 -:101FD00030200070880808083800003820212122AD -:101FE0001C00180808F8080818000000203F20000E -:101FF000000008F808000008F808001F2020202032 -:102000001F000878880000C83808000007380E0153 -:102010000000F80800F80008F800033C0700073C3F -:102020000300081868808068180820302C03032CEF -:1020300030200838C800C83808000000203F2000C1 -:10204000000010080808C838080020382621202081 -:102050001800000000FE020202000000007F404065 -:102060004000000C30C000000000000000010638F5 -:10207000C00000020202FE000000004040407F005D -:102080000000000004020202040000000000000042 -:102090000000000000000000000080808080808040 -:1020A0008080000202040000000000000000000028 -:1020B000000000008080808000000019242222227D -:1020C0003F2008F8008080000000003F1120201110 -:1020D0000E000000008080800000000E11202020F3 -:1020E0001100000000808088F800000E11202010F0 -:1020F0003F200000808080800000001F22222222DA -:102100001300008080F0888888180020203F20205D -:1021100000000000808080808000006B9494949385 -:10212000600008F8008080800000203F210000202F -:102130003F2000809898000000000020203F2020D1 -:102140000000000000809898000000C08080807F20 -:10215000000008F8000080808000203F24022D301D -:102160002000000808F8000000000020203F202088 -:1021700000008080808080808000203F20003F2001 -:10218000003F8080008080800000203F21000020F0 -:102190003F200000808080800000001F2020202041 -:1021A0001F00808000808000000080FFA12020119F -:1021B0000E000000008080808000000E112020A012 -:1021C000FF80808080008080800020203F212000D0 -:1021D00001000000808080808000003324242424BB -:1021E0001900008080E0808000000000001F202097 -:1021F00000008080000000808000001F2020201050 -:102200003F20808080000080808000010E30080622 -:10221000010080800080008080800F300C030C3033 -:102220000F0000808000808080000020312E0E3161 -:102230002000808080000080808080818E70180661 -:10224000010000808080808080000021302C2221CD -:10225000300000000000807C020200000000003F0F -:10226000404000000000FF00000000000000FF00F0 -:1022700000000002027C800000000040403F00009F -:10228000000000060101020204040000000000003A -:1022900000000003050911FF118905C300E000F0EB -:1022A00000F8000000000000004428FF11AA4400CC -:1022B000000000000000000000000000000000001E -:1022C000000000000000000000000000000000000E -:1022D00000000000000000000000000000000000FE -:1022E00000000000000000000000000083013844EE -:1022F000829292740183000000000000007C44C7B9 -:10230000017D7D7D7D017D7D7D7D017D7D7D7D01ED -:10231000FF000000000000010001000100010001B9 -:1023200000010000000000000000000101000000AA -:10233000000000000000000000000000000000009D -:10234000000000000000000000000000000000008D -:10235000000000000000000000000000000000007D -:10236000000000000000000000000000010100006B -:10237000000000000101000000000000000000015A -:10238000010101010101010101010101010101013D -:1023900001000000000000000000004040404040FC -:1023A00000006D6D6D6D6D0000606060606000002C -:1023B00040404040400000000000000000000000DD -:1023C000000000000000000000000000000000000D -:1023D00000000000000000000000000000000000FD -:1023E00000000000000000000000000000000000ED -:1023F00000000000000000000000000000000000DD -:1024000000000000000000000000000000000000CC -:102410000000000000000000000000DBDBDBDBDB75 -:102420000000DBDBDBDBDB0000DBDBDBDBDB00001E -:10243000DBDBDBDBDB0000DADADADADA0000D8D863 -:10244000D8D8D80000C0C0C0C0C00000C0C0C0C044 -:10245000C00000C0C0C0C0C00000C0C0C0C0C0003C -:1024600000808080808000000000000000000000EC -:10247000000000000000000000000000000000005C -:10248000000000000000000000000000000000004C -:10249000000000000000000000000006060606061E -:1024A00000000606060606000006060606060000F0 -:1024B00006060606060000060606E6662000060674 -:1024C00086060600000606060686000006060606C4 -:1024D000060000868686868680808686068686C07A -:1024E000C08686860606D0307606060606000006FA -:1024F0000606060600000606060606000006060694 -:1025000006060000060606060600000000000000A1 -:1025100000000000000000000000000000000000BB -:1025200000000000000000000000000000000000AB -:10253000000000000000000000000000601C00FE21 -:1025400000010200C41820029E63B20E00FF8181C8 -:10255000FF00008040300F00000000FF0023EAAAC7 -:10256000BFAAEA033F00FF000000000000000000D7 -:10257000000000000000000000000000000000005B -:10258000000000000000000000000000000000004B -:10259000000000000080808000000000008080803B -:1025A000000000000000000000000000000000002B -:1025B000000000000000000000000E0C08000001F8 -:1025C0000101010100000001000000010081808084 -:1025D0008180818080808001010101000000010074 -:1025E000000001000101090C0E00000000000000C5 -:1025F00000000000000000000000C0C0C0C0C0C05B -:10260000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0CA -:10261000C000001E21404050215E001E214040505D -:10262000215E00000000000000000000000000002B -:10263000000000000000000000000000000000009A -:1026400000000000000000000000000000FFFFC1CB -:10265000C1FFFFC1C1FFFF0000000000000000003B -:10266000000000000000000000000000000000006A -:1026700000000000000000000000FFFF80FCF3EFFE -:10268000F3FC80FF80EEEEEEF5FBFF9CBEB6B68855 -:10269000FF000000B42600080000002074000000C5 -:1026A000280D000828270008740000200C1C0000DA -:1026B000380D00080024F4000000000000000000B5 -:1026C000000000000000000000000000000000000A -:1026D00000000000000000000000000000000000FA -:1026E00000000000000000000000000000000000EA -:1026F0000000000000000000311100087511000802 -:1027000080000020400000208010002042000020B7 -:1027100000000000000000006019000866190008B1 -:08272000C6E533B4650D0008A5 +:1001400004461946FFF7F0FF204610BD064C074D48 +:1001500006E0E06840F0010394E807009847103497 +:10016000AC42F6D3FFF7C6FF8C1E0008AC1E000899 +:1001700000BFFEE770B504460D4600BF2CB901F084 +:100180004FFA01E000BF00BFFCE700BF012070BDD7 +:1001900010B50248006801F0D2FA10BD64000020DA +:1001A00010B50248006801F0CAFA10BD64000020D2 +:1001B000704700BFFEE7000008B5054989690143A3 +:1001C000034A9161114689690140009100BF08BD51 +:1001D0000010024008B5054989690143034A91614D +:1001E000114689690140009100BF08BD001002401E +:1001F00010B54A1E044B9A5C825822F001034A1E35 +:10020000014CA25C835010BD301E000810B54A1E80 +:10021000044B9A5C825842F001034A1E014CA25CD6 +:10022000835010BD301E000810B54A1E044B9A5C66 +:10023000825842F002034A1E014CA25C835010BD5A +:10024000301E000830B54B1E054CE35CC35823F448 +:10025000405313434C1E024D2C5D035130BD000032 +:10026000EE1D000830B54B1E064CE35C03445B6892 +:100270006FF30F0313434C1E024D2C5D0444636067 +:1002800030BD0000301E000830B54B1E054CE35C4D +:10029000C35844F21004A34313434C1E014D2C5D7C +:1002A000035130BDEE1D000810B54B1E024CE35C3F +:1002B0000344DA6010BD0000301E000830B54B1E4C +:1002C000054CE35CC35823F0800313434C1E024DDE +:1002D0002C5D035130BD0000EE1D000830B54B1EF3 +:1002E000054CE35CC35823F4406313434C1E024D9A +:1002F0002C5D035130BD0000EE1D000830B54B1ED3 +:10030000054CE35CC35823F0200313434C1E024DFD +:100310002C5D035130BD0000EE1D000810B54B1ED2 +:10032000024CE35C03449A6010BD0000301E0008DC +:1003300030B54B1E054CE35CC35823F04003134318 +:100340004C1E024D2C5D035130BD0000EE1D000817 +:1003500030B54B1E054CE35CC35823F44073134384 +:100360004C1E024D2C5D035130BD0000EE1D0008F7 +:100370002DE9F04102460B461868C0F30F2595FAA7 +:10038000A5F0B0FA80F480E00120A04028400028C9 +:100390007AD0082C04D240F2011000FA04F106E0F1 +:1003A000A4F108004FF00116864046F080615868BD +:1003B00008280ED11869D66826EA11260F0A97FA7E +:1003C000A7F7B7FA87F700FA07F73E43D66000BFF2 +:1003D00000BF586802EB116691FAA1FCBCFA8CFCD4 +:1003E0004FEA8C084FF00F0C0CFA08FC376827EA2C +:1003F0000C0791FAA1FCBCFA8CFC4FEA8C0C00FAB9 +:100400000CFC47EA0C07376000BF5868012802D08F +:100410005868092838D1986802EB116691FAA1FC56 +:10042000BCFA8CFC4FEA8C084FF0030C0CFA08FC69 +:10043000376827EA0C0791FAA1FCBCFA8CFC4FEA5A +:100440008C0C00FA0CFC47EA0C07376000BFD86838 +:1004500002EB116691FAA1FCBCFA8CFC4FEA8C0805 +:100460004FF0040C0CFA08FC376827EA0C0791FAE5 +:10047000A1FCBCFA8CFC4FEA8C0C00FA0CFC47EA9D +:100480000C07376000BF00BF641C25FA04F0002889 +:100490007FF47AAFBDE8F08102469068C1F30F2384 +:1004A0001840C1F30F23984201D10120704700206A +:1004B000FCE7C1F30F2242617047C1F30F22426192 +:1004C0007047C1F30F220261704770B500EB1163F2 +:1004D00091FAA1F5B5FA85F5AE000F25B5401C6877 +:1004E000AC4391FAA1F5B5FA85F5AD0002FA05F530 +:1004F0002C431C6070BD000002480068401C01498C +:1005000008607047100000204FF47A71B0FBF1F2E0 +:10051000521E4FF0E0235A6100229A6105221A61AF +:1005200000BF704710B5044600F0A2FB20602068B1 +:1005300000F06AFB6060606800F076FBA0606068B5 +:1005400000F084FBE06010BD0149086070470000C6 +:100550000000002010B5024613681C48824208D0F3 +:10056000B2F1804F05D01A48824202D01948824227 +:1005700004D123F070004C6840EA0403134882421F +:1005800008D0B2F1804F05D01148824202D0114804 +:10059000824204D123F44070CC6840EA0403136023 +:1005A0008868D06200BF0888906200BF0748824216 +:1005B00003D10869106300BF00BF00BF506940F05D +:1005C0000100506100BF002010BD0000002C014060 +:1005D00000040040000800400146086900F00100E6 +:1005E000704708B50168009100BF4168009100BFE5 +:1005F00008BD6FF040010160704700002DE9FF4128 +:1006000004460D4601270026204600F055F8002834 +:1006100033D1E9686868084329690843E16841F211 +:100620000C6291430843E060A868216921F44051BD +:100630000143216100BF6869616921F44071014390 +:10064000616100BF6846FFF76DFF0E48844201D12B +:10065000039E08E00C48844201D1029E03E00B484F +:10066000844200D1029E46B1286830B1002731464D +:1006700020462A6800F025F800BF384604B0BDE8DF +:10068000F081000000380140004400400048004074 +:1006900001460868C0F34000704701460868C0F38F +:1006A0008000704701460868C0F3C00070470146EB +:1006B0000868C0F3801070470146C868C0F3403036 +:1006C000704770B501EBC10303EB01139400B3FB5A +:1006D000F4F301EBC10404EB01149500B4FBF5F451 +:1006E0006425B4FBF5F404EBC40505EB0414A3EB9B +:1006F0008403322404EB03136424B3FBF4F303F008 +:10070000F00301EBC10404EB01149500B4FBF5F414 +:100710006425B4FBF5F403EB041401EBC10303EB14 +:1007200001139500B3FBF5F301EBC10505EB0115D2 +:100730009600B5FBF6F56426B5FBF6F505EBC506A8 +:1007400006EB0515A3EB8503322505EB03136425A2 +:10075000B3FBF5F303F00F0323449BB2836070BD3A +:1007600038B50120144949690143134A51611146C2 +:1007700049690140009100BF00BF00F0D7FB05466A +:100780000022114600F01EFA044621460E2000F019 +:10079000D5FB0E2000F0BCFB00F0C8FB0546002294 +:1007A000114600F00FFA044621460F2000F0C6FB68 +:1007B0000F2000F0ADFB38BD0010024000B585B041 +:1007C00014216846FFF7B7FC1020FFF7F5FC202046 +:1007D000FFF7F2FC0420FFF7EFFC0820FFF7ECFC2A +:1007E00025492648FFF765FE40F202212448FFF71D +:1007F00060FE24492448FFF75CFE1F48009001205A +:100800000190022002900020039069461B48FFF7E8 +:10081000AFFD1E4800900020019069461748FFF781 +:10082000A7FD1B4800900020019069461448FFF77F +:100830009FFD40F2022000900120019002200290D2 +:100840000020039069460E48FFF792FD1148009082 +:100850000020019069460C48FFF78AFD0948009086 +:100860000120019003200290002003906946064871 +:10087000FFF77EFD05B000BD200020040010014000 +:100880000008014030003004000C0140C000C004EA +:10089000FDFD9904FFFFCF042DE9F04186B014213E +:1008A00001A8FFF748FC01204849C9690143474AAC +:1008B000D1611146C9690140009100BF00BF1C21F0 +:1008C000434B1B68C3F302200F2400250346C3F1EA +:1008D000070CBCF1040F02D94FF0040C01E0C3F186 +:1008E000070C674603F1040CBCF1070F02D24FF06E +:1008F000000C01E0A3F1030C66464FF0010C0CFA6A +:1009000007FCACF1010C0CEA040C0CFA06FC4FF0ED +:10091000010808FA06F8A8F1010808EA05084CEAF7 +:10092000080200BF002904DB1007030E29484354C6 +:1009300007E01007040E26480C3001F00F031B1FC0 +:10094000C45400BF1C20002809DB00F01F02012155 +:1009500091404209920002F1E022C2F8001100BF6A +:1009600041F61F40ADF80400002002906320039080 +:100970000020049001A94FF08040FFF7EBFD00BF7D +:100980004FF08040006820F080004FF08041086008 +:1009900000BF0020896844F20702914301434FF0F1 +:1009A0008042916000BF00BF1146496821F070018C +:1009B0000143516000BF00BF1046806820F08000F6 +:1009C0001146886000BF06B0BDE8F081001002400B +:1009D0000CED00E000E400E02DE9F0418CB01C21BA +:1009E00005A8FFF7A8FB14216846FFF7A4FB4FF406 +:1009F0008040FFF7EFFB0420FFF7ECFB6848009016 +:100A00000920019003200290002003906946654868 +:100A1000FFF7AEFC644800900420019069466148ED +:100A2000FFF7A6FC002205216048FFF72DFC0022FD +:100A300005215E48FFF706FC002205215B48FFF711 +:100A40005DFC002205215948FFF772FC8022052138 +:100A50005648FFF733FC002205215448FFF778FC85 +:100A6000002205215148FFF739FC102204214F488C +:100A7000FFF70AFC002204214C48FFF7E3FB0022A9 +:100A800004214A48FFF73AFC002204214748FFF7B7 +:100A90004FFC802204214548FFF710FC002204216E +:100AA0004248FFF755FC002204214048FFF716FC9E +:100AB00025213F4B1B68C3F3022000242546034633 +:100AC000C3F1070CBCF1040F02D94FF0040C01E094 +:100AD000C3F1070C674603F1040CBCF1070F02D207 +:100AE0004FF0000C01E0A3F1030C66464FF0010C3F +:100AF0000CFA07FCACF1010C0CEA040C0CFA06FC35 +:100B00004FF0010808FA06F8A8F1010808EA0508FC +:100B10004CEA080200BF002904DB1007030E254839 +:100B2000435407E01007040E21480C3001F00F0376 +:100B30001B1FC45400BF2520002809DB00F01F0242 +:100B4000012191404209920002F1E022C2F8001115 +:100B500000BF4FF4E1300590002006900790089008 +:100B60000C20099000200A900B9005A91248FFF76D +:100B700045FD00BF1048006920F490400E4908610F +:100B80000846406920F02A00486100BF00BF0846BF +:100B9000C06840F40050C86000BF0CB0BDE8F081F0 +:100BA00002000204000801400400040400000240A6 +:100BB0000CED00E000E400E00038014000BFFEE77B +:100BC00000BFFEE7F0B503460C4603F00701C1F194 +:100BD0000700042801D9042001E0C1F107000646FE +:100BE000081D072801D2002000E0C81E054601208C +:100BF000B040401E2040A8400127AF407F1E174054 +:100C00003843F0BD70470000014600BF044840680B +:100C100000F0F0000009034A125C21FA02F070476C +:100C200000100240181E0008014600BF0548406839 +:100C300000F4E060044A02EB1020027821FA02F08E +:100C40007047000000100240281E0008014600BF47 +:100C50000548406800F46050044A02EBD020027856 +:100C600021FA02F07047000000100240281E000820 +:100C700010B5002400BF0B48406800F00C0020B104 +:100C8000042804D0082808D103E0074C07E0064CEC +:100C900005E000F00BF8044601E0034C00BF00BF84 +:100CA000204610BD0010024000127A0000210022F0 +:100CB00000BF1148406800F4803002461AB1B2F516 +:100CC000803F0CD101E00D490BE000BF0A484068AD +:100CD000C0F34040401C0A4BB3FBF0F101E0074970 +:100CE00000BF00BF00BF0448406800F4701002233A +:100CF00003EB9040484370470010024000093D005C +:100D000000127A007047704710B502203749096811 +:100D100021F007010143354A116000BF00BF00BF49 +:100D20003248006800F007000228F8D100BF3048C0 +:100D3000006840F480302E49086000BF00BF00BF4B +:100D40002B480068C0F340400028F8D04FF48030B2 +:100D50004FF4E011264A526822F47C1200F440332A +:100D60000B431A43224B5A6000BF00BF184600686D +:100D700040F080701946086000BF00BF00BF1C48EB +:100D80000068C0F340600028F8D000201849496886 +:100D900021F0F0010143164A516000BF10151146C1 +:100DA000496821F4E0610143516000BF0020114611 +:100DB000496821F460510143516000BF022011468F +:100DC000496821F003010143516000BF00BF00BF2B +:100DD0000748406800F00C000828F8D10548FFF7E4 +:100DE00093FB0448FFF7B0FB10BD00000020024059 +:100DF0000010024000A24A047047000010B54FF0F6 +:100E00008040FFF7E9FB012874D100BF00BF8007D5 +:100E10000069C0F3400068B100BF4FF08040C06877 +:100E2000C0F3400030B100BF6FF0020081070861DD +:100E300000BF00BF00BF4FF080400069C0F38000DA +:100E400070B100BF4FF08040C068C0F3800038B17F +:100E500000BF6FF004004FF08041086100BF00BF89 +:100E600000BF4FF080400069C0F3C00070B100BF08 +:100E70004FF08040C068C0F3C00038B100BF6FF0D1 +:100E800008004FF08041086100BF00BF00BF4FF075 +:100E900080400069C0F3001070B100BF4FF0804087 +:100EA000C068C0F3001038B100BF6FF010004FF001 +:100EB0008041086100BF00BF4FF08040FFF78CFB0E +:100EC00001280DD100BF8007C06800F0010038B1D3 +:100ED00000BF6FF001004FF08041086100BF00BF0C +:100EE00000BFFFF709FB00BF03480068401C024930 +:100EF000086000BF10BD00006000002010B502486F +:100F0000006800F047FD10BD6400002000BFFEE750 +:100F1000002809DB00F01F020121914042099200E4 +:100F200002F1E022C2F80011704700000248006898 +:100F3000C0F30220704700000CED00E010B500285F +:100F400004DB0A07130E054A135406E00A07140EC1 +:100F5000034A00F00F031B1FD45410BD00E400E04F +:100F600018ED00E002E008C8121F08C1002AFAD1FB +:100F700070477047002001E001C1121F002AFBD119 +:100F800070470000014601F1100000E0001D0268FA +:100F90001AB9024A12689042F8D370472400002020 +:100FA00010B50648046803E02046FFF7EBFF04464F +:100FB000034800688442F7D310BD000020000020E1 +:100FC0002400002010B504462146002000F084FAD9 +:100FD00010BD10B501E000F8011B131EA2F10104C1 +:100FE000A2B2F8D110BD10B501E000F8011B131E2C +:100FF000A2F10104A2B2F8D110BD000000200B49FB +:10100000086000BF00BF4FF08040006840F0010062 +:101010004FF08041086000BF00BF0846C06840F044 +:101020000100C86000BF00BF70470000040000203E +:1010300010B5024800F022F910BD000004000020A5 +:1010400010B500F077FC00F073FA10BD014908609C +:10105000704700000C00002070B5034600224FF0DE +:10106000E02675690D4E366803FB06F44FF0E02666 +:10107000B16910E04FF0E026B06988420BD0884299 +:1010800002D20E1A324402E02E1A0E4432440146B5 +:10109000A24200D300E0EDE700BF70BD0C000020CD +:1010A00010B500BF01220E490E48FFF70EFA00BF2F +:1010B0000B490C48FFF705FA0B490A48FFF701FAFC +:1010C0000420FFF7C9FF06490648FFF7F6F9042098 +:1010D000FFF7C2FF04490348FFF7EFF910BD000016 +:1010E00010001004000C01402000200410B500BFC7 +:1010F00001220E490E48FFF7E8F900BF0D490C48E0 +:10110000FFF7DBF909490A48FFF7D7F90420FFF791 +:10111000A3FF08490648FFF7D4F904490448FFF73C +:10112000D0F90420FFF798FF10BD00001000100454 +:10113000000C01402000200410B5002408221349AF +:101140001348FFF7C2F911491148FFF7BAF9042013 +:10115000FFF782FF0F490E48FFF7B3F90420FFF7AE +:101160007BFF07E0601CC4B2FA2C03DDFFF7BEFF73 +:10117000002010BD05490648FFF78EF90028F1D17F +:1011800004490348FFF799F90120F2E71000100421 +:10119000000C01402000200470B50446002500BF6B +:1011A000012217491748FFF790F900BF1649154863 +:1011B000FFF783F900BF1FE0E00920B11049114893 +:1011C000FFF77FF903E00E490E48FFF776F9600656 +:1011D000040E0220FFF740FF0B490A48FFF771F9A0 +:1011E0000220FFF739FF08490648FFF766F9022099 +:1011F000FFF732FF681CC5B2082DDDDB70BD0000B3 +:1012000010001004000C01402000200438B50446F2 +:1012100000208DF800008DF80140FFF741FF782095 +:10122000FFF7BAFFFFF788FF9DF80000FFF7B4FF54 +:10123000FFF782FF9DF80100FFF7AEFFFFF77CFF8D +:10124000FFF754FF38BD38B5044640208DF8000044 +:101250008DF80140FFF724FF7820FFF79DFFFFF78F +:101260006BFF9DF80000FFF797FFFFF765FF9DF804 +:101270000100FFF791FFFFF75FFF38BD38B5044667 +:1012800000200090206810B1152826D116E000BF7C +:101290001448154BDA68C0F30F2121EA020302EA71 +:1012A000010543EA0543104D2B6100BF00BF0F4805 +:1012B0000068606000BF1520206000BF0B496068B7 +:1012C0000968081A642801D2002038BD00BF00BF99 +:1012D000062107A000F0F8FCDAE70020206000906B +:1012E0000320F2E7200020040010014060000020ED +:1012F00069646C650D0A000008B5012025498969FB +:101300000143244A9161114689690140009100BF5F +:1013100000BF00071146C9690143D1611146C9697F +:101320000140009100BF00BF032002461A4B19681C +:101330004FF6FF031940194B0B4343EA0221164BAA +:10134000196000BF00BF1648406820F0E06040F020 +:1013500000701349486000BFFFF7D6FC11480068D1 +:101360001149B0FBF1F084B22046FFF76FFEFFF7A2 +:1013700025FAFFF7F5F9FFF78FFAFFF72DFB0020AD +:1013800000F014F8FFF75CFEFFF738FE01E0FFF70E +:101390004FFEFCE7001002400CED00E00000FA05F3 +:1013A000000001400000002040420F0010B504463C +:1013B0000C4951F824104A000B4951F8240000212F +:1013C00000F09EF8094951F824200749083951F8DE +:1013D0002400002100F094F8012103480830015551 +:1013E00010BD0000741E000854000020841E000878 +:1013F0002DE9F04704460F460025A9462348005D25 +:1014000020B9224818380168204688471FB94FF094 +:10141000FF30BDE8F0871E4850F82400B7FBF0F617 +:101420001B4850F82400B7FBF0F100FB117000B12D +:10143000761C184850F82400451E22E0134808384E +:1014400050F8240030F8150010B909F1010901E045 +:101450004FF00009B14513D14FF0000809E00B48E7 +:10146000083850F8240005EB080220F8126008F153 +:101470000108B045F3D3064850F824006843C8E794 +:101480006D1E002DDADA4FF0FF30C2E75C0000205D +:101490007C1E0008741E000810B5014600230022BF +:1014A00007E00B4850F8210030F8120000B15B1C37 +:1014B000521C084850F821009042F2D8642058434A +:1014C000044C54F82140B0FBF4F0C0B210BD000051 +:1014D00054000020741E000870B504460E463146C4 +:1014E0002046FFF785FF0546681C08B9002070BD3F +:1014F000024850F824002844F9E700004C0000207E +:1015000030B5034601E003F8011B141EA2F10102ED +:10151000F9D130BD10B504464FF48062214603482E +:10152000FFF761FD00F05AF810BD000080140020A4 +:1015300010B5AE20FFF76AFE2020FFF767FE1020EF +:10154000FFF764FEC820FFF761FE0020FFF75EFE94 +:101550001020FFF75BFE4020FFF758FE8120FFF7C9 +:1015600055FEFF20FFF752FEA120FFF74FFEA620F9 +:10157000FFF74CFEA820FFF749FE3F20FFF746FE8D +:10158000A420FFF743FED320FFF740FE0020FFF723 +:101590003DFED520FFF73AFEF020FFF737FED920B9 +:1015A000FFF734FE2220FFF731FEDA20FFF72EFE90 +:1015B0001220FFF72BFEDB20FFF728FE2020FFF78D +:1015C00025FE8D20FFF722FE1420FFF71FFEAF201F +:1015D000FFF71CFE0020FFF79DFF10BD70B5002433 +:1015E00018E004F1B001C8B2FFF710FE0120FFF7C8 +:1015F0000DFE1020FFF70AFE002507E005EBC411E1 +:10160000064A505CFFF71FFE681CC5B2802DF5DB53 +:10161000601CC4B2082CE4DB70BD00008014002004 +:1016200000BF00BF00BF00BF00BFBFF34F8F00BFB0 +:1016300000BF00BF0948006800F4E06008490843A3 +:10164000001D0649086000BF00BF00BFBFF34F8FF9 +:1016500000BF00BF00BF00BF00BFFDE70CED00E012 +:101660000000FA0510B5044604B910BD002020851D +:10167000A07D012808D1606A30B1218C89040A0C50 +:101680000021606AFFF7A5FC00BFEEE72DE9F05FDF +:101690000646884615469946DDE90B7BDDF828A00D +:1016A0000EB1012100E0002108462921FEF762FD6C +:1016B0004420FFF787FC04460CB1012100E0002123 +:1016C00008462C21FEF756FD0120E075002020760B +:1016D000C4F83C902584C4F840B0A786002D0CDDEA +:1016E0002846FFF76FFCE061E16909B1012100E0E4 +:1016F000002108463E21FEF73DFD002F0CDD384657 +:10170000FFF760FC2063216B09B1012100E000219B +:1017100008464521FEF72EFD84F8158084F82CA09C +:1017200066602046BDE8F09F10B5044604B910BDC0 +:10173000002060852046FFF795FF00BFF7E710B552 +:1017400004460CB1012100E00021084640F2D71107 +:10175000FEF710FD012084F838002169A068FEF72B +:1017600047FD2069082865D2DFE800F06404111EF7 +:101770002C3A485600BFA0680168C1F3400121B16E +:10178000A0680221416000BF00BF00BF53E000BF5E +:10179000A0680168C1F3401121B1A0682021416017 +:1017A00000BF00BF00BF46E000BFA0680168C1F3F2 +:1017B000402129B1A0684FF40071416000BF00BF13 +:1017C00000BF38E000BFA0680168C1F3403129B113 +:1017D000A0684FF40051416000BF00BF00BF2AE085 +:1017E00000BFA0680168C1F3404129B1A0684FF46F +:1017F0000031416000BF00BF00BF1CE000BFA06817 +:101800000168C1F3405129B1A0684FF40011416053 +:1018100000BF00BF00BF0EE000BFA0680168C1F3B9 +:10182000406129B1A0684FF00071416000BF00BF66 +:1018300000BF00E000BF00BF606800BF00BF00BF86 +:1018400000F10C0252E8002F42F0400100F10C02BE +:1018500042E80013002BF3D100BF00BF2069082825 +:1018600065D2DFE800F06404111E2C3A485600BF30 +:10187000A0680168C1F3C00121B1A06808214160DE +:1018800000BF00BF00BF53E000BFA0680168C1F304 +:10189000C01121B1A0688021416000BF00BF00BF1E +:1018A00046E000BFA0680168C1F3C02129B1A0686B +:1018B0004FF40061416000BF00BF00BF38E000BFCF +:1018C000A0680168C1F3C03129B1A0684FF400419C +:1018D000416000BF00BF00BF2AE000BFA0680168F0 +:1018E000C1F3C04129B1A0684FF40021416000BF9D +:1018F00000BF00BF1CE000BFA0680168C1F3C05179 +:1019000029B1A0684FF40001416000BF00BF00BFD3 +:101910000EE000BFA0680168C1F3C06129B1A068F2 +:101920004FF00061416000BF00BF00BF00E000BF9A +:1019300000BF10BD0EB51348006808BB0020F021A1 +:101940000122114BCDE9002102900A4601210F48E6 +:10195000FFF79CFE0B4908600020096808700C48DE +:10196000084909688860052006490968C86004209C +:1019700004490968086100210248006800F0E2F8A3 +:101980000EBD000064000020C71C000800380140A4 +:101990000000024038B5044604B938BD6068C1682B +:1019A000C1F34011B9B160680168C1F3401191B150 +:1019B000608D218C884202DB2046FFF7B5FE61680E +:1019C0004A68D2B2608D411C6185E1690A540020E9 +:1019D0002076E0753FE06068C168C1F3001100291E +:1019E00039D060680168C1F30011002933D0607DEF +:1019F00001282BD1D4E902014A1E514B9A5C0244C2 +:101A00005268208C801A6085207DF8B9D4E90201E3 +:101A1000FEF7EEFBE06B80B1608D00280DDD608D80 +:101A2000218C884209DC628D2078E36BE16998475C +:101A3000228C0021E069FFF7CCFA228CD4E9020164 +:101A4000FEF710FCD4E90201FEF7E0FB0020608500 +:101A50006068FEF7C6FD6068C168C1F3801151B1CE +:101A60006068FEF724FE30B1206C08B1206C80471E +:101A70006068FEF7BEFDA07D01285ED1012560688B +:101A8000C168C1F3002171B16068016801F0010112 +:101A900049B1022560680168009100BF416800916A +:101AA00000BF00BF00BF6068FEF7F2FD68B160686C +:101AB000FEF7EEFD48B1042560680168009100BFA3 +:101AC0004168009100BF00BF00BF6068FEF7E5FD00 +:101AD00060B16068FEF7E1FD40B1606801680091A7 +:101AE00000BF4168009100BF00BF00BF6068FEF703 +:101AF000D9FD68B16068FEF7D5FD48B11025606872 +:101B00000168009100BF4168009100BF00BF00BFA5 +:101B1000012D11D0606A78B1618D491E88B2228D85 +:101B2000616A01EB82014880228D616A01F82250CE +:101B3000218D491C218500BF00BF00BF2DE700009B +:101B4000301E000870B504460D46607D90B9A5753D +:101B5000606800BF00BF00BF00F10C0252E8002F18 +:101B600042F0200100F10C0242E80013002BF3D1F7 +:101B700000BF70E00020A0756068FEF732FD2169AB +:101B8000A068FEF735FBD4E90201FEF731FB60687F +:101B9000011D0E463246D4E90201FEF7BFFBE269A1 +:101BA000D4E90201FEF780FB228CD4E90201FEF7A2 +:101BB00059FBD4E90201FEF737FBD4E90201FEF735 +:101BC00025FB606800BF00BF00BF00F1140252E8AF +:101BD000002F42F0400100F1140242E80013002BF4 +:101BE000F3D100BF00BF606800BF00BF00BF00F1BD +:101BF0000C0252E8002F42F0100100F10C0242E802 +:101C00000013002BF3D100BF00BF6068011D0E461A +:101C100032462169A068FEF781FB226B2169A0682A +:101C2000FEF742FB2169A068FEF7FEFA606800BF7C +:101C300000BF00BF00F1140252E8002F42F0800103 +:101C400000F1140242E80013002BF3D100BF00BFE3 +:101C5000012084F83800A07D012833D1606A68B97A +:101C6000218C8800FFF7AEF96062616A09B1012139 +:101C700000E0002108468221FEF77CFA606800BF80 +:101C800000BF00BF00F10C0252E8002F42F4807147 +:101C900000F10C0242E80013002BF3D100BF00BF9B +:101CA000606800BF00BF00BF00F1140252E8002FBF +:101CB00042F0010100F1140242E80013002BF3D1BD +:101CC00000BF00BF70BD704770B504460D462A4680 +:101CD00021460248006800F003F870BD640000204F +:101CE0002DE9F04104460D4616460CB1012100E0F5 +:101CF00000210846C221FEF73DFA0DB1012100E0A6 +:101D000000210846C321FEF735FA002E01DD01212E +:101D100000E000210846C421FEF72CFA002794F8C1 +:101D20002C00012831D1002084F8380029463246A1 +:101D3000206B03E011F8013B00F8013B131EA2F1F8 +:101D4000010C1FFA8CF2F5D100BF2169A068FEF7E3 +:101D50004FFA226B2169A068FEF7A6FA3246216984 +:101D6000A068FEF77FFA2169A068FEF74FFA07E046 +:101D70003846791C8FB2B0F5FA6F01DBBDE8F0810F +:101D800094F838000028F3D02FE00027002015E059 +:101D900000272A5C61684A6000BF07E039467A1C68 +:101DA00097B2FE2901DB002700E000BF61680A68E6 +:101DB000C2F3C012002AF1D0411C88B2B042E7DB66 +:101DC00007E03846791C8FB2FE2801DB002700E0CF +:101DD00000BF6068FEF76BFC0028F2D0206C08B1F1 +:101DE000206C80476068FEF704FC00BFC6E7081C53 +:101DF0003044586C80000000000404040000080017 +:101E00000000080000080000000800020406080A9C +:101E10000C000102030405060000000000000000A1 +:101E20000102030406070809000000000102030480 +:101E3000081C3044586C80000000000404040000BA +:101E40000800000008000008000000080002040666 +:101E5000080A0C000102030405065F6C6973740034 +:101E60006C69737420616C6C20636F6D6D616E645E +:101E70000000000000020000000000000800000058 +:101E8000080000000010000000000000AC1E000868 +:101E90000000002078000000640F0008241F0008E4 +:101EA00078000020081C0000740F00080024F400D3 +:101EB0000000000000000000000000000000000022 +:101EC0000000000000000000000000000000000012 +:101ED0000000000000000000000000000000000002 +:101EE00000000000000000000000000000000000F2 +:101EF000AD13000899140008800000204000002065 +:101F000080100020420000200000000000000000BF +:101F1000000000005A1E0008601E0008C6E533B429 +:041F2000A10F000805 :04000005080000ED02 :00000001FF diff --git a/User/application/app.c b/User/application/app.c index 6516b29..960125d 100644 --- a/User/application/app.c +++ b/User/application/app.c @@ -18,7 +18,7 @@ static uint8_t idle_inspection(struct flow *fl) for (;;) { GPIO_TOGGLE(LED_BLUE_GPIO_Port, LED_BLUE_Pin); - FL_LOCK_DELAY(fl, FL_CLOCK_SEC * 1); + FL_LOCK_DELAY(fl, FL_CLOCK_SEC); } FL_TAIL(fl); } diff --git a/User/board/board.c b/User/board/board.c index af0387a..7c203f4 100644 --- a/User/board/board.c +++ b/User/board/board.c @@ -1,9 +1,42 @@ #include "board.h" +uart_t *uart = NULL; + +static void uart_rx_cb(uint8_t uart_index, uint8_t *data, uint16_t len) +{ +} + +static void uart_init(void) +{ + if (uart == NULL) + { + uart = uart_create(USART1, TRUE, UART_RXSIZE, uart_rx_cb, TRUE, UART_TXSIZE, NULL); + uart->uart_index = 0; + uart->dma = DMA1; + uart->dma_rx_channel = LL_DMA_CHANNEL_5; + uart->dma_tx_channel = LL_DMA_CHANNEL_4; + uart_recv_en(uart, FALSE); + } +} + +/** + * @brief 通过UART发送数据 + * + * 该函数通过UART接口发送指定长度的数据。 + * + * @param data 指向要发送数据的指针 + * @param len 要发送的数据长度 + */ +void uart_send(uint8_t *data, uint16_t len) +{ + uart_send_data(uart, data, len); +} + /** * @brief 初始化显示板 * */ void board_init(void) { + uart_init(); ssd1306_init(); } diff --git a/User/board/board.h b/User/board/board.h index 0394bc2..44d8d51 100644 --- a/User/board/board.h +++ b/User/board/board.h @@ -2,8 +2,13 @@ #define __BOARD_H__ #include "lib.h" #include "ssd1306_oled.h" +#define UART_RXSIZE (240u) // 接收240个字节 +#define UART_TXSIZE (240u) // 发送240个字节 #define TASK_TIM TIM2 +extern uart_t *uart; + void board_init(void); +void uart_send(uint8_t *data, uint16_t len); #endif diff --git a/User/board/ssd1306_oled.c b/User/board/ssd1306_oled.c index 78f04b2..193be97 100644 --- a/User/board/ssd1306_oled.c +++ b/User/board/ssd1306_oled.c @@ -8,26 +8,6 @@ #include "ssd1306_oled.h" #include "ssd1306_oled.h" -const uint8_t F16x16[] = - { - 0x00, 0xF8, 0x08, 0x88, 0x88, 0x08, 0x08, 0x00, 0x00, 0xE0, 0x10, 0x08, 0x08, 0x10, 0xE0, 0x00, - 0x00, 0x19, 0x21, 0x20, 0x20, 0x11, 0x0E, 0x00, 0x00, 0x0F, 0x10, 0x20, 0x20, 0x10, 0x0F, 0x00, // 50 - - 0x10, 0x60, 0x02, 0x8C, 0x00, 0x80, 0x00, 0xF0, 0x02, 0x04, 0x18, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x04, 0x04, 0x7E, 0x01, 0x08, 0x07, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x78, 0x00, 0x07, 0x00, // 沁 - - 0x20, 0x24, 0x24, 0xA4, 0xFE, 0x23, 0x22, 0x20, 0x00, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, - 0x10, 0x08, 0x06, 0x01, 0xFF, 0x01, 0x06, 0x00, 0x00, 0x3F, 0x10, 0x10, 0x10, 0x3F, 0x00, 0x00, // 和 - - 0x10, 0x94, 0x53, 0x32, 0x1E, 0x32, 0x52, 0x10, 0x00, 0x7E, 0x42, 0x42, 0x42, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0xFF, 0x00, 0x00, 0x00, 0x00, // 智 - - 0x08, 0xCC, 0x4A, 0x49, 0x48, 0x4A, 0xCC, 0x18, 0x00, 0x7F, 0x88, 0x88, 0x84, 0x82, 0xE0, 0x00, - 0x00, 0xFF, 0x12, 0x12, 0x52, 0x92, 0x7F, 0x00, 0x00, 0x7E, 0x88, 0x88, 0x84, 0x82, 0xE0, 0x00, // 能 - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //: -}; /************************************6*8的点阵************************************/ const uint8_t F6x8[][6] = @@ -225,74 +205,6 @@ const uint8_t F8X16[] = 0x00, 0x06, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //~ 94 }; -const uint8_t BMP1[] = - { - 0x00, 0x03, 0x05, 0x09, 0x11, 0xFF, 0x11, 0x89, 0x05, 0xC3, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x28, 0xFF, 0x11, 0xAA, 0x44, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x01, 0x38, 0x44, 0x82, 0x92, - 0x92, 0x74, 0x01, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x44, 0xC7, 0x01, 0x7D, - 0x7D, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xFF, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, - 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x40, 0x40, - 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0xDB, 0xDB, - 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0x00, 0x00, 0xD8, 0xD8, 0xD8, 0xD8, - 0xD8, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, - 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0xE6, 0x66, 0x20, 0x00, 0x06, 0x06, 0x86, 0x06, - 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x86, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, - 0x00, 0x86, 0x86, 0x86, 0x86, 0x86, 0x80, 0x80, 0x86, 0x86, 0x06, 0x86, 0x86, 0xC0, 0xC0, 0x86, - 0x86, 0x86, 0x06, 0x06, 0xD0, 0x30, 0x76, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1C, 0x00, 0xFE, 0x00, 0x01, - 0x02, 0x00, 0xC4, 0x18, 0x20, 0x02, 0x9E, 0x63, 0xB2, 0x0E, 0x00, 0xFF, 0x81, 0x81, 0xFF, 0x00, - 0x00, 0x80, 0x40, 0x30, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x23, 0xEA, 0xAA, 0xBF, 0xAA, - 0xEA, 0x03, 0x3F, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0C, 0x08, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x81, 0x80, 0x80, 0x81, 0x80, - 0x81, 0x80, 0x80, 0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x01, 0x09, 0x0C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, - 0x00, 0x1E, 0x21, 0x40, 0x40, 0x50, 0x21, 0x5E, 0x00, 0x1E, 0x21, 0x40, 0x40, 0x50, 0x21, 0x5E, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC1, 0xC1, 0xFF, - 0xFF, 0xC1, 0xC1, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0xFC, 0xF3, 0xEF, 0xF3, 0xFC, - 0x80, 0xFF, 0x80, 0xEE, 0xEE, 0xEE, 0xF5, 0xFB, 0xFF, 0x9C, 0xBE, 0xB6, 0xB6, 0x88, 0xFF, 0x00, /*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/ -}; - static uint8_t _buffer[SSD1306_WIDTH * SSD1306_HEIGHT / 8]; // 定义屏幕缓冲区 static void i2c_start(void) @@ -459,9 +371,9 @@ void set_position(uint8_t x, uint8_t y) i2c_write_command((x & 0x0f) | 0x01); } -static void ssd1306_test(void) +void ssd1306_test(void) { - ssd1306_f8x16_string(0, 0, "TEST"); + ssd1306_f8x16_string(0, 0, " TEST"); ssd1306_f8x16_number(40, 0, -15.26, 2); ssd1306_f6x8_string_number(0, 3, " @ADC1:", 'V', 24); ssd1306_update_screen(); @@ -498,7 +410,7 @@ void ssd1306_init(void) i2c_write_command(SSD1306_CMD_DISPLAY_ON); //--turn on oled panel ssd1306_fill(0); - // ssd1306_test(); +// ssd1306_test(); } void ssd1306_display_on(void) @@ -570,6 +482,35 @@ void ssd1306_clear(void) ssd1306_update_screen(); } +/** + * @brief 在指定区域内绘制BMP + * + * 在指定坐标区域内绘制一个BMP,使用SSD1306 OLED显示屏 + * ssd1306_draw_bmp(0, 0, 128, 2); + * @param x0 BMP绘制的起始X坐标 + * @param y0 BMP绘制的起始Y坐标 + * @param x1 BMP绘制的结束X坐标 + * @param y1 BMP绘制的结束Y坐标 + */ +void ssd1306_draw_bmp(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *bmp) +{ + uint8_t j = 0; + uint8_t x, y; + osel_memset(_buffer, 0, ARRAY_LEN(_buffer)); + if (y1 % 8 == 0) + y = y1 / 8; + else + y = y1 / 8 + 1; + for (y = y0; y < y1; y++) + { + set_position(x0, y); + for (x = x0; x < x1; x++) + { + i2c_write_data(bmp[j++]); + } + } +} + /** * @brief 在SSD1306 OLED显示屏上显示字符串 * diff --git a/User/board/ssd1306_oled.h b/User/board/ssd1306_oled.h index cac9120..2355bb5 100644 --- a/User/board/ssd1306_oled.h +++ b/User/board/ssd1306_oled.h @@ -59,6 +59,7 @@ void ssd1306_update_screen(void); void ssd1306_fill(uint8_t color); void ssd1306_clear(void); +void ssd1306_draw_bmp(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *bmp); void ssd1306_f6x8_string(uint8_t x, uint8_t y, const uint8_t *ch); void ssd1306_f6x8_string_number(uint8_t x, uint8_t y, const uint8_t *ch, uint8_t unit, float32 num); void ssd1306_f8x16_string(uint8_t x, uint8_t y, const uint8_t *ch); diff --git a/User/system/bsp/bsp.h b/User/system/bsp/bsp.h index 1f61a3b..a1fc982 100644 --- a/User/system/bsp/bsp.h +++ b/User/system/bsp/bsp.h @@ -18,7 +18,7 @@ #include "dmas.h" #include "tims.h" // #include "pwms.h" -// #include "uarts.h" +#include "uarts.h" // #include "eeprom.h" // #include "spis.h" #include "i2cs.h" diff --git a/motor.ioc b/motor.ioc index 7f22e1c..170710c 100644 --- a/motor.ioc +++ b/motor.ioc @@ -2,29 +2,54 @@ CAD.formats= CAD.pinconfig= CAD.provider= +Dma.Request0=USART1_RX +Dma.Request1=USART1_TX +Dma.RequestsNb=2 +Dma.USART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.USART1_RX.0.Instance=DMA1_Channel5 +Dma.USART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART1_RX.0.MemInc=DMA_MINC_ENABLE +Dma.USART1_RX.0.Mode=DMA_NORMAL +Dma.USART1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART1_RX.0.PeriphInc=DMA_PINC_DISABLE +Dma.USART1_RX.0.Priority=DMA_PRIORITY_LOW +Dma.USART1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority +Dma.USART1_TX.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART1_TX.1.Instance=DMA1_Channel4 +Dma.USART1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART1_TX.1.MemInc=DMA_MINC_ENABLE +Dma.USART1_TX.1.Mode=DMA_NORMAL +Dma.USART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE +Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW +Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false Mcu.CPN=STM32F103C8T6 Mcu.Family=STM32F1 -Mcu.IP0=NVIC -Mcu.IP1=RCC -Mcu.IP2=SYS -Mcu.IP3=TIM2 -Mcu.IPNb=4 +Mcu.IP0=DMA +Mcu.IP1=NVIC +Mcu.IP2=RCC +Mcu.IP3=SYS +Mcu.IP4=TIM2 +Mcu.IP5=USART1 +Mcu.IPNb=6 Mcu.Name=STM32F103C(8-B)Tx Mcu.Package=LQFP48 Mcu.Pin0=PC13-TAMPER-RTC Mcu.Pin1=PD0-OSC_IN +Mcu.Pin10=VP_SYS_VS_Systick +Mcu.Pin11=VP_TIM2_VS_ClockSourceINT Mcu.Pin2=PD1-OSC_OUT Mcu.Pin3=PA1 Mcu.Pin4=PB12 Mcu.Pin5=PB13 -Mcu.Pin6=PA13 -Mcu.Pin7=PA14 -Mcu.Pin8=VP_SYS_VS_Systick -Mcu.Pin9=VP_TIM2_VS_ClockSourceINT -Mcu.PinsNb=10 +Mcu.Pin6=PA9 +Mcu.Pin7=PA10 +Mcu.Pin8=PA13 +Mcu.Pin9=PA14 +Mcu.PinsNb=12 Mcu.ThirdParty0=RealThread.RT-Thread.3.1.5 Mcu.ThirdPartyNb=1 Mcu.UserConstants= @@ -32,6 +57,8 @@ Mcu.UserName=STM32F103C8Tx MxCube.Version=6.9.2 MxDb.Version=DB.6.0.92 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.DMA1_Channel4_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true +NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false @@ -42,14 +69,19 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false NVIC.TIM2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PA1.GPIOParameters=GPIO_Label PA1.GPIO_Label=PWMA PA1.Signal=GPIO_Output +PA10.Mode=Asynchronous +PA10.Signal=USART1_RX PA13.Mode=Serial_Wire PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Serial_Wire PA14.Signal=SYS_JTCK-SWCLK +PA9.Mode=Asynchronous +PA9.Signal=USART1_TX PB12.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP PB12.GPIO_Label=OLED_SDA PB12.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP @@ -102,7 +134,7 @@ ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_TIM2_Init-TIM2-false-LL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_DMA_Init-DMA-false-LL-true,4-MX_TIM2_Init-TIM2-false-LL-true,5-MX_USART1_UART_Init-USART1-false-LL-true RCC.ADCFreqValue=36000000 RCC.AHBFreq_Value=72000000 RCC.APB1CLKDivider=RCC_HCLK_DIV2 @@ -135,6 +167,8 @@ RealThread.RT-Thread.3.1.5_SwParameter=RTOSJjkernel\:true;RTOSJjshell\:true;RTOS TIM2.IPParameters=Prescaler,Period TIM2.Period=99 TIM2.Prescaler=7199 +USART1.IPParameters=VirtualMode +USART1.VirtualMode=VM_ASYNC VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Signal=SYS_VS_Systick VP_TIM2_VS_ClockSourceINT.Mode=Internal