nrf_ds18b20.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __DS18B20_H__
  2. #define __DS18B20_H__
  3. #include "define.h"
  4. #ifndef HIGH
  5. #define HIGH 1
  6. #endif
  7. #ifndef LOW
  8. #define LOW 0
  9. #endif
  10. //IO操作函数
  11. #define DS18B20_HIGH nrf_gpio_pin_write(DS18B20_DATA, 1);
  12. #define DS18B20_LOW nrf_gpio_pin_write(DS18B20_DATA, 0);
  13. #define DS18B20_IN nrf_gpio_pin_read(DS18B20_DATA) //输入SDA
  14. #define DS18B20_SET_TIME_LEN 600000
  15. typedef enum
  16. {
  17. DS18B20_QUEUE_TIME=0,
  18. DS18B20_QUEUE_INT=1,
  19. }DS18B20_QUEUE_TYPE;
  20. typedef enum {
  21. SIGN_NULL=0,
  22. SIGN_OK=1,
  23. SIGN_ERR=2
  24. }DS18B20_SIGN_STATUS;
  25. typedef struct{
  26. DS18B20_SIGN_STATUS sign;
  27. float temperture;
  28. }ds18b20_data_s;
  29. typedef void (*ds18b20_finish_func)(bool stat);
  30. typedef struct{
  31. ds18b20_finish_func finish_func;
  32. unsigned char timeout;
  33. bool is_readtemperture;
  34. bool ds18b20_lock;
  35. uint8_t ds18b20_status;
  36. unsigned char count;
  37. float value[3];
  38. }ds18b20_work_s;
  39. extern ds18b20_data_s ds18b20_data;
  40. void DS18B20_Gpio_Init(void);
  41. void DS18B20_timers_init(void);
  42. void set_Ds18b20_finish_func(ds18b20_finish_func func);
  43. void Set_Ds18b20_Queue(DS18B20_QUEUE_TYPE type);
  44. void Ds18b20_Start(void);
  45. #endif