72 lines
1.5 KiB
C
72 lines
1.5 KiB
C
#include "timer.h"
|
|
|
|
#include "ads1220.h"
|
|
#include "adcs.h"
|
|
#include "lvgl.h"
|
|
#include "events_init.h"
|
|
|
|
int Direction;
|
|
int CaptureNumber = 30000;
|
|
int last_CaptureNumber = 30000;
|
|
int key2_tim_cnt = 0;
|
|
int key3_tim_cnt = 0;
|
|
|
|
int tim_cnt = 0;
|
|
|
|
extern long ads1230_vol;
|
|
|
|
extern void get_ads1230_vol(void);
|
|
|
|
//重写TIM中断调用函数
|
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|
{
|
|
if(htim == &htim6)
|
|
{
|
|
lv_tick_inc(1);
|
|
adc_sample(); //电池电压
|
|
if(screen_id == 1)
|
|
{
|
|
#if USE_ADS1220
|
|
CaptureNumber=__HAL_TIM_GET_COUNTER(&htim1); //读取脉冲计数值
|
|
|
|
get_data(); //采样电压
|
|
|
|
//每次位移超过0.5mm,获取一个采样点数据
|
|
if(test_status == 2 && abs(CaptureNumber - last_CaptureNumber) > 14)
|
|
{
|
|
last_CaptureNumber = CaptureNumber;
|
|
point_data.loca[point_data.cnt] = CaptureNumber;
|
|
point_data.vol[point_data.cnt] = ads1220_data;
|
|
point_data.cnt++;
|
|
}
|
|
#else
|
|
tim_cnt++;
|
|
if(tim_cnt > 14)
|
|
{
|
|
tim_cnt = 0;
|
|
CaptureNumber=__HAL_TIM_GET_COUNTER(&htim1); //读取脉冲计数值
|
|
|
|
get_ads1230_vol(); //采样电压
|
|
|
|
//每次位移超过0.5mm,获取一个采样点数据
|
|
if(test_status == 2 && abs(CaptureNumber - last_CaptureNumber) > 14)
|
|
{
|
|
last_CaptureNumber = CaptureNumber;
|
|
point_data.loca[point_data.cnt] = CaptureNumber;
|
|
point_data.vol[point_data.cnt] = ads1230_vol;
|
|
point_data.cnt++;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
|
|
}
|
|
if(htim == &htim1)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
|