📄 temp.c~
字号:
#include <mega128.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "typedef.h"
#include "app.h"
#include "attention.h"
#include "g20modem.h"
#include "g20serialdrv.h"
#include "rtc.h"
#include "serialdrv.h"
#include "timer.h"
#include "UDP.h"
#include "protocol.h"
#include "temp.h"
// 1 Wire Bus functions
#asm
.equ __w1_port=0x1B ;PORTA
.equ __w1_bit=0
#endasm
#include <1wire.h>
// DS1820 Temperature Sensor functions
#include <ds1820.h>
// number of DS1820 devices
// connected to the 1 Wire bus
unsigned char ds1820_devices = 0;
// DS1820 devices ROM code storage area,
// 9 bytes are used for each device
// (see the w1_search function description in the help)
unsigned char ds1820_rom_codes[MAX_DS1820][9];
int ds1820_temp[MAX_DS1820];
void temp_init(void)
{
// Determine the number of DS1820 devices
// connected to the 1 Wire bus
ds1820_devices = w1_search(0xf0,ds1820_rom_codes);
}
void temp_detect(void)
{
unsigned char i;
if (ds1820_devices)
{
for (i=0;i<ds1820_devices;i++)
{
ds1820_temp[i]=ds1820_temperature_10(&ds1820_rom_codes[0,0]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -