From 364a8e6f6c361fc92289fa6844b5c39d16682c79 Mon Sep 17 00:00:00 2001 From: DrZlo13 Date: Fri, 9 Oct 2020 02:34:43 +1000 Subject: [PATCH] Fix input (#166) * fixed inline functions for modern C standart * Fix button-left and button-back setup code * *nix fix Co-authored-by: aanper --- firmware/targets/f2/Inc/main.h | 1 + firmware/targets/f2/Inc/stm32l4xx_it.h | 1 + firmware/targets/f2/Src/gpio.c | 15 ++++++--------- firmware/targets/f2/Src/stm32l4xx_it.c | 14 ++++++++++++++ firmware/targets/f2/cube.ioc | 10 +++++++--- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/firmware/targets/f2/Inc/main.h b/firmware/targets/f2/Inc/main.h index b2e76a7e..6a96ec46 100644 --- a/firmware/targets/f2/Inc/main.h +++ b/firmware/targets/f2/Inc/main.h @@ -60,6 +60,7 @@ void Error_Handler(void); /* Private defines -----------------------------------------------------------*/ #define BUTTON_BACK_Pin GPIO_PIN_13 #define BUTTON_BACK_GPIO_Port GPIOC +#define BUTTON_BACK_EXTI_IRQn EXTI15_10_IRQn #define CHRG_Pin GPIO_PIN_2 #define CHRG_GPIO_Port GPIOC #define CHRG_EXTI_IRQn EXTI2_IRQn diff --git a/firmware/targets/f2/Inc/stm32l4xx_it.h b/firmware/targets/f2/Inc/stm32l4xx_it.h index 8fa9860e..47b48949 100644 --- a/firmware/targets/f2/Inc/stm32l4xx_it.h +++ b/firmware/targets/f2/Inc/stm32l4xx_it.h @@ -59,6 +59,7 @@ void EXTI2_IRQHandler(void); void EXTI4_IRQHandler(void); void EXTI9_5_IRQHandler(void); void TIM1_TRG_COM_TIM17_IRQHandler(void); +void EXTI15_10_IRQHandler(void); void TIM8_CC_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/firmware/targets/f2/Src/gpio.c b/firmware/targets/f2/Src/gpio.c index 8102df17..8b7d7c0b 100644 --- a/firmware/targets/f2/Src/gpio.c +++ b/firmware/targets/f2/Src/gpio.c @@ -66,7 +66,7 @@ void MX_GPIO_Init(void) /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = BUTTON_BACK_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(BUTTON_BACK_GPIO_Port, &GPIO_InitStruct); @@ -108,8 +108,8 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PBPin PBPin PBPin */ - GPIO_InitStruct.Pin = BUTTON_UP_Pin|BUTTON_RIGHT_Pin|BUTTON_OK_Pin; + /*Configure GPIO pins : PBPin PBPin PBPin PBPin */ + GPIO_InitStruct.Pin = BUTTON_UP_Pin|BUTTON_LEFT_Pin|BUTTON_RIGHT_Pin|BUTTON_OK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); @@ -147,12 +147,6 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pin : PtPin */ - GPIO_InitStruct.Pin = BUTTON_LEFT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - HAL_GPIO_Init(BUTTON_LEFT_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = CC1101_G0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; @@ -175,6 +169,9 @@ void MX_GPIO_Init(void) HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + } /* USER CODE BEGIN 2 */ diff --git a/firmware/targets/f2/Src/stm32l4xx_it.c b/firmware/targets/f2/Src/stm32l4xx_it.c index 6003a63b..6dfe949a 100644 --- a/firmware/targets/f2/Src/stm32l4xx_it.c +++ b/firmware/targets/f2/Src/stm32l4xx_it.c @@ -245,6 +245,20 @@ void TIM1_TRG_COM_TIM17_IRQHandler(void) /* USER CODE END TIM1_TRG_COM_TIM17_IRQn 1 */ } +/** + * @brief This function handles EXTI line[15:10] interrupts. + */ +void EXTI15_10_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI15_10_IRQn 0 */ + + /* USER CODE END EXTI15_10_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13); + /* USER CODE BEGIN EXTI15_10_IRQn 1 */ + + /* USER CODE END EXTI15_10_IRQn 1 */ +} + /** * @brief This function handles TIM8 capture compare interrupt. */ diff --git a/firmware/targets/f2/cube.ioc b/firmware/targets/f2/cube.ioc index c0908d2a..82ebbba1 100644 --- a/firmware/targets/f2/cube.ioc +++ b/firmware/targets/f2/cube.ioc @@ -35,6 +35,7 @@ PA14\ (JTCK-SWCLK).Signal=SYS_JTCK-SWCLK RCC.LPTIM1Freq_Value=64000000 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false NVIC.EXTI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +PB4\ (NJTRST).GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING RCC.ADCCLockSelection=RCC_ADCCLKSOURCE_SYSCLK SPI1.Direction=SPI_DIRECTION_2LINES RCC.APB2TimFreq_Value=64000000 @@ -47,6 +48,7 @@ PA1.GPIO_PuPd=GPIO_PULLDOWN RCC.PREFETCH_ENABLE=1 PB13.Locked=true RCC.USART3Freq_Value=64000000 +NVIC.EXTI15_10_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PA0.Locked=true @@ -214,8 +216,8 @@ ADC1.master=1 PA3.Locked=true Mcu.Pin21=PB2 PA10.Locked=true -NVIC.ForceEnableDMAVector=true PA14\ (JTCK-SWCLK).Locked=true +NVIC.ForceEnableDMAVector=true NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false ProjectManager.CompilerOptimize=6 PA11.Signal=USB_OTG_FS_DM @@ -314,6 +316,7 @@ Mcu.Pin0=PC13 SPI3.DataSize=SPI_DATASIZE_8BIT Mcu.Pin1=PC14-OSC32_IN (PC14) TIM8.IPParameters=Channel-Input_Capture2_from_TI2,ICPolarity_CH2,Prescaler,Period +GPIO.groupedBy=Group By Peripherals Mcu.Pin2=PC15-OSC32_OUT (PC15) Mcu.Pin3=PH0-OSC_IN (PH0) Mcu.Pin4=PH1-OSC_OUT (PH1) @@ -399,7 +402,7 @@ PC8.GPIO_Label=DISPLAY_CS USART1.VirtualMode-Asynchronous=VM_ASYNC FREERTOS.configUSE_IDLE_HOOK=1 PA9.Mode=Asynchronous -PB4\ (NJTRST).GPIOParameters=GPIO_PuPd,GPIO_Label +PB4\ (NJTRST).GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI NVIC.TIM8_CC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true PB14.PinState=GPIO_PIN_SET ProjectManager.TargetToolchain=Makefile @@ -425,7 +428,7 @@ RCC.UART4Freq_Value=64000000 SPI3.CalculateBaudRate=1000.0 KBits/s MxCube.Version=6.0.1 PA13\ (JTMS-SWDIO).GPIO_Label=TMS -PC13.GPIOParameters=GPIO_PuPd,GPIO_Label +PC13.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI RCC.PLLSAI1QoutputFreq_Value=48000000 RCC.ADCFreq_Value=64000000 SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 @@ -456,6 +459,7 @@ SH.GPXTI4.0=GPIO_EXTI4 RCC.PLLSAI2PoutputFreq_Value=9142857.142857144 KeepUserPlacement=false TIM5.Prescaler=500 - 1 +PC13.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PC5.GPIO_Label=RFID_RF_IN PC14-OSC32_IN\ (PC14).Signal=RCC_OSC32_IN SH.GPXTI9.ConfNb=1