18 lines
520 B
C
18 lines
520 B
C
#ifndef __DS18B20_H
|
|
#define __DS18B20_H
|
|
|
|
#include "main.h"
|
|
|
|
//IO方向设置
|
|
#define DS18B20_IO_IN() {GPIOC->MODER &= 0xFFFFFFF3;;}
|
|
#define DS18B20_IO_OUT() {GPIOC->MODER &= 0xFFFFFFF3; GPIOC -> MODER |= (uint32_t)(1 << 2);}
|
|
//IO操作函数
|
|
#define DS18B20_DQ_OUT(x) HAL_GPIO_WritePin(GPIOC,GPIO_PIN_1,(GPIO_PinState)x) //数据端口
|
|
#define DS18B20_DQ_IN HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_1) //数据端口
|
|
|
|
uint8_t ds18b20_init(void);//初始化DS18B20
|
|
short ds18b20_get_temp(void);//获取温度
|
|
|
|
|
|
#endif
|