1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef __DS18B20_H__
- #define __DS18B20_H__
- #include "define.h"
- #ifndef HIGH
- #define HIGH 1
- #endif
- #ifndef LOW
- #define LOW 0
- #endif
- //IO操作函数
- #define DS18B20_HIGH nrf_gpio_pin_write(DS18B20_DATA, 1);
- #define DS18B20_LOW nrf_gpio_pin_write(DS18B20_DATA, 0);
- #define DS18B20_IN nrf_gpio_pin_read(DS18B20_DATA) //输入SDA
- #define DS18B20_SET_TIME_LEN 600000
- typedef enum
- {
- DS18B20_QUEUE_TIME=0,
- DS18B20_QUEUE_INT=1,
- }DS18B20_QUEUE_TYPE;
- typedef enum {
- SIGN_NULL=0,
- SIGN_OK=1,
- SIGN_ERR=2
- }DS18B20_SIGN_STATUS;
- typedef struct{
- DS18B20_SIGN_STATUS sign;
- float temperture;
- }ds18b20_data_s;
- typedef void (*ds18b20_finish_func)(bool stat);
- typedef struct{
- ds18b20_finish_func finish_func;
- unsigned char timeout;
- bool is_readtemperture;
- bool ds18b20_lock;
- uint8_t ds18b20_status;
- unsigned char count;
- float value[3];
- }ds18b20_work_s;
- extern ds18b20_data_s ds18b20_data;
- void DS18B20_Gpio_Init(void);
- void DS18B20_timers_init(void);
- void set_Ds18b20_finish_func(ds18b20_finish_func func);
- void Set_Ds18b20_Queue(DS18B20_QUEUE_TYPE type);
- void Ds18b20_Start(void);
- #endif
|