⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 DS18B20源代码
💻 C
字号:
/****************************************
*   project:Ds18b20
*   Author:panda
*   Date: 2006.12.9
*   output: JTAG
*****************************************/

//#include <avr/signal.h>
#include <avr/io.h>
#include "ds18b20.h"
#include "usart.h"
#include "delay.h"
//#include "bit_set.h"

/*------宏定义------*/
#define uchar	unsigned char
#define uint	unsigned int
#define BIT(x)	(1<<(x))
#define NOP()	asm("nop")
#define WDR() 	asm("wdr")
#define sei() asm("sei")
#define cli() asm("cli")

static unsigned int temp;
int temp2=0; // for debugging

//端口初始化
void port_init(void)
{
	PORTA = 0xFF;
	DDRA  = 0xFF;
	PORTB = 0xFF;
	DDRB  = 0xFF;
	PORTC = 0xFF;
	DDRC  = 0xFF;
	PORTD = 0xFF;
	DDRD  = 0xFF;
}


void init_devices(void)
{
	cli(); //禁止所有中断
	MCUCR  = 0x00;   //全局中断打开
	MCUCSR = 0x80;//禁止JTAG
	GICR   = 0x00;
	port_init();
	//timer1_init();
	usart_init();
	sei();//开全局中断
}

//主函数

int main()
{
 init_devices();
	for(;;)
	{
			temp=reset_ds18b20();
		 temp2=(get_the_temprature())>>4;
   //temp2=byte_to_ds18b20(0x11);
			delay_xms(100);
			printf(temp);
	}
	return 0;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -