sht21.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _DEV_SHT21_H_
  2. #define _DEV_SHT21_H_
  3. /*
  4. * Copyright (C) 2010 by Rittal GmbH & Co. KG,
  5. * Dawid Sadji <sadji.d@rittal.de> All rights reserved.
  6. * Ulrich Prinz <prinz.u@rittal.de> All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY EMBEDDED IT AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMBEDDED IT
  25. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  28. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  30. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  31. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. * For additional information see http://www.ethernut.de/
  34. *
  35. */
  36. /*
  37. * \verbatim
  38. * $Id:$
  39. * \endverbatim
  40. */
  41. #include <cfg/sht21.h>
  42. #ifndef I2C_SLA_SHT21
  43. #define I2C_SLA_SHT21 0x40
  44. #endif
  45. /*
  46. * Sensirion common sensor commands
  47. */
  48. #ifdef SHT_ACK_POLLING
  49. #define SHT_GET_TEMP 0xF3 /* Get Temperature Command */
  50. #define SHT_GET_HUM 0xF5 /* Get Humidity Command */
  51. #else
  52. #define SHT_GET_TEMP 0xE3 /* Get Temperature Command */
  53. #define SHT_GET_HUM 0xE5 /* Get Humidity Command */
  54. #endif
  55. #define SHT_SET_USER 0xE6 /* Set User Register Command */
  56. #define SHT_GET_USER 0xE7 /* Get User Register Command */
  57. #define SHT_SOFT_RESET 0xFE /* Soft Reset Command */
  58. #define SHT_READ_OCM 0xFA /* Read On Chip Memory Command */
  59. #define SHT_GET_SERNR 0x0F /* Read OCM: Serial Number */
  60. /* Bit definitions of User Register */
  61. #define SHT_RES_12_14 0x00 /* Resolution: RH=12bit, T=14bit */
  62. #define SHT_RES_8_12 0x01 /* Resolution: RH= 8bit, T=12bit */
  63. #define SHT_RES_10_13 0x80 /* Resolution: RH=10bit, T=13bit */
  64. #define SHT_RES_11_11 0x81 /* Resolution: RH=11bit, T=11bit */
  65. #define SHT_RES_MASK 0x81 /* Resolution: Mask for res. bits */
  66. #define SHT_USER_EOB 0x40 /* User Register: End Of Battery Flag */
  67. #define SHT_USER_HTR 0x04 /* User Register: Heater On Flag */
  68. int ShtCrc(uint8_t *Data, uint8_t Size);
  69. int ShtCommand(uint8_t cmd, uint16_t *data);
  70. int ShtRead( uint8_t cmd, int16_t *val);
  71. int ShtInit(void);
  72. #endif /* _DEV_SHT21_H_ */