52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
/*
|
|
* @Author: DaMing zxm5337@163.com
|
|
* @Date: 2024-04-07 15:32:20
|
|
* @LastEditors: DaMing zxm5337@163.com
|
|
* @LastEditTime: 2024-04-08 18:42:07
|
|
* @FilePath: \Proxi_CheckBoard\User\App\ds18b20.h
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
|
|
#ifndef __DS18B20_H__
|
|
#define __DS18B20_H__
|
|
#include "gpio.h"
|
|
#include "data_type_def.h"
|
|
|
|
#define WRITE_MEMORY 0X4E
|
|
#define SKIP_ROM 0XCC
|
|
#define TEMP_SWITCH 0X44
|
|
#define READ_MEMORY 0XBE
|
|
|
|
typedef void (*write_pin_cb_t)(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
|
|
typedef GPIO_PinState (*read_pin_cb_t)(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
|
|
|
|
typedef struct
|
|
{
|
|
GPIO_TypeDef *TX_GPIOx;
|
|
uint16_t TX_GPIO_Pin;
|
|
GPIO_TypeDef *RX_GPIOx;
|
|
uint16_t RX_GPIO_Pin;
|
|
|
|
write_pin_cb_t write_pin_cb;
|
|
read_pin_cb_t read_pin_cb;
|
|
} bus_port_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t index;
|
|
bus_port_t ds18b20_ports;
|
|
float32_u temperature;
|
|
|
|
uint8_t (*check)(bus_port_t *bus_port);
|
|
void (*write_cmd)(bus_port_t *bus_port, uint8_t cmd);
|
|
uint8_t (*read_data)(bus_port_t *bus_port);
|
|
} ds18b20_t;
|
|
|
|
extern bus_port_t bus_port_A, bus_port_B;
|
|
extern ds18b20_t ds18b20_A, ds18b20_B;
|
|
void fun_ini_bus_port(bus_port_t *bus_port);
|
|
void fun_ini_ds18b20(ds18b20_t *ds18b20);
|
|
void ds18b20_read_temperature_cb(bus_port_t *bus_port, ds18b20_t *ds18b20);
|
|
|
|
#endif
|