From: AceVest Date: Wed, 5 Jun 2019 02:38:48 +0000 (+0800) Subject: F103RE GPIO KEY1 INPUT X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doc/roff.7.ps?a=commitdiff_plain;h=06924bf3e20edb709e2c0ee4e3d8c1e33ce599b9;p=acecode.git F103RE GPIO KEY1 INPUT --- diff --git a/learn/stm32/F103RE/F103RE.ioc b/learn/stm32/F103RE/F103RE.ioc index c5f3bef..81c7f01 100644 --- a/learn/stm32/F103RE/F103RE.ioc +++ b/learn/stm32/F103RE/F103RE.ioc @@ -10,14 +10,15 @@ Mcu.Name=STM32F103R(C-D-E)Tx Mcu.Package=LQFP64 Mcu.Pin0=PD0-OSC_IN Mcu.Pin1=PD1-OSC_OUT -Mcu.Pin2=PA4 -Mcu.Pin3=PA5 -Mcu.Pin4=PA6 -Mcu.Pin5=PA7 -Mcu.Pin6=PA13 -Mcu.Pin7=PA14 -Mcu.Pin8=VP_SYS_VS_Systick -Mcu.PinsNb=9 +Mcu.Pin2=PC0 +Mcu.Pin3=PA4 +Mcu.Pin4=PA5 +Mcu.Pin5=PA6 +Mcu.Pin6=PA7 +Mcu.Pin7=PA13 +Mcu.Pin8=PA14 +Mcu.Pin9=VP_SYS_VS_Systick +Mcu.PinsNb=10 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F103RETx @@ -26,7 +27,7 @@ MxDb.Version=DB.5.0.20 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:true\:false\:true\:false\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 @@ -59,6 +60,10 @@ PA7.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP PA7.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PA7.Locked=true PA7.Signal=GPIO_Output +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=KEY1 +PC0.Locked=true +PC0.Signal=GPIO_Input PCC.Checker=false PCC.Line=STM32F103 PCC.MCU=STM32F103R(C-D-E)Tx diff --git a/learn/stm32/F103RE/Inc/main.h b/learn/stm32/F103RE/Inc/main.h index f0f5f32..db628f8 100644 --- a/learn/stm32/F103RE/Inc/main.h +++ b/learn/stm32/F103RE/Inc/main.h @@ -58,6 +58,8 @@ void Error_Handler(void); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ +#define KEY1_Pin GPIO_PIN_0 +#define KEY1_GPIO_Port GPIOC #define LED1_Pin GPIO_PIN_4 #define LED1_GPIO_Port GPIOA #define LED2_Pin GPIO_PIN_5 diff --git a/learn/stm32/F103RE/Src/gpio.c b/learn/stm32/F103RE/Src/gpio.c index 4a612f8..007b707 100644 --- a/learn/stm32/F103RE/Src/gpio.c +++ b/learn/stm32/F103RE/Src/gpio.c @@ -44,11 +44,18 @@ void MX_GPIO_Init(void) /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, LED1_Pin|LED2_Pin|LED3_Pin|LED4_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin : PtPin */ + GPIO_InitStruct.Pin = KEY1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(KEY1_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pins : PAPin PAPin PAPin PAPin */ GPIO_InitStruct.Pin = LED1_Pin|LED2_Pin|LED3_Pin|LED4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;