commit for rotary encoder input pin config with EXTI interrupt line. && modified GPIO pin with named user label.
This commit is contained in:
@@ -57,6 +57,16 @@ void Error_Handler(void);
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define ENCODER_A_EXTI0_Pin GPIO_PIN_0
|
||||
#define ENCODER_A_EXTI0_GPIO_Port GPIOA
|
||||
#define ENCODER_A_EXTI0_EXTI_IRQn EXTI0_1_IRQn
|
||||
#define ENCODER_B_INPUT_Pin GPIO_PIN_1
|
||||
#define ENCODER_B_INPUT_GPIO_Port GPIOA
|
||||
#define ENCODER_S_EXTI4_Pin GPIO_PIN_4
|
||||
#define ENCODER_S_EXTI4_GPIO_Port GPIOA
|
||||
#define ENCODER_S_EXTI4_EXTI_IRQn EXTI4_15_IRQn
|
||||
#define BUZZER_PWM_OUT_Pin GPIO_PIN_8
|
||||
#define BUZZER_PWM_OUT_GPIO_Port GPIOA
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ extern "C" {
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void EXTI0_1_IRQHandler(void);
|
||||
void EXTI4_15_IRQHandler(void);
|
||||
void DMA1_Channel1_IRQHandler(void);
|
||||
void DMA1_Channel2_3_IRQHandler(void);
|
||||
void TIM17_IRQHandler(void);
|
||||
|
||||
+23
-6
@@ -67,16 +67,33 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PA0 PA1 PA4 PA5
|
||||
PA6 PA7 PA11 PA12
|
||||
PA15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
|
||||
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_11|GPIO_PIN_12
|
||||
|GPIO_PIN_15;
|
||||
/*Configure GPIO pins : ENCODER_A_EXTI0_Pin ENCODER_S_EXTI4_Pin */
|
||||
GPIO_InitStruct.Pin = ENCODER_A_EXTI0_Pin|ENCODER_S_EXTI4_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : ENCODER_B_INPUT_Pin */
|
||||
GPIO_InitStruct.Pin = ENCODER_B_INPUT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(ENCODER_B_INPUT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PA5 PA6 PA7 PA11
|
||||
PA12 PA15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_11
|
||||
|GPIO_PIN_12|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI0_1_IRQn, 3, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI4_15_IRQn, 3, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
@@ -104,6 +104,34 @@ void HardFault_Handler(void)
|
||||
/* please refer to the startup file (startup_stm32g0xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles EXTI line 0 and line 1 interrupts.
|
||||
*/
|
||||
void EXTI0_1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI0_1_IRQn 0 */
|
||||
|
||||
/* USER CODE END EXTI0_1_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(ENCODER_A_EXTI0_Pin);
|
||||
/* USER CODE BEGIN EXTI0_1_IRQn 1 */
|
||||
|
||||
/* USER CODE END EXTI0_1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles EXTI line 4 to 15 interrupts.
|
||||
*/
|
||||
void EXTI4_15_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI4_15_IRQn 0 */
|
||||
|
||||
/* USER CODE END EXTI4_15_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(ENCODER_S_EXTI4_Pin);
|
||||
/* USER CODE BEGIN EXTI4_15_IRQn 1 */
|
||||
|
||||
/* USER CODE END EXTI4_15_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA1 channel 1 interrupt.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -123,12 +123,12 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
/**TIM1 GPIO Configuration
|
||||
PA8 ------> TIM1_CH1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||
GPIO_InitStruct.Pin = BUZZER_PWM_OUT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF2_TIM1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(BUZZER_PWM_OUT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN TIM1_MspPostInit 1 */
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ Mcu.IP6=USART2
|
||||
Mcu.IPNb=7
|
||||
Mcu.Name=STM32G030F6Px
|
||||
Mcu.Package=TSSOP20
|
||||
Mcu.Pin0=PA2
|
||||
Mcu.Pin1=PA3
|
||||
Mcu.Pin2=PB0
|
||||
Mcu.Pin3=PB1
|
||||
Mcu.Pin4=PB2
|
||||
Mcu.Pin0=PA0
|
||||
Mcu.Pin1=PA1
|
||||
Mcu.Pin2=PA2
|
||||
Mcu.Pin3=PA3
|
||||
Mcu.Pin4=PA4
|
||||
Mcu.Pin5=PA8
|
||||
Mcu.Pin6=PA13
|
||||
Mcu.Pin7=PA14-BOOT0
|
||||
@@ -80,6 +80,8 @@ MxCube.Version=6.18.0
|
||||
MxDb.Version=DB.6.0.180
|
||||
NVIC.DMA1_Channel1_IRQn=true\:3\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA1_Channel2_3_IRQn=true\:3\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.EXTI0_1_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.EXTI4_15_IRQn=true\:3\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
@@ -93,6 +95,15 @@ NVIC.TIM17_IRQn=true\:3\:0\:false\:false\:true\:false\:false\:true\:true
|
||||
NVIC.TimeBase=TIM17_IRQn
|
||||
NVIC.TimeBaseIP=TIM17
|
||||
NVIC.USART2_IRQn=true\:3\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
PA0.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
|
||||
PA0.GPIO_Label=ENCODER_A_EXTI0
|
||||
PA0.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
|
||||
PA0.Locked=true
|
||||
PA0.Signal=GPXTI0
|
||||
PA1.GPIOParameters=GPIO_Label
|
||||
PA1.GPIO_Label=ENCODER_B_INPUT
|
||||
PA1.Locked=true
|
||||
PA1.Signal=GPIO_Input
|
||||
PA13.Mode=Serial_Wire
|
||||
PA13.Signal=SYS_SWDIO
|
||||
PA14-BOOT0.Mode=Serial_Wire
|
||||
@@ -102,12 +113,16 @@ PA2.Mode=Asynchronous
|
||||
PA2.Signal=USART2_TX
|
||||
PA3.Mode=Asynchronous
|
||||
PA3.Signal=USART2_RX
|
||||
PA4.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
|
||||
PA4.GPIO_Label=ENCODER_S_EXTI4
|
||||
PA4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
|
||||
PA4.Locked=true
|
||||
PA4.Signal=GPXTI4
|
||||
PA8.GPIOParameters=GPIO_Label
|
||||
PA8.GPIO_Label=BUZZER_PWM_OUT
|
||||
PA8.Locked=true
|
||||
PA8.Signal=S_TIM1_CH1
|
||||
PB0.Locked=true
|
||||
PB0__PB1__PB2__PA8.StandardMode=true
|
||||
PB1.Locked=true
|
||||
PB2.Locked=true
|
||||
PB3__PB4__PB5__PB6.StandardMode=true
|
||||
PB7__PB8.StandardMode=true
|
||||
PC14-OSC32_IN\ (PC14)__PB9.StandardMode=true
|
||||
@@ -155,7 +170,7 @@ ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
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_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_USART2_UART_Init-USART2-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true
|
||||
RCC.ADCFreq_Value=64000000
|
||||
RCC.AHBFreq_Value=64000000
|
||||
RCC.APBFreq_Value=64000000
|
||||
@@ -182,6 +197,10 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||
RCC.USART1Freq_Value=64000000
|
||||
RCC.VCOInputFreq_Value=16000000
|
||||
RCC.VCOOutputFreq_Value=128000000
|
||||
SH.GPXTI0.0=GPIO_EXTI0
|
||||
SH.GPXTI0.ConfNb=1
|
||||
SH.GPXTI4.0=GPIO_EXTI4
|
||||
SH.GPXTI4.ConfNb=1
|
||||
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
|
||||
SH.S_TIM1_CH1.ConfNb=1
|
||||
TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
|
||||
|
||||
Reference in New Issue
Block a user