From 08534362f41685125262f830d41da68b4c56f7d6 Mon Sep 17 00:00:00 2001 From: murmur Date: Sat, 14 Dec 2024 21:40:58 +0800 Subject: [PATCH] fix led --- .eide/eide.json | 6 ++++-- Core/Inc/main.h | 4 ++-- Core/Src/gpio.c | 38 +++++++++++++++++++------------------- Core/Src/main.c | 5 +++-- f1CTL.ioc | 20 ++++++++++---------- 5 files changed, 38 insertions(+), 35 deletions(-) diff --git a/.eide/eide.json b/.eide/eide.json index 31ec253..ba9a2e7 100644 --- a/.eide/eide.json +++ b/.eide/eide.json @@ -19,7 +19,9 @@ }, "targets": { "Debug": { - "excludeList": [], + "excludeList": [ + "Core/motor" + ], "toolchain": "GCC", "compileConfig": { "cpuType": "Cortex-M3", @@ -36,7 +38,7 @@ "uploadConfig": { "bin": "", "target": "stm32f1x", - "interface": "cmsis-dap", + "interface": "stlink", "baseAddr": "0x08000000" }, "uploadConfigMap": { diff --git a/Core/Inc/main.h b/Core/Inc/main.h index d6404c4..9bc5a68 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -57,10 +57,10 @@ void Error_Handler(void); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ -#define LED_Pin GPIO_PIN_15 -#define LED_GPIO_Port GPIOC #define DIR2_Pin GPIO_PIN_1 #define DIR2_GPIO_Port GPIOA +#define LED_Pin GPIO_PIN_15 +#define LED_GPIO_Port GPIOE /* USER CODE BEGIN Private defines */ diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 759bd82..683b738 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -54,40 +54,33 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(DIR2_GPIO_Port, DIR2_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(DIR2_GPIO_Port, DIR2_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); /*Configure GPIO pins : PE2 PE3 PE4 PE5 PE6 PE7 PE8 PE9 PE10 PE11 PE12 PE13 - PE14 PE15 PE0 PE1 */ + PE14 PE0 PE1 */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9 |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 - |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + |GPIO_PIN_14|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - /*Configure GPIO pins : PC13 PC14 PC0 PC1 - PC2 PC3 PC4 PC5 - PC6 PC7 PC8 PC9 - PC10 PC11 PC12 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_0|GPIO_PIN_1 - |GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9 - |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; + /*Configure GPIO pins : PC13 PC14 PC15 PC0 + PC1 PC2 PC3 PC4 + PC5 PC6 PC7 PC8 + PC9 PC10 PC11 PC12 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0 + |GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 + |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pin : LED_Pin */ - GPIO_InitStruct.Pin = LED_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA4 PA5 PA6 PA7 PA8 PA11 PA12 PA15 */ @@ -115,6 +108,13 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + /*Configure GPIO pin : LED_Pin */ + GPIO_InitStruct.Pin = LED_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pins : PD8 PD9 PD10 PD11 PD12 PD13 PD14 PD15 PD0 PD1 PD2 PD3 diff --git a/Core/Src/main.c b/Core/Src/main.c index 309b77a..6817d14 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -100,10 +100,11 @@ int main(void) while (1) { /* USER CODE END WHILE */ - HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); - HAL_Delay(500); + /* USER CODE BEGIN 3 */ + HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); + HAL_Delay(500); } /* USER CODE END 3 */ } diff --git a/f1CTL.ioc b/f1CTL.ioc index 8cb1018..5eb01b9 100644 --- a/f1CTL.ioc +++ b/f1CTL.ioc @@ -37,13 +37,13 @@ Mcu.IP5=USART2 Mcu.IPNb=6 Mcu.Name=STM32F103V(C-D-E)Tx Mcu.Package=LQFP100 -Mcu.Pin0=PC15-OSC32_OUT -Mcu.Pin1=OSC_IN +Mcu.Pin0=OSC_IN +Mcu.Pin1=OSC_OUT Mcu.Pin10=VP_SYS_VS_Systick -Mcu.Pin2=OSC_OUT -Mcu.Pin3=PA1 -Mcu.Pin4=PA2 -Mcu.Pin5=PA3 +Mcu.Pin2=PA1 +Mcu.Pin3=PA2 +Mcu.Pin4=PA3 +Mcu.Pin5=PE15 Mcu.Pin6=PA9 Mcu.Pin7=PA10 Mcu.Pin8=PA13 @@ -89,10 +89,10 @@ PA3.Mode=Asynchronous PA3.Signal=USART2_RX PA9.Mode=Asynchronous PA9.Signal=USART1_TX -PC15-OSC32_OUT.GPIOParameters=GPIO_Label -PC15-OSC32_OUT.GPIO_Label=LED -PC15-OSC32_OUT.Locked=true -PC15-OSC32_OUT.Signal=GPIO_Output +PE15.GPIOParameters=GPIO_Label +PE15.GPIO_Label=LED +PE15.Locked=true +PE15.Signal=GPIO_Output PinOutPanel.RotationAngle=0 ProjectManager.AskForMigrate=true ProjectManager.BackupPrevious=false