add button test at the board startup, part 2

This commit is contained in:
ІО-23 Шмуляр Олег 2025-03-08 14:43:54 +02:00
parent 82a3907d8a
commit 0b8a55a9e2
4 changed files with 20 additions and 6 deletions

View File

@ -58,6 +58,7 @@ void SysTick_Handler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
void EXTI0_IRQHandler(void); void EXTI0_IRQHandler(void);
void EXTI9_5_IRQHandler(void);
/* USER CODE END EFP */ /* USER CODE END EFP */

View File

@ -53,7 +53,7 @@ void ((*executors[])(void)) = {
external_temp_show_fahrenheit external_temp_show_fahrenheit
}; };
int current_executor_id = 0; size_t current_executor_id = 0;
/* USER CODE END PV */ /* USER CODE END PV */
@ -174,14 +174,13 @@ int main(void)
HAL_NVIC_EnableIRQ(EXTI0_IRQn); HAL_NVIC_EnableIRQ(EXTI0_IRQn);
// switch mode for SW5 (alternative advancing method) // switch mode for SW5 (alternative advancing method)
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI8_IRQn, 0, 0); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI8_IRQn); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

View File

@ -41,7 +41,7 @@
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
extern int current_executor_id; extern size_t current_executor_id;
/* USER CODE END PV */ /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
@ -214,4 +214,18 @@ void EXTI0_IRQHandler(void)
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
} }
void EXTI9_5_IRQHandler(void)
{
GPIOD->ODR = 0x1000;
current_executor_id += 1;
current_executor_id %= 2;
for (int i = 900000; i > 0; i--) asm("nop");
GPIOD->ODR = 0x0000;
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
}
/* USER CODE END 1 */ /* USER CODE END 1 */

View File

@ -157,4 +157,4 @@ SH.ADCx_IN9.ConfNb=1
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
board=custom board=custom
isbadioc=true isbadioc=false