You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/*
|
|
|
|
* @Author: your name
|
|
|
|
* @Date: 2022-04-10 12:08:03
|
|
|
|
* @LastEditTime: 2022-04-13 02:13:14
|
|
|
|
* @LastEditors: your name
|
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
|
* @FilePath: \20220410-IntelligentPiggery\stm32\HARDWARE\DS18B20\ds18b20.h
|
|
|
|
*/
|
|
|
|
#ifndef __DS18B20_H
|
|
|
|
#define __DS18B20_H
|
|
|
|
#include "sys.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//本程序只供学习使用,未经作者许可,不得用于其它任何用途
|
|
|
|
//ALIENTEK MiniSTM32开发板
|
|
|
|
//DS18B20驱动代码
|
|
|
|
//正点原子@ALIENTEK
|
|
|
|
//技术论坛:www.openedv.com
|
|
|
|
//修改日期:2014/3/12
|
|
|
|
//版本:V1.0
|
|
|
|
//版权所有,盗版必究。
|
|
|
|
//Copyright(C) 广州市星翼电子科技有限公司 2009-2019
|
|
|
|
//All rights reserved
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//IO方向设置
|
|
|
|
#define DS18B20_IO_IN() {GPIOA->CRL&=0XFFFF0FFF;GPIOA->CRL|=8<<12;}
|
|
|
|
#define DS18B20_IO_OUT() {GPIOA->CRL&=0XFFFF0FFF;GPIOA->CRL|=3<<12;}
|
|
|
|
|
|
|
|
////IO操作函数
|
|
|
|
#define DS18B20_DQ_OUT PAout(3) //数据端口 PA0
|
|
|
|
#define DS18B20_DQ_IN PAin(3) //数据端口 PA0
|
|
|
|
|
|
|
|
u8 DS18B20_Init(void); //初始化DS18B20
|
|
|
|
short DS18B20_Get_Temp(void); //获取温度
|
|
|
|
void DS18B20_Start(void); //开始温度转换
|
|
|
|
void DS18B20_Write_Byte(u8 dat);//写入一个字节
|
|
|
|
u8 DS18B20_Read_Byte(void); //读出一个字节
|
|
|
|
u8 DS18B20_Read_Bit(void); //读出一个位
|
|
|
|
u8 DS18B20_Check(void); //检测是否存在DS18B20
|
|
|
|
void DS18B20_Rst(void); //复位DS18B20
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|