Main.c文件示例#include "stm32f4xx.h" // Device header
#include "led.h"
#include "delay.h"
#include "key.h"
#include "usart.h"
#include "sys.h"
#include "exti.h"
#include "timer.h"
#include "pwm.h"
#include "ds18b20.h"
int main(void)
{
short temp;
unsigned short intT,decT; //温度值的整数和小数部分
LED_Init();
KEY_Init();
USART1_Init(84,115200);
KEY_EXTI_Init();
DS18B20_Init();
while(1)
{
/*读取温度信息*/
temp=DS18B20_Get_Temp();
intT = temp >> 4; //分离出温度值整数部分
decT = temp & 0xF; //分离出温度值小数部分
printf("DS18B20: %d.%d *C\r\n",(int)intT,(int)decT);
DelayMs(1000);
}
}
|