🦄 refactor: 添加回串口2 DMA
This commit is contained in:
parent
817466b4aa
commit
18eed95c7e
|
@ -6,6 +6,11 @@ SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\dma.c;..\Core\Src\
|
||||||
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Core\Inc;
|
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Core\Inc;
|
||||||
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
||||||
|
|
||||||
|
[PreviousUsedMakefileFiles]
|
||||||
|
SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\dma.c;Core\Src\i2c.c;Core\Src\tim.c;Core\Src\usart.c;Core\Src\stm32f1xx_it.c;Core\Src\stm32f1xx_hal_msp.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Core\Src\system_stm32f1xx.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Core\Src\system_stm32f1xx.c;;;
|
||||||
|
HeaderPath=Drivers\STM32F1xx_HAL_Driver\Inc;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;Drivers\CMSIS\Device\ST\STM32F1xx\Include;Drivers\CMSIS\Include;Core\Inc;
|
||||||
|
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
||||||
|
|
||||||
[PreviousGenFiles]
|
[PreviousGenFiles]
|
||||||
AdvancedFolderStructure=true
|
AdvancedFolderStructure=true
|
||||||
HeaderFileListSize=8
|
HeaderFileListSize=8
|
||||||
|
|
12
CAR.ioc
12
CAR.ioc
|
@ -77,7 +77,6 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_2
|
||||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.SysTick_IRQn=true\:3\:0\:true\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:3\:0\:true\:false\:true\:false\:true\:false
|
||||||
NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
|
||||||
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
PA0-WKUP.GPIOParameters=PinState,GPIO_Label
|
PA0-WKUP.GPIOParameters=PinState,GPIO_Label
|
||||||
|
@ -90,6 +89,8 @@ PA1.GPIO_Label=FAN_GS
|
||||||
PA1.Locked=true
|
PA1.Locked=true
|
||||||
PA1.PinState=GPIO_PIN_SET
|
PA1.PinState=GPIO_PIN_SET
|
||||||
PA1.Signal=GPIO_Output
|
PA1.Signal=GPIO_Output
|
||||||
|
PA10.Mode=Asynchronous
|
||||||
|
PA10.Signal=USART1_RX
|
||||||
PA12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
PA12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
||||||
PA12.GPIO_Label=Echo
|
PA12.GPIO_Label=Echo
|
||||||
PA12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
|
PA12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
|
||||||
|
@ -113,6 +114,8 @@ PA7.GPIOParameters=GPIO_Label
|
||||||
PA7.GPIO_Label=LED_B_TIM3CH2
|
PA7.GPIO_Label=LED_B_TIM3CH2
|
||||||
PA7.Locked=true
|
PA7.Locked=true
|
||||||
PA7.Signal=S_TIM3_CH2
|
PA7.Signal=S_TIM3_CH2
|
||||||
|
PA9.Mode=Asynchronous
|
||||||
|
PA9.Signal=USART1_TX
|
||||||
PB0.GPIOParameters=GPIO_Label
|
PB0.GPIOParameters=GPIO_Label
|
||||||
PB0.GPIO_Label=LED_G_TIM3CH3
|
PB0.GPIO_Label=LED_G_TIM3CH3
|
||||||
PB0.Locked=true
|
PB0.Locked=true
|
||||||
|
@ -189,7 +192,7 @@ ProjectManager.ToolChainLocation=
|
||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=false
|
ProjectManager.UnderRoot=false
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_USART1_UART_Init-USART1-false-HAL-true,9-MX_USART2_UART_Init-USART2-false-HAL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_USART2_UART_Init-USART2-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true
|
||||||
RCC.ADCFreqValue=36000000
|
RCC.ADCFreqValue=36000000
|
||||||
RCC.AHBFreq_Value=72000000
|
RCC.AHBFreq_Value=72000000
|
||||||
RCC.APB1CLKDivider=RCC_HCLK_DIV2
|
RCC.APB1CLKDivider=RCC_HCLK_DIV2
|
||||||
|
@ -249,11 +252,8 @@ USART1.IPParameters=VirtualMode,BaudRate,Parity,WordLength
|
||||||
USART1.Parity=PARITY_NONE
|
USART1.Parity=PARITY_NONE
|
||||||
USART1.VirtualMode=VM_ASYNC
|
USART1.VirtualMode=VM_ASYNC
|
||||||
USART1.WordLength=WORDLENGTH_8B
|
USART1.WordLength=WORDLENGTH_8B
|
||||||
USART2.BaudRate=9600
|
USART2.IPParameters=VirtualMode
|
||||||
USART2.IPParameters=VirtualMode,BaudRate,Parity,WordLength
|
|
||||||
USART2.Parity=PARITY_NONE
|
|
||||||
USART2.VirtualMode=VM_ASYNC
|
USART2.VirtualMode=VM_ASYNC
|
||||||
USART2.WordLength=WORDLENGTH_8B
|
|
||||||
VP_SYS_VS_Systick.Mode=SysTick
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
||||||
|
|
|
@ -57,7 +57,6 @@ void PendSV_Handler(void);
|
||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
void DMA1_Channel6_IRQHandler(void);
|
void DMA1_Channel6_IRQHandler(void);
|
||||||
void TIM2_IRQHandler(void);
|
void TIM2_IRQHandler(void);
|
||||||
void USART1_IRQHandler(void);
|
|
||||||
void USART2_IRQHandler(void);
|
void USART2_IRQHandler(void);
|
||||||
void EXTI15_10_IRQHandler(void);
|
void EXTI15_10_IRQHandler(void);
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
|
@ -32,7 +32,7 @@ extern "C" {
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart1;
|
||||||
|
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
|
|
||||||
|
|
161
Core/Src/main.c
161
Core/Src/main.c
|
@ -18,11 +18,11 @@
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "dma.h"
|
||||||
#include "gpio.h"
|
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#include "tim.h"
|
#include "tim.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
@ -68,38 +68,42 @@ void SystemClock_Config(void);
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The application entry point.
|
* @brief The application entry point.
|
||||||
* @retval int
|
* @retval int
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void)
|
||||||
/* USER CODE BEGIN 1 */
|
{
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
HAL_Init();
|
|
||||||
|
|
||||||
/* USER CODE BEGIN Init */
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||||
|
HAL_Init();
|
||||||
|
|
||||||
/* USER CODE END Init */
|
/* USER CODE BEGIN Init */
|
||||||
|
|
||||||
/* Configure the system clock */
|
/* USER CODE END Init */
|
||||||
SystemClock_Config();
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SysInit */
|
/* Configure the system clock */
|
||||||
|
SystemClock_Config();
|
||||||
|
|
||||||
/* USER CODE END SysInit */
|
/* USER CODE BEGIN SysInit */
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* USER CODE END SysInit */
|
||||||
MX_GPIO_Init();
|
|
||||||
MX_I2C2_Init();
|
/* Initialize all configured peripherals */
|
||||||
MX_TIM3_Init();
|
MX_GPIO_Init();
|
||||||
MX_TIM4_Init();
|
MX_DMA_Init();
|
||||||
MX_TIM2_Init();
|
MX_I2C2_Init();
|
||||||
MX_USART2_UART_Init();
|
MX_TIM2_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
MX_TIM3_Init();
|
||||||
|
MX_TIM4_Init();
|
||||||
|
MX_USART2_UART_Init();
|
||||||
|
MX_USART1_UART_Init();
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
HC_SR04_Init();
|
HC_SR04_Init();
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
|
@ -108,14 +112,13 @@ int main(void) {
|
||||||
MX_TIM2_Init();
|
MX_TIM2_Init();
|
||||||
MX_TIM3_Init();
|
MX_TIM3_Init();
|
||||||
MX_TIM4_Init();
|
MX_TIM4_Init();
|
||||||
MX_USART1_UART_Init();
|
|
||||||
MX_USART2_UART_Init();
|
MX_USART2_UART_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("test\n");
|
printf("test\n");
|
||||||
|
|
||||||
|
@ -125,46 +128,50 @@ int main(void) {
|
||||||
|
|
||||||
HAL_Delay(300); // 延时300毫秒
|
HAL_Delay(300); // 延时300毫秒
|
||||||
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief System Clock Configuration
|
* @brief System Clock Configuration
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void SystemClock_Config(void) {
|
void SystemClock_Config(void)
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
{
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
/** Initializes the RCC Oscillators according to the specified parameters
|
/** Initializes the RCC Oscillators according to the specified parameters
|
||||||
* in the RCC_OscInitTypeDef structure.
|
* in the RCC_OscInitTypeDef structure.
|
||||||
*/
|
*/
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||||
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
Error_Handler();
|
{
|
||||||
}
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
/** Initializes the CPU, AHB and APB buses clocks
|
/** Initializes the CPU, AHB and APB buses clocks
|
||||||
*/
|
*/
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||||
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||||
Error_Handler();
|
{
|
||||||
}
|
Error_Handler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
@ -172,30 +179,32 @@ void SystemClock_Config(void) {
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is executed in case of error occurrence.
|
* @brief This function is executed in case of error occurrence.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void Error_Handler(void) {
|
void Error_Handler(void)
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
{
|
||||||
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
/* User can add his own implementation to report the HAL error return state */
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
/* USER CODE END Error_Handler_Debug */
|
/* USER CODE END Error_Handler_Debug */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
#ifdef USE_FULL_ASSERT
|
||||||
/**
|
/**
|
||||||
* @brief Reports the name of the source file and the source line number
|
* @brief Reports the name of the source file and the source line number
|
||||||
* where the assert_param error has occurred.
|
* where the assert_param error has occurred.
|
||||||
* @param file: pointer to the source file name
|
* @param file: pointer to the source file name
|
||||||
* @param line: assert_param error line source number
|
* @param line: assert_param error line source number
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void assert_failed(uint8_t *file, uint32_t line) {
|
void assert_failed(uint8_t *file, uint32_t line)
|
||||||
/* USER CODE BEGIN 6 */
|
{
|
||||||
|
/* USER CODE BEGIN 6 */
|
||||||
/* User can add his own implementation to report the file name and line number,
|
/* User can add his own implementation to report the file name and line number,
|
||||||
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||||
/* USER CODE END 6 */
|
/* USER CODE END 6 */
|
||||||
}
|
}
|
||||||
#endif /* USE_FULL_ASSERT */
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
/* External variables --------------------------------------------------------*/
|
/* External variables --------------------------------------------------------*/
|
||||||
extern TIM_HandleTypeDef htim2;
|
extern TIM_HandleTypeDef htim2;
|
||||||
extern DMA_HandleTypeDef hdma_usart2_rx;
|
extern DMA_HandleTypeDef hdma_usart2_rx;
|
||||||
extern UART_HandleTypeDef huart1;
|
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
/* USER CODE BEGIN EV */
|
/* USER CODE BEGIN EV */
|
||||||
|
|
||||||
|
@ -229,20 +228,6 @@ void TIM2_IRQHandler(void)
|
||||||
/* USER CODE END TIM2_IRQn 1 */
|
/* 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 */
|
|
||||||
HAL_UART_IRQHandler(&huart1);
|
|
||||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END USART1_IRQn 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART2 global interrupt.
|
* @brief This function handles USART2 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -47,7 +47,7 @@ void MX_TIM2_Init(void)
|
||||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim2.Init.Period = 72 - 1;
|
htim2.Init.Period = 72 - 1;
|
||||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
|
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
|
|
103
Core/Src/usart.c
103
Core/Src/usart.c
|
@ -28,6 +28,35 @@ UART_HandleTypeDef huart1;
|
||||||
UART_HandleTypeDef huart2;
|
UART_HandleTypeDef huart2;
|
||||||
DMA_HandleTypeDef hdma_usart2_rx;
|
DMA_HandleTypeDef hdma_usart2_rx;
|
||||||
|
|
||||||
|
/* USART1 init function */
|
||||||
|
|
||||||
|
void MX_USART1_UART_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 1 */
|
||||||
|
huart1.Instance = USART1;
|
||||||
|
huart1.Init.BaudRate = 115200;
|
||||||
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart1.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart1.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
if (HAL_UART_Init(&huart1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN USART1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
/* USART2 init function */
|
/* USART2 init function */
|
||||||
|
|
||||||
void MX_USART2_UART_Init(void)
|
void MX_USART2_UART_Init(void)
|
||||||
|
@ -56,70 +85,38 @@ void MX_USART2_UART_Init(void)
|
||||||
|
|
||||||
/* USER CODE END USART2_Init 2 */
|
/* USER CODE END USART2_Init 2 */
|
||||||
|
|
||||||
}
|
|
||||||
/* USART2 init function */
|
|
||||||
|
|
||||||
void MX_USART2_UART_Init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* USER CODE BEGIN USART2_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE END USART2_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN USART2_Init 1 */
|
|
||||||
|
|
||||||
/* USER CODE END USART2_Init 1 */
|
|
||||||
huart2.Instance = USART2;
|
|
||||||
huart2.Init.BaudRate = 9600;
|
|
||||||
huart2.Init.WordLength = UART_WORDLENGTH_8B;
|
|
||||||
huart2.Init.StopBits = UART_STOPBITS_1;
|
|
||||||
huart2.Init.Parity = UART_PARITY_NONE;
|
|
||||||
huart2.Init.Mode = UART_MODE_TX_RX;
|
|
||||||
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
||||||
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
|
|
||||||
if (HAL_UART_Init(&huart2) != HAL_OK)
|
|
||||||
{
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
/* USER CODE BEGIN USART2_Init 2 */
|
|
||||||
|
|
||||||
/* USER CODE END USART2_Init 2 */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
{
|
{
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
if(uartHandle->Instance==USART2)
|
if(uartHandle->Instance==USART1)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART2_MspInit 0 */
|
/* USER CODE BEGIN USART1_MspInit 0 */
|
||||||
|
|
||||||
/* USER CODE END USART2_MspInit 0 */
|
/* USER CODE END USART1_MspInit 0 */
|
||||||
/* USART2 clock enable */
|
/* USART1 clock enable */
|
||||||
__HAL_RCC_USART2_CLK_ENABLE();
|
__HAL_RCC_USART1_CLK_ENABLE();
|
||||||
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
/**USART2 GPIO Configuration
|
/**USART1 GPIO Configuration
|
||||||
PA2 ------> USART2_TX
|
PA9 ------> USART1_TX
|
||||||
PA3 ------> USART2_RX
|
PA10 ------> USART1_RX
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
GPIO_InitStruct.Pin = GPIO_PIN_9;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* USART1 interrupt Init */
|
|
||||||
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
|
||||||
/* USER CODE BEGIN USART1_MspInit 1 */
|
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END USART2_MspInit 1 */
|
/* USER CODE END USART1_MspInit 1 */
|
||||||
}
|
}
|
||||||
else if(uartHandle->Instance==USART2)
|
else if(uartHandle->Instance==USART2)
|
||||||
{
|
{
|
||||||
|
@ -173,25 +170,23 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(uartHandle->Instance==USART2)
|
if(uartHandle->Instance==USART1)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART2_MspDeInit 0 */
|
/* USER CODE BEGIN USART1_MspDeInit 0 */
|
||||||
|
|
||||||
/* USER CODE END USART2_MspDeInit 0 */
|
/* USER CODE END USART1_MspDeInit 0 */
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_USART2_CLK_DISABLE();
|
__HAL_RCC_USART1_CLK_DISABLE();
|
||||||
|
|
||||||
/**USART2 GPIO Configuration
|
/**USART1 GPIO Configuration
|
||||||
PA2 ------> USART2_TX
|
PA9 ------> USART1_TX
|
||||||
PA3 ------> USART2_RX
|
PA10 ------> USART1_RX
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
|
||||||
|
|
||||||
/* USART1 interrupt Deinit */
|
|
||||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
|
||||||
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||||
|
|
||||||
/* USER CODE END USART2_MspDeInit 1 */
|
/* USER CODE END USART1_MspDeInit 1 */
|
||||||
}
|
}
|
||||||
else if(uartHandle->Instance==USART2)
|
else if(uartHandle->Instance==USART2)
|
||||||
{
|
{
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -1,5 +1,5 @@
|
||||||
##########################################################################################################################
|
##########################################################################################################################
|
||||||
# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Sat Jul 13 14:09:19 CST 2024]
|
# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Sat Jul 13 16:33:46 CST 2024]
|
||||||
##########################################################################################################################
|
##########################################################################################################################
|
||||||
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
|
@ -40,6 +40,7 @@ Core/Src/main.c \
|
||||||
Core/Src/gpio.c \
|
Core/Src/gpio.c \
|
||||||
Core/Src/i2c.c \
|
Core/Src/i2c.c \
|
||||||
Core/Src/tim.c \
|
Core/Src/tim.c \
|
||||||
|
Core/Src/dma.c \
|
||||||
Core/Src/usart.c \
|
Core/Src/usart.c \
|
||||||
Core/Src/stm32f1xx_it.c \
|
Core/Src/stm32f1xx_it.c \
|
||||||
Core/Src/stm32f1xx_hal_msp.c \
|
Core/Src/stm32f1xx_hal_msp.c \
|
||||||
|
@ -63,7 +64,9 @@ Core/Src/sysmem.c \
|
||||||
Core/Src/hcsr04.c \
|
Core/Src/hcsr04.c \
|
||||||
Core/Src/motor.c \
|
Core/Src/motor.c \
|
||||||
Core/Src/led.c \
|
Core/Src/led.c \
|
||||||
Core/Src/syscalls.c
|
Core/Src/syscalls.c \
|
||||||
|
Core/Src/bluetooth.c \
|
||||||
|
Core/Src/control.c
|
||||||
|
|
||||||
# ASM sources
|
# ASM sources
|
||||||
ASM_SOURCES = \
|
ASM_SOURCES = \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user