Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main
- uint8_t zapal = 0;
- uint8_t pushCount = 0;
- while (1)
- {
- if(zapal)
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
- else
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
- }
- //sysTick
- extern uint8_t pushCount;
- extern uint8_t zapal;
- uint32_t time_ms = 0;
- void SysTick_Handler(void)
- {
- /* USER CODE BEGIN SysTick_IRQn 0 */
- /* USER CODE END SysTick_IRQn 0 */
- HAL_IncTick();
- HAL_SYSTICK_IRQHandler();
- /* USER CODE BEGIN SysTick_IRQn 1 */
- time_ms++;
- if(!HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13))
- {
- pushCount++;
- if(pushCount > 3)
- pushCount = 1;
- }
- if(pushCount == 1 && time_ms > 500) // 1Hz
- {
- if(zapal)
- zapal = 0;
- else
- zapal = 1;
- time_ms = 0;
- }
- if(pushCount == 2 && time_ms > 250) // 2Hz
- {
- if(zapal)
- zapal = 0;
- else
- zapal = 1;
- time_ms = 0;
- }
- if(pushCount == 3 && time_ms > 125) // 4Hz
- {
- if(zapal)
- zapal = 0;
- else
- zapal = 1;
- time_ms = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement