#include "led.h"
#include "usart.h"
#include "pms5003.h"
#include "MyUsart.h"
#include "timer.h"
#include "timer2.h"
#include "NTCtp.h"
#include "stdio.h"
#include "string.h"
extern uint8_t data_buffer[100];
extern uint8_t data_cnt;
extern uint8_t har;
extern uint8_t sum;
extern uint32_t Resultvolt;
extern uint32_t Resistance;
extern uint32_t electricity;
extern int Temp;
uint32_t tick1ms;
int PM2_5;
int main()
{
static uint32_t led_timer = 0;
static uint32_t NTC_timer = 0;
static uint32_t PMS5003_timer = 0;
//SysTick_Config_Init();
led_gpio_init();
NTCtp_config();
pms5003_config();
while(1)
{
if (tick1ms - led_timer >= 500)
{
led_timer = tick1ms;
//GPIO_ResetBits(GPIOB,GPIO_Pin_7);
GPIOB->ODR ^= GPIO_Pin_7;
}
if (tick1ms - NTC_timer >= 500)
{
NTC_timer = tick1ms;
look_up_table();
printf("电压是%dmv
",Resultvolt); //NTC电压
printf("电流是%dμA
",electricity); //电流
printf("电阻是%dΩ
",Resistance); //NTC电阻 ;
printf("温度是%d°C
",Temp);
}
if (tick1ms - PMS5003_timer >= 500)
{
PMS5003_timer = tick1ms;
while(data_cnt == 32)
{
PM2_5 = (int)data_buffer[12] * 256 + (int)data_buffer[13]; //PM2.5
printf("PM2.5 is %d ug/m3
", PM2_5);
if(data_cnt >= 32)
{
data_cnt = 0;
}
}
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>