DS18B20_ATY.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @file DS18B20_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2026 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief functions of DS18B20 for C platform (Dev-style)
  20. *
  21. * @version
  22. * - 1_01_251112 > ATY
  23. * -# Refactor to Dev-style; remove legacy STM32-specific interfaces
  24. ********************************************************************************
  25. */
  26. #ifndef __DS18B20_ATY_H
  27. #define __DS18B20_ATY_H
  28. #include "INCLUDE_ATY.h"
  29. /******************************* For user *************************************/
  30. // Set AD0 voltage level for device address
  31. #define AD5245_AD0 1
  32. #define __DEBUG_DS18B20_ATY
  33. /******************************************************************************/
  34. // 0 1 0 1 1 0 AD0 R/W
  35. #define AD5245_ADDRESS (0x2C | AD5245_AD0)
  36. struct DS18B20_ATY_Dev
  37. {
  38. void (*drive_low)(void);
  39. void (*release_bus)(void);
  40. uint8_t (*read_bus)(void);
  41. void (*delay_us)(uint16_t us);
  42. uint8_t lock;
  43. uint8_t debugEnable;
  44. void (*LOG)(const char* s);
  45. };
  46. uint8_t DS18B20_InitDev(struct DS18B20_ATY_Dev* dev);
  47. void DS18B20_ResetDev(struct DS18B20_ATY_Dev* dev);
  48. uint8_t DS18B20_CheckReadyDev(struct DS18B20_ATY_Dev* dev);
  49. void DS18B20_WriteByteDev(struct DS18B20_ATY_Dev* dev, uint8_t cmd);
  50. uint8_t DS18B20_ReadByteDev(struct DS18B20_ATY_Dev* dev);
  51. uint16_t DS18B20_GetTemperatureDev(struct DS18B20_ATY_Dev* dev);
  52. uint8_t DS18B20_ReadRomInfoDev(struct DS18B20_ATY_Dev* dev, uint8_t rom8[8]);
  53. #endif /* __DS18B20_ATY_H */
  54. /******************************** End Of File *********************************/