| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "timer.h"
- #include "read.h"
- bool Start_80_hz = false;
- bool Start_10_hz = false;
- bool Start_5_hz = false;
- bool Start_1_hz = false;
- // 12.5ms进一次中断
- void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
- {
- static uint8_t time_count = 0;
- Start_80_hz = true;
- time_count++;
- if (time_count % 8 == 0)
- {
- Start_10_hz = true;
- }
- if (time_count % 26 == 0)
- {
- Start_5_hz = true;
- }
- if (time_count % 80 == 0)
- {
- Start_1_hz = true;
- time_count = 0;
- }
- }
- void delay_us(uint16_t us)
- {
- HAL_TIM_Base_Start(&htim3);
- __HAL_TIM_SET_COUNTER(&htim3, 0); // 清零计数
- us = (us > 4) ? (us - 2) : 1;
- while (us > __HAL_TIM_GET_COUNTER(&htim3))
- ;
- HAL_TIM_Base_Stop(&htim3);
- }
|