stm320518_eval_i2c_tsensor.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. ******************************************************************************
  3. * @file stm320518_eval_i2c_tsensor.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 20-April-2012
  7. * @brief This file contains all the functions prototypes for the
  8. * stm320518_eval_i2c_tsensor.c firmware driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM320518_EVAL_I2C_TSENSOR_H
  30. #define __STM320518_EVAL_I2C_TSENSOR_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm320518_eval.h"
  36. /** @addtogroup Utilities
  37. * @{
  38. */
  39. /** @addtogroup STM32_EVAL
  40. * @{
  41. */
  42. /** @addtogroup STM320518_EVAL
  43. * @{
  44. */
  45. /** @addtogroup STM320518_EVAL_I2C_TSENSOR
  46. * @{
  47. */
  48. /** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Types
  49. * @{
  50. */
  51. /**
  52. * @brief TSENSOR Status
  53. */
  54. typedef enum
  55. {
  56. LM75_OK = 0,
  57. LM75_FAIL
  58. }LM75_Status_TypDef;
  59. /**
  60. * @}
  61. */
  62. /** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Constants
  63. * @{
  64. */
  65. /* Uncomment the following line to use Timeout_User_Callback LM75_TimeoutUserCallback().
  66. If This Callback is enabled, it should be implemented by user in main function .
  67. LM75_TimeoutUserCallback() function is called whenever a timeout condition
  68. occure during communication (waiting on an event that doesn't occur, bus
  69. errors, busy devices ...). */
  70. /* #define USE_TIMEOUT_USER_CALLBACK */
  71. /* Maximum Timeout values for flags and events waiting loops. These timeouts are
  72. not based on accurate values, they just guarantee that the application will
  73. not remain stuck if the I2C communication is corrupted.
  74. You may modify these timeout values depending on CPU frequency and application
  75. conditions (interrupts routines ...). */
  76. #define LM75_FLAG_TIMEOUT ((uint32_t)0x1000)
  77. #define LM75_LONG_TIMEOUT ((uint32_t)(10 * LM75_FLAG_TIMEOUT))
  78. /**
  79. * @brief Block Size
  80. */
  81. #define LM75_REG_TEMP 0x00 /*!< Temperature Register of LM75 */
  82. #define LM75_REG_CONF 0x01 /*!< Configuration Register of LM75 */
  83. #define LM75_REG_THYS 0x02 /*!< Temperature Register of LM75 */
  84. #define LM75_REG_TOS 0x03 /*!< Over-temp Shutdown threshold Register of LM75 */
  85. #define I2C_TIMEOUT ((uint32_t)0x3FFFF) /*!< I2C Time out */
  86. #define LM75_ADDR 0x90 /*!< LM75 address */
  87. #define LM75_I2C_TIMING 0x1045061D
  88. /**
  89. * @}
  90. */
  91. /** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Macros
  92. * @{
  93. */
  94. /**
  95. * @}
  96. */
  97. /** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Functions
  98. * @{
  99. */
  100. void LM75_DeInit(void);
  101. void LM75_Init(void);
  102. ErrorStatus LM75_GetStatus(void);
  103. uint16_t LM75_ReadTemp(void);
  104. uint16_t LM75_ReadReg(uint8_t RegName);
  105. uint8_t LM75_WriteReg(uint8_t RegName, uint16_t RegValue);
  106. uint8_t LM75_ReadConfReg(void);
  107. uint8_t LM75_WriteConfReg(uint8_t RegValue);
  108. uint8_t LM75_ShutDown(FunctionalState NewState);
  109. /**
  110. * @brief Timeout user callback function. This function is called when a timeout
  111. * condition occurs during communication with LM75. Only protoype
  112. * of this function is decalred in LM75 driver. Its implementation
  113. * may be done into user application. This function may typically stop
  114. * current operations and reset the I2C peripheral and LM75.
  115. * To enable this function use uncomment the define USE_TIMEOUT_USER_CALLBACK
  116. * at the top of this file.
  117. */
  118. #ifdef USE_TIMEOUT_USER_CALLBACK
  119. uint8_t LM75_TIMEOUT_UserCallback(void);
  120. #else
  121. #define LM75_TIMEOUT_UserCallback() LM75_FAIL
  122. #endif /* USE_TIMEOUT_USER_CALLBACK */
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif /* __STM320518_EVAL_I2C_TSENSOR_H */
  127. /**
  128. * @}
  129. */
  130. /**
  131. * @}
  132. */
  133. /**
  134. * @}
  135. */
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/