You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
#include "timer.h" |
|
#include "led.h" |
|
#include "wifi.h" |
|
#include "math.h" |
|
#include "encoder.h" |
|
|
|
extern char smog_value_buf[7]; |
|
extern char temp_value_buf[7]; |
|
extern char beam_value_buf[7]; |
|
|
|
extern struct UserInfo userInfo; |
|
|
|
|
|
void TIM3_Int_Init(u16 arr,u16 psc) |
|
{ |
|
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; |
|
NVIC_InitTypeDef NVIC_InitStructure; |
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); |
|
|
|
TIM_TimeBaseStructure.TIM_Period = arr; |
|
TIM_TimeBaseStructure.TIM_Prescaler =psc; |
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0; |
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; |
|
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); |
|
|
|
TIM_ITConfig( |
|
TIM3, |
|
TIM_IT_Update , |
|
ENABLE |
|
); |
|
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; |
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; |
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; |
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
|
NVIC_Init(&NVIC_InitStructure); |
|
|
|
TIM_Cmd(TIM3, ENABLE); |
|
|
|
} |
|
|
|
|
|
void TIM3_IRQHandler(void) |
|
{ |
|
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) |
|
{ |
|
userInfo.currentSpeed = Read_Encoder(2); |
|
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|