中级会员
 
- 积分
- 405
- 金钱
- 405
- 注册时间
- 2019-3-21
- 在线时间
- 107 小时
|
10金钱
#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\r\n",Resultvolt); //NTC电压
printf("电流是%dμA\r\n",electricity); //电流
printf("电阻是%dΩ\r\n",Resistance); //NTC电阻 ;
printf("温度是%d°C\r\n",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\r\n", PM2_5);
if(data_cnt >= 32)
{
data_cnt = 0;
}
}
}
}
}
|
|