DHT11

Committer:
jhon309
Date:
Thu Aug 13 00:21:57 2015 +0000
Revision:
0:c52df770855b
DHT11

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:c52df770855b 1 /**
jhon309 0:c52df770855b 2 ******************************************************************************
jhon309 0:c52df770855b 3 * @file stm32f0xx_hal_smbus.h
jhon309 0:c52df770855b 4 * @author MCD Application Team
jhon309 0:c52df770855b 5 * @version V1.2.0
jhon309 0:c52df770855b 6 * @date 11-December-2014
jhon309 0:c52df770855b 7 * @brief Header file of SMBUS HAL module.
jhon309 0:c52df770855b 8 ******************************************************************************
jhon309 0:c52df770855b 9 * @attention
jhon309 0:c52df770855b 10 *
jhon309 0:c52df770855b 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
jhon309 0:c52df770855b 12 *
jhon309 0:c52df770855b 13 * Redistribution and use in source and binary forms, with or without modification,
jhon309 0:c52df770855b 14 * are permitted provided that the following conditions are met:
jhon309 0:c52df770855b 15 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:c52df770855b 16 * this list of conditions and the following disclaimer.
jhon309 0:c52df770855b 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:c52df770855b 18 * this list of conditions and the following disclaimer in the documentation
jhon309 0:c52df770855b 19 * and/or other materials provided with the distribution.
jhon309 0:c52df770855b 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:c52df770855b 21 * may be used to endorse or promote products derived from this software
jhon309 0:c52df770855b 22 * without specific prior written permission.
jhon309 0:c52df770855b 23 *
jhon309 0:c52df770855b 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:c52df770855b 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:c52df770855b 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:c52df770855b 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:c52df770855b 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:c52df770855b 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:c52df770855b 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:c52df770855b 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:c52df770855b 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:c52df770855b 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:c52df770855b 34 *
jhon309 0:c52df770855b 35 ******************************************************************************
jhon309 0:c52df770855b 36 */
jhon309 0:c52df770855b 37
jhon309 0:c52df770855b 38 /* Define to prevent recursive inclusion -------------------------------------*/
jhon309 0:c52df770855b 39 #ifndef __STM32F0xx_HAL_SMBUS_H
jhon309 0:c52df770855b 40 #define __STM32F0xx_HAL_SMBUS_H
jhon309 0:c52df770855b 41
jhon309 0:c52df770855b 42 #ifdef __cplusplus
jhon309 0:c52df770855b 43 extern "C" {
jhon309 0:c52df770855b 44 #endif
jhon309 0:c52df770855b 45
jhon309 0:c52df770855b 46 /* Includes ------------------------------------------------------------------*/
jhon309 0:c52df770855b 47 #include "stm32f0xx_hal_def.h"
jhon309 0:c52df770855b 48
jhon309 0:c52df770855b 49 /** @addtogroup STM32F0xx_HAL_Driver
jhon309 0:c52df770855b 50 * @{
jhon309 0:c52df770855b 51 */
jhon309 0:c52df770855b 52
jhon309 0:c52df770855b 53 /** @addtogroup SMBUS
jhon309 0:c52df770855b 54 * @{
jhon309 0:c52df770855b 55 */
jhon309 0:c52df770855b 56
jhon309 0:c52df770855b 57 /* Exported types ------------------------------------------------------------*/
jhon309 0:c52df770855b 58 /** @defgroup SMBUS_Exported_Types SMBUS Exported Types
jhon309 0:c52df770855b 59 * @{
jhon309 0:c52df770855b 60 */
jhon309 0:c52df770855b 61
jhon309 0:c52df770855b 62 /**
jhon309 0:c52df770855b 63 * @brief SMBUS Configuration Structure definition
jhon309 0:c52df770855b 64 */
jhon309 0:c52df770855b 65 typedef struct
jhon309 0:c52df770855b 66 {
jhon309 0:c52df770855b 67 uint32_t Timing; /*!< Specifies the SMBUS_TIMINGR_register value.
jhon309 0:c52df770855b 68 This parameter calculated by referring to SMBUS initialization
jhon309 0:c52df770855b 69 section in Reference manual */
jhon309 0:c52df770855b 70 uint32_t AnalogFilter; /*!< Specifies if Analog Filter is enable or not.
jhon309 0:c52df770855b 71 This parameter can be a a value of @ref SMBUS_Analog_Filter */
jhon309 0:c52df770855b 72
jhon309 0:c52df770855b 73 uint32_t OwnAddress1; /*!< Specifies the first device own address.
jhon309 0:c52df770855b 74 This parameter can be a 7-bit or 10-bit address. */
jhon309 0:c52df770855b 75
jhon309 0:c52df770855b 76 uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode for master is selected.
jhon309 0:c52df770855b 77 This parameter can be a value of @ref SMBUS_addressing_mode */
jhon309 0:c52df770855b 78
jhon309 0:c52df770855b 79 uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
jhon309 0:c52df770855b 80 This parameter can be a value of @ref SMBUS_dual_addressing_mode */
jhon309 0:c52df770855b 81
jhon309 0:c52df770855b 82 uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
jhon309 0:c52df770855b 83 This parameter can be a 7-bit address. */
jhon309 0:c52df770855b 84
jhon309 0:c52df770855b 85 uint32_t OwnAddress2Masks; /*!< Specifies the acknoledge mask address second device own address if dual addressing mode is selected
jhon309 0:c52df770855b 86 This parameter can be a value of @ref SMBUS_own_address2_masks. */
jhon309 0:c52df770855b 87
jhon309 0:c52df770855b 88 uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
jhon309 0:c52df770855b 89 This parameter can be a value of @ref SMBUS_general_call_addressing_mode. */
jhon309 0:c52df770855b 90
jhon309 0:c52df770855b 91 uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
jhon309 0:c52df770855b 92 This parameter can be a value of @ref SMBUS_nostretch_mode */
jhon309 0:c52df770855b 93
jhon309 0:c52df770855b 94 uint32_t PacketErrorCheckMode; /*!< Specifies if Packet Error Check mode is selected.
jhon309 0:c52df770855b 95 This parameter can be a value of @ref SMBUS_packet_error_check_mode */
jhon309 0:c52df770855b 96
jhon309 0:c52df770855b 97 uint32_t PeripheralMode; /*!< Specifies which mode of Periphal is selected.
jhon309 0:c52df770855b 98 This parameter can be a value of @ref SMBUS_peripheral_mode */
jhon309 0:c52df770855b 99
jhon309 0:c52df770855b 100 uint32_t SMBusTimeout; /*!< Specifies the content of the 32 Bits SMBUS_TIMEOUT_register value.
jhon309 0:c52df770855b 101 (Enable bits and different timeout values)
jhon309 0:c52df770855b 102 This parameter calculated by referring to SMBUS initialization
jhon309 0:c52df770855b 103 section in Reference manual */
jhon309 0:c52df770855b 104 } SMBUS_InitTypeDef;
jhon309 0:c52df770855b 105
jhon309 0:c52df770855b 106 /**
jhon309 0:c52df770855b 107 * @brief SMBUS handle Structure definition
jhon309 0:c52df770855b 108 */
jhon309 0:c52df770855b 109 typedef struct
jhon309 0:c52df770855b 110 {
jhon309 0:c52df770855b 111 I2C_TypeDef *Instance; /*!< SMBUS registers base address */
jhon309 0:c52df770855b 112
jhon309 0:c52df770855b 113 SMBUS_InitTypeDef Init; /*!< SMBUS communication parameters */
jhon309 0:c52df770855b 114
jhon309 0:c52df770855b 115 uint8_t *pBuffPtr; /*!< Pointer to SMBUS transfer buffer */
jhon309 0:c52df770855b 116
jhon309 0:c52df770855b 117 uint16_t XferSize; /*!< SMBUS transfer size */
jhon309 0:c52df770855b 118
jhon309 0:c52df770855b 119 __IO uint16_t XferCount; /*!< SMBUS transfer counter */
jhon309 0:c52df770855b 120
jhon309 0:c52df770855b 121 __IO uint32_t XferOptions; /*!< SMBUS transfer options */
jhon309 0:c52df770855b 122
jhon309 0:c52df770855b 123 __IO uint32_t PreviousState; /*!< SMBUS communication Previous state
jhon309 0:c52df770855b 124 This parameter can be a value of @ref SMBUS_State */
jhon309 0:c52df770855b 125
jhon309 0:c52df770855b 126 HAL_LockTypeDef Lock; /*!< SMBUS locking object */
jhon309 0:c52df770855b 127
jhon309 0:c52df770855b 128 __IO uint32_t State; /*!< SMBUS communication state
jhon309 0:c52df770855b 129 This parameter can be a value of @ref SMBUS_State */
jhon309 0:c52df770855b 130
jhon309 0:c52df770855b 131 __IO uint32_t ErrorCode; /*!< SMBUS Error code
jhon309 0:c52df770855b 132 This parameter can be a value of @ref SMBUS_Error */
jhon309 0:c52df770855b 133
jhon309 0:c52df770855b 134 }SMBUS_HandleTypeDef;
jhon309 0:c52df770855b 135 /**
jhon309 0:c52df770855b 136 * @}
jhon309 0:c52df770855b 137 */
jhon309 0:c52df770855b 138
jhon309 0:c52df770855b 139 /* Exported constants --------------------------------------------------------*/
jhon309 0:c52df770855b 140
jhon309 0:c52df770855b 141 /** @defgroup SMBUS_Exported_Constants SMBUS Exported Constants
jhon309 0:c52df770855b 142 * @{
jhon309 0:c52df770855b 143 */
jhon309 0:c52df770855b 144
jhon309 0:c52df770855b 145 /** @defgroup SMBUS_Error SMBUS Error
jhon309 0:c52df770855b 146 * @{
jhon309 0:c52df770855b 147 */
jhon309 0:c52df770855b 148 #define HAL_SMBUS_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
jhon309 0:c52df770855b 149 #define HAL_SMBUS_ERROR_BERR ((uint32_t)0x00000001) /*!< BERR error */
jhon309 0:c52df770855b 150 #define HAL_SMBUS_ERROR_ARLO ((uint32_t)0x00000002) /*!< ARLO error */
jhon309 0:c52df770855b 151 #define HAL_SMBUS_ERROR_ACKF ((uint32_t)0x00000004) /*!< ACKF error */
jhon309 0:c52df770855b 152 #define HAL_SMBUS_ERROR_OVR ((uint32_t)0x00000008) /*!< OVR error */
jhon309 0:c52df770855b 153 #define HAL_SMBUS_ERROR_HALTIMEOUT ((uint32_t)0x00000010) /*!< Timeout error */
jhon309 0:c52df770855b 154 #define HAL_SMBUS_ERROR_BUSTIMEOUT ((uint32_t)0x00000020) /*!< Bus Timeout error */
jhon309 0:c52df770855b 155 #define HAL_SMBUS_ERROR_ALERT ((uint32_t)0x00000040) /*!< Alert error */
jhon309 0:c52df770855b 156 #define HAL_SMBUS_ERROR_PECERR ((uint32_t)0x00000080) /*!< PEC error */
jhon309 0:c52df770855b 157 /**
jhon309 0:c52df770855b 158 * @}
jhon309 0:c52df770855b 159 */
jhon309 0:c52df770855b 160
jhon309 0:c52df770855b 161 /** @defgroup SMBUS_State SMBUS State
jhon309 0:c52df770855b 162 * @{
jhon309 0:c52df770855b 163 */
jhon309 0:c52df770855b 164
jhon309 0:c52df770855b 165 #define HAL_SMBUS_STATE_RESET ((uint32_t)0x00000000) /*!< SMBUS not yet initialized or disabled */
jhon309 0:c52df770855b 166 #define HAL_SMBUS_STATE_READY ((uint32_t)0x00000001) /*!< SMBUS initialized and ready for use */
jhon309 0:c52df770855b 167 #define HAL_SMBUS_STATE_BUSY ((uint32_t)0x00000002) /*!< SMBUS internal process is ongoing */
jhon309 0:c52df770855b 168 #define HAL_SMBUS_STATE_MASTER_BUSY_TX ((uint32_t)0x00000012) /*!< Master Data Transmission process is ongoing */
jhon309 0:c52df770855b 169 #define HAL_SMBUS_STATE_MASTER_BUSY_RX ((uint32_t)0x00000022) /*!< Master Data Reception process is ongoing */
jhon309 0:c52df770855b 170 #define HAL_SMBUS_STATE_SLAVE_BUSY_TX ((uint32_t)0x00000032) /*!< Slave Data Transmission process is ongoing */
jhon309 0:c52df770855b 171 #define HAL_SMBUS_STATE_SLAVE_BUSY_RX ((uint32_t)0x00000042) /*!< Slave Data Reception process is ongoing */
jhon309 0:c52df770855b 172 #define HAL_SMBUS_STATE_TIMEOUT ((uint32_t)0x00000003) /*!< Timeout state */
jhon309 0:c52df770855b 173 #define HAL_SMBUS_STATE_ERROR ((uint32_t)0x00000004) /*!< Reception process is ongoing */
jhon309 0:c52df770855b 174 #define HAL_SMBUS_STATE_SLAVE_LISTEN ((uint32_t)0x00000008) /*!< Address Listen Mode is ongoing */
jhon309 0:c52df770855b 175 /* Aliases for inter STM32 series compatibility */
jhon309 0:c52df770855b 176 #define HAL_SMBUS_STATE_LISTEN HAL_SMBUS_STATE_SLAVE_LISTEN
jhon309 0:c52df770855b 177
jhon309 0:c52df770855b 178 /**
jhon309 0:c52df770855b 179 * @}
jhon309 0:c52df770855b 180 */
jhon309 0:c52df770855b 181
jhon309 0:c52df770855b 182 /** @defgroup SMBUS_Analog_Filter SMBUS Analog Filter
jhon309 0:c52df770855b 183 * @{
jhon309 0:c52df770855b 184 */
jhon309 0:c52df770855b 185 #define SMBUS_ANALOGFILTER_ENABLED ((uint32_t)0x00000000)
jhon309 0:c52df770855b 186 #define SMBUS_ANALOGFILTER_DISABLED I2C_CR1_ANFOFF
jhon309 0:c52df770855b 187
jhon309 0:c52df770855b 188 #define IS_SMBUS_ANALOG_FILTER(FILTER) (((FILTER) == SMBUS_ANALOGFILTER_ENABLED) || \
jhon309 0:c52df770855b 189 ((FILTER) == SMBUS_ANALOGFILTER_DISABLED))
jhon309 0:c52df770855b 190 /**
jhon309 0:c52df770855b 191 * @}
jhon309 0:c52df770855b 192 */
jhon309 0:c52df770855b 193
jhon309 0:c52df770855b 194 /** @defgroup SMBUS_addressing_mode SMBUS addressing mode
jhon309 0:c52df770855b 195 * @{
jhon309 0:c52df770855b 196 */
jhon309 0:c52df770855b 197 #define SMBUS_ADDRESSINGMODE_7BIT ((uint32_t)0x00000001)
jhon309 0:c52df770855b 198 #define SMBUS_ADDRESSINGMODE_10BIT ((uint32_t)0x00000002)
jhon309 0:c52df770855b 199
jhon309 0:c52df770855b 200 #define IS_SMBUS_ADDRESSING_MODE(MODE) (((MODE) == SMBUS_ADDRESSINGMODE_7BIT) || \
jhon309 0:c52df770855b 201 ((MODE) == SMBUS_ADDRESSINGMODE_10BIT))
jhon309 0:c52df770855b 202 /**
jhon309 0:c52df770855b 203 * @}
jhon309 0:c52df770855b 204 */
jhon309 0:c52df770855b 205
jhon309 0:c52df770855b 206 /** @defgroup SMBUS_dual_addressing_mode SMBUS dual addressing mode
jhon309 0:c52df770855b 207 * @{
jhon309 0:c52df770855b 208 */
jhon309 0:c52df770855b 209
jhon309 0:c52df770855b 210 #define SMBUS_DUALADDRESS_DISABLED ((uint32_t)0x00000000)
jhon309 0:c52df770855b 211 #define SMBUS_DUALADDRESS_ENABLED I2C_OAR2_OA2EN
jhon309 0:c52df770855b 212
jhon309 0:c52df770855b 213 #define IS_SMBUS_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == SMBUS_DUALADDRESS_DISABLED) || \
jhon309 0:c52df770855b 214 ((ADDRESS) == SMBUS_DUALADDRESS_ENABLED))
jhon309 0:c52df770855b 215 /**
jhon309 0:c52df770855b 216 * @}
jhon309 0:c52df770855b 217 */
jhon309 0:c52df770855b 218
jhon309 0:c52df770855b 219 /** @defgroup SMBUS_own_address2_masks SMBUS ownaddress2 masks
jhon309 0:c52df770855b 220 * @{
jhon309 0:c52df770855b 221 */
jhon309 0:c52df770855b 222
jhon309 0:c52df770855b 223 #define SMBUS_OA2_NOMASK ((uint8_t)0x00)
jhon309 0:c52df770855b 224 #define SMBUS_OA2_MASK01 ((uint8_t)0x01)
jhon309 0:c52df770855b 225 #define SMBUS_OA2_MASK02 ((uint8_t)0x02)
jhon309 0:c52df770855b 226 #define SMBUS_OA2_MASK03 ((uint8_t)0x03)
jhon309 0:c52df770855b 227 #define SMBUS_OA2_MASK04 ((uint8_t)0x04)
jhon309 0:c52df770855b 228 #define SMBUS_OA2_MASK05 ((uint8_t)0x05)
jhon309 0:c52df770855b 229 #define SMBUS_OA2_MASK06 ((uint8_t)0x06)
jhon309 0:c52df770855b 230 #define SMBUS_OA2_MASK07 ((uint8_t)0x07)
jhon309 0:c52df770855b 231
jhon309 0:c52df770855b 232 #define IS_SMBUS_OWN_ADDRESS2_MASK(MASK) (((MASK) == SMBUS_OA2_NOMASK) || \
jhon309 0:c52df770855b 233 ((MASK) == SMBUS_OA2_MASK01) || \
jhon309 0:c52df770855b 234 ((MASK) == SMBUS_OA2_MASK02) || \
jhon309 0:c52df770855b 235 ((MASK) == SMBUS_OA2_MASK03) || \
jhon309 0:c52df770855b 236 ((MASK) == SMBUS_OA2_MASK04) || \
jhon309 0:c52df770855b 237 ((MASK) == SMBUS_OA2_MASK05) || \
jhon309 0:c52df770855b 238 ((MASK) == SMBUS_OA2_MASK06) || \
jhon309 0:c52df770855b 239 ((MASK) == SMBUS_OA2_MASK07))
jhon309 0:c52df770855b 240 /**
jhon309 0:c52df770855b 241 * @}
jhon309 0:c52df770855b 242 */
jhon309 0:c52df770855b 243
jhon309 0:c52df770855b 244
jhon309 0:c52df770855b 245 /** @defgroup SMBUS_general_call_addressing_mode SMBUS general call addressing mode
jhon309 0:c52df770855b 246 * @{
jhon309 0:c52df770855b 247 */
jhon309 0:c52df770855b 248 #define SMBUS_GENERALCALL_DISABLED ((uint32_t)0x00000000)
jhon309 0:c52df770855b 249 #define SMBUS_GENERALCALL_ENABLED I2C_CR1_GCEN
jhon309 0:c52df770855b 250
jhon309 0:c52df770855b 251 #define IS_SMBUS_GENERAL_CALL(CALL) (((CALL) == SMBUS_GENERALCALL_DISABLED) || \
jhon309 0:c52df770855b 252 ((CALL) == SMBUS_GENERALCALL_ENABLED))
jhon309 0:c52df770855b 253 /**
jhon309 0:c52df770855b 254 * @}
jhon309 0:c52df770855b 255 */
jhon309 0:c52df770855b 256
jhon309 0:c52df770855b 257 /** @defgroup SMBUS_nostretch_mode SMBUS nostretch mode
jhon309 0:c52df770855b 258 * @{
jhon309 0:c52df770855b 259 */
jhon309 0:c52df770855b 260 #define SMBUS_NOSTRETCH_DISABLED ((uint32_t)0x00000000)
jhon309 0:c52df770855b 261 #define SMBUS_NOSTRETCH_ENABLED I2C_CR1_NOSTRETCH
jhon309 0:c52df770855b 262
jhon309 0:c52df770855b 263 #define IS_SMBUS_NO_STRETCH(STRETCH) (((STRETCH) == SMBUS_NOSTRETCH_DISABLED) || \
jhon309 0:c52df770855b 264 ((STRETCH) == SMBUS_NOSTRETCH_ENABLED))
jhon309 0:c52df770855b 265 /**
jhon309 0:c52df770855b 266 * @}
jhon309 0:c52df770855b 267 */
jhon309 0:c52df770855b 268
jhon309 0:c52df770855b 269 /** @defgroup SMBUS_packet_error_check_mode SMBUS packet error check mode
jhon309 0:c52df770855b 270 * @{
jhon309 0:c52df770855b 271 */
jhon309 0:c52df770855b 272 #define SMBUS_PEC_DISABLED ((uint32_t)0x00000000)
jhon309 0:c52df770855b 273 #define SMBUS_PEC_ENABLED I2C_CR1_PECEN
jhon309 0:c52df770855b 274
jhon309 0:c52df770855b 275 #define IS_SMBUS_PEC(PEC) (((PEC) == SMBUS_PEC_DISABLED) || \
jhon309 0:c52df770855b 276 ((PEC) == SMBUS_PEC_ENABLED))
jhon309 0:c52df770855b 277 /**
jhon309 0:c52df770855b 278 * @}
jhon309 0:c52df770855b 279 */
jhon309 0:c52df770855b 280
jhon309 0:c52df770855b 281 /** @defgroup SMBUS_peripheral_mode SMBUS peripheral mode
jhon309 0:c52df770855b 282 * @{
jhon309 0:c52df770855b 283 */
jhon309 0:c52df770855b 284 #define SMBUS_PERIPHERAL_MODE_SMBUS_HOST (uint32_t)(I2C_CR1_SMBHEN)
jhon309 0:c52df770855b 285 #define SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE (uint32_t)(0x00000000)
jhon309 0:c52df770855b 286 #define SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE_ARP (uint32_t)(I2C_CR1_SMBDEN)
jhon309 0:c52df770855b 287
jhon309 0:c52df770855b 288 #define IS_SMBUS_PERIPHERAL_MODE(MODE) (((MODE) == SMBUS_PERIPHERAL_MODE_SMBUS_HOST) || \
jhon309 0:c52df770855b 289 ((MODE) == SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE) || \
jhon309 0:c52df770855b 290 ((MODE) == SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE_ARP))
jhon309 0:c52df770855b 291 /**
jhon309 0:c52df770855b 292 * @}
jhon309 0:c52df770855b 293 */
jhon309 0:c52df770855b 294
jhon309 0:c52df770855b 295 /** @defgroup SMBUS_ReloadEndMode_definition SMBUS ReloadEndMode definition
jhon309 0:c52df770855b 296 * @{
jhon309 0:c52df770855b 297 */
jhon309 0:c52df770855b 298
jhon309 0:c52df770855b 299 #define SMBUS_SOFTEND_MODE ((uint32_t)0x00000000)
jhon309 0:c52df770855b 300 #define SMBUS_RELOAD_MODE I2C_CR2_RELOAD
jhon309 0:c52df770855b 301 #define SMBUS_AUTOEND_MODE I2C_CR2_AUTOEND
jhon309 0:c52df770855b 302 #define SMBUS_SENDPEC_MODE I2C_CR2_PECBYTE
jhon309 0:c52df770855b 303
jhon309 0:c52df770855b 304 #define IS_SMBUS_TRANSFER_MODE(MODE) (((MODE) == SMBUS_RELOAD_MODE) || \
jhon309 0:c52df770855b 305 ((MODE) == SMBUS_AUTOEND_MODE) || \
jhon309 0:c52df770855b 306 ((MODE) == SMBUS_SOFTEND_MODE) || \
jhon309 0:c52df770855b 307 ((MODE) == (SMBUS_RELOAD_MODE | SMBUS_SENDPEC_MODE)) || \
jhon309 0:c52df770855b 308 ((MODE) == (SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE)) || \
jhon309 0:c52df770855b 309 ((MODE) == (SMBUS_AUTOEND_MODE | SMBUS_RELOAD_MODE)) || \
jhon309 0:c52df770855b 310 ((MODE) == (SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE | SMBUS_RELOAD_MODE )))
jhon309 0:c52df770855b 311
jhon309 0:c52df770855b 312 /**
jhon309 0:c52df770855b 313 * @}
jhon309 0:c52df770855b 314 */
jhon309 0:c52df770855b 315
jhon309 0:c52df770855b 316 /** @defgroup SMBUS_StartStopMode_definition SMBUS StartStopMode definition
jhon309 0:c52df770855b 317 * @{
jhon309 0:c52df770855b 318 */
jhon309 0:c52df770855b 319
jhon309 0:c52df770855b 320 #define SMBUS_NO_STARTSTOP ((uint32_t)0x00000000)
jhon309 0:c52df770855b 321 #define SMBUS_GENERATE_STOP I2C_CR2_STOP
jhon309 0:c52df770855b 322 #define SMBUS_GENERATE_START_READ (uint32_t)(I2C_CR2_START | I2C_CR2_RD_WRN)
jhon309 0:c52df770855b 323 #define SMBUS_GENERATE_START_WRITE I2C_CR2_START
jhon309 0:c52df770855b 324
jhon309 0:c52df770855b 325 #define IS_SMBUS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == SMBUS_GENERATE_STOP) || \
jhon309 0:c52df770855b 326 ((REQUEST) == SMBUS_GENERATE_START_READ) || \
jhon309 0:c52df770855b 327 ((REQUEST) == SMBUS_GENERATE_START_WRITE) || \
jhon309 0:c52df770855b 328 ((REQUEST) == SMBUS_NO_STARTSTOP))
jhon309 0:c52df770855b 329
jhon309 0:c52df770855b 330 /**
jhon309 0:c52df770855b 331 * @}
jhon309 0:c52df770855b 332 */
jhon309 0:c52df770855b 333
jhon309 0:c52df770855b 334 /** @defgroup SMBUS_XferOptions_definition SMBUS XferOptions definition
jhon309 0:c52df770855b 335 * @{
jhon309 0:c52df770855b 336 */
jhon309 0:c52df770855b 337
jhon309 0:c52df770855b 338 #define SMBUS_FIRST_FRAME ((uint32_t)(SMBUS_SOFTEND_MODE))
jhon309 0:c52df770855b 339 #define SMBUS_NEXT_FRAME ((uint32_t)(SMBUS_RELOAD_MODE | SMBUS_SOFTEND_MODE))
jhon309 0:c52df770855b 340 #define SMBUS_FIRST_AND_LAST_FRAME_NO_PEC SMBUS_AUTOEND_MODE
jhon309 0:c52df770855b 341 #define SMBUS_LAST_FRAME_NO_PEC SMBUS_AUTOEND_MODE
jhon309 0:c52df770855b 342 #define SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC ((uint32_t)(SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE))
jhon309 0:c52df770855b 343 #define SMBUS_LAST_FRAME_WITH_PEC ((uint32_t)(SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE))
jhon309 0:c52df770855b 344
jhon309 0:c52df770855b 345 #define IS_SMBUS_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == SMBUS_FIRST_FRAME) || \
jhon309 0:c52df770855b 346 ((REQUEST) == SMBUS_NEXT_FRAME) || \
jhon309 0:c52df770855b 347 ((REQUEST) == SMBUS_FIRST_AND_LAST_FRAME_NO_PEC) || \
jhon309 0:c52df770855b 348 ((REQUEST) == SMBUS_LAST_FRAME_NO_PEC) || \
jhon309 0:c52df770855b 349 ((REQUEST) == SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC) || \
jhon309 0:c52df770855b 350 ((REQUEST) == SMBUS_LAST_FRAME_WITH_PEC))
jhon309 0:c52df770855b 351
jhon309 0:c52df770855b 352 /**
jhon309 0:c52df770855b 353 * @}
jhon309 0:c52df770855b 354 */
jhon309 0:c52df770855b 355
jhon309 0:c52df770855b 356 /** @defgroup SMBUS_Interrupt_configuration_definition SMBUS Interrupt configuration definition
jhon309 0:c52df770855b 357 * @brief SMBUS Interrupt definition
jhon309 0:c52df770855b 358 * Elements values convention: 0xXXXXXXXX
jhon309 0:c52df770855b 359 * - XXXXXXXX : Interrupt control mask
jhon309 0:c52df770855b 360 * @{
jhon309 0:c52df770855b 361 */
jhon309 0:c52df770855b 362 #define SMBUS_IT_ERRI I2C_CR1_ERRIE
jhon309 0:c52df770855b 363 #define SMBUS_IT_TCI I2C_CR1_TCIE
jhon309 0:c52df770855b 364 #define SMBUS_IT_STOPI I2C_CR1_STOPIE
jhon309 0:c52df770855b 365 #define SMBUS_IT_NACKI I2C_CR1_NACKIE
jhon309 0:c52df770855b 366 #define SMBUS_IT_ADDRI I2C_CR1_ADDRIE
jhon309 0:c52df770855b 367 #define SMBUS_IT_RXI I2C_CR1_RXIE
jhon309 0:c52df770855b 368 #define SMBUS_IT_TXI I2C_CR1_TXIE
jhon309 0:c52df770855b 369 #define SMBUS_IT_TX (SMBUS_IT_ERRI | SMBUS_IT_TCI | SMBUS_IT_STOPI | SMBUS_IT_NACKI | SMBUS_IT_TXI)
jhon309 0:c52df770855b 370 #define SMBUS_IT_RX (SMBUS_IT_ERRI | SMBUS_IT_TCI | SMBUS_IT_NACKI | SMBUS_IT_RXI)
jhon309 0:c52df770855b 371 #define SMBUS_IT_ALERT (SMBUS_IT_ERRI)
jhon309 0:c52df770855b 372 #define SMBUS_IT_ADDR (SMBUS_IT_ADDRI | SMBUS_IT_STOPI | SMBUS_IT_NACKI)
jhon309 0:c52df770855b 373 /**
jhon309 0:c52df770855b 374 * @}
jhon309 0:c52df770855b 375 */
jhon309 0:c52df770855b 376
jhon309 0:c52df770855b 377 /** @defgroup SMBUS_Flag_definition SMBUS Flag definition
jhon309 0:c52df770855b 378 * @brief Flag definition
jhon309 0:c52df770855b 379 * Elements values convention: 0xXXXXYYYY
jhon309 0:c52df770855b 380 * - XXXXXXXX : Flag mask
jhon309 0:c52df770855b 381 * @{
jhon309 0:c52df770855b 382 */
jhon309 0:c52df770855b 383
jhon309 0:c52df770855b 384 #define SMBUS_FLAG_TXE I2C_ISR_TXE
jhon309 0:c52df770855b 385 #define SMBUS_FLAG_TXIS I2C_ISR_TXIS
jhon309 0:c52df770855b 386 #define SMBUS_FLAG_RXNE I2C_ISR_RXNE
jhon309 0:c52df770855b 387 #define SMBUS_FLAG_ADDR I2C_ISR_ADDR
jhon309 0:c52df770855b 388 #define SMBUS_FLAG_AF I2C_ISR_NACKF
jhon309 0:c52df770855b 389 #define SMBUS_FLAG_STOPF I2C_ISR_STOPF
jhon309 0:c52df770855b 390 #define SMBUS_FLAG_TC I2C_ISR_TC
jhon309 0:c52df770855b 391 #define SMBUS_FLAG_TCR I2C_ISR_TCR
jhon309 0:c52df770855b 392 #define SMBUS_FLAG_BERR I2C_ISR_BERR
jhon309 0:c52df770855b 393 #define SMBUS_FLAG_ARLO I2C_ISR_ARLO
jhon309 0:c52df770855b 394 #define SMBUS_FLAG_OVR I2C_ISR_OVR
jhon309 0:c52df770855b 395 #define SMBUS_FLAG_PECERR I2C_ISR_PECERR
jhon309 0:c52df770855b 396 #define SMBUS_FLAG_TIMEOUT I2C_ISR_TIMEOUT
jhon309 0:c52df770855b 397 #define SMBUS_FLAG_ALERT I2C_ISR_ALERT
jhon309 0:c52df770855b 398 #define SMBUS_FLAG_BUSY I2C_ISR_BUSY
jhon309 0:c52df770855b 399 #define SMBUS_FLAG_DIR I2C_ISR_DIR
jhon309 0:c52df770855b 400 /**
jhon309 0:c52df770855b 401 * @}
jhon309 0:c52df770855b 402 */
jhon309 0:c52df770855b 403
jhon309 0:c52df770855b 404 /**
jhon309 0:c52df770855b 405 * @}
jhon309 0:c52df770855b 406 */
jhon309 0:c52df770855b 407
jhon309 0:c52df770855b 408 /* Exported macros ------------------------------------------------------------*/
jhon309 0:c52df770855b 409 /** @defgroup SMBUS_Exported_Macros SMBUS Exported Macros
jhon309 0:c52df770855b 410 * @{
jhon309 0:c52df770855b 411 */
jhon309 0:c52df770855b 412
jhon309 0:c52df770855b 413 /** @brief Reset SMBUS handle state
jhon309 0:c52df770855b 414 * @param __HANDLE__: SMBUS handle.
jhon309 0:c52df770855b 415 * @retval None
jhon309 0:c52df770855b 416 */
jhon309 0:c52df770855b 417 #define __HAL_SMBUS_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMBUS_STATE_RESET)
jhon309 0:c52df770855b 418
jhon309 0:c52df770855b 419 /** @brief Enable or disable the specified SMBUS interrupts.
jhon309 0:c52df770855b 420 * @param __HANDLE__: specifies the SMBUS Handle.
jhon309 0:c52df770855b 421 * This parameter can be SMBUS where x: 1 or 2 to select the SMBUS peripheral.
jhon309 0:c52df770855b 422 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
jhon309 0:c52df770855b 423 * This parameter can be one of the following values:
jhon309 0:c52df770855b 424 * @arg SMBUS_IT_ERRI: Errors interrupt enable
jhon309 0:c52df770855b 425 * @arg SMBUS_IT_TCI: Transfer complete interrupt enable
jhon309 0:c52df770855b 426 * @arg SMBUS_IT_STOPI: STOP detection interrupt enable
jhon309 0:c52df770855b 427 * @arg SMBUS_IT_NACKI: NACK received interrupt enable
jhon309 0:c52df770855b 428 * @arg SMBUS_IT_ADDRI: Address match interrupt enable
jhon309 0:c52df770855b 429 * @arg SMBUS_IT_RXI: RX interrupt enable
jhon309 0:c52df770855b 430 * @arg SMBUS_IT_TXI: TX interrupt enable
jhon309 0:c52df770855b 431 *
jhon309 0:c52df770855b 432 * @retval None
jhon309 0:c52df770855b 433 */
jhon309 0:c52df770855b 434
jhon309 0:c52df770855b 435 #define __HAL_SMBUS_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
jhon309 0:c52df770855b 436 #define __HAL_SMBUS_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
jhon309 0:c52df770855b 437
jhon309 0:c52df770855b 438 /** @brief Checks if the specified SMBUS interrupt source is enabled or disabled.
jhon309 0:c52df770855b 439 * @param __HANDLE__: specifies the SMBUS Handle.
jhon309 0:c52df770855b 440 * This parameter can be SMBUS where x: 1 or 2 to select the SMBUS peripheral.
jhon309 0:c52df770855b 441 * @param __INTERRUPT__: specifies the SMBUS interrupt source to check.
jhon309 0:c52df770855b 442 * This parameter can be one of the following values:
jhon309 0:c52df770855b 443 * @arg SMBUS_IT_ERRI: Errors interrupt enable
jhon309 0:c52df770855b 444 * @arg SMBUS_IT_TCI: Transfer complete interrupt enable
jhon309 0:c52df770855b 445 * @arg SMBUS_IT_STOPI: STOP detection interrupt enable
jhon309 0:c52df770855b 446 * @arg SMBUS_IT_NACKI: NACK received interrupt enable
jhon309 0:c52df770855b 447 * @arg SMBUS_IT_ADDRI: Address match interrupt enable
jhon309 0:c52df770855b 448 * @arg SMBUS_IT_RXI: RX interrupt enable
jhon309 0:c52df770855b 449 * @arg SMBUS_IT_TXI: TX interrupt enable
jhon309 0:c52df770855b 450 *
jhon309 0:c52df770855b 451 * @retval The new state of __IT__ (TRUE or FALSE).
jhon309 0:c52df770855b 452 */
jhon309 0:c52df770855b 453 #define __HAL_SMBUS_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
jhon309 0:c52df770855b 454
jhon309 0:c52df770855b 455 /** @brief Checks whether the specified SMBUS flag is set or not.
jhon309 0:c52df770855b 456 * @param __HANDLE__: specifies the SMBUS Handle.
jhon309 0:c52df770855b 457 * This parameter can be SMBUS where x: 1 or 2 to select the SMBUS peripheral.
jhon309 0:c52df770855b 458 * @param __FLAG__: specifies the flag to check.
jhon309 0:c52df770855b 459 * This parameter can be one of the following values:
jhon309 0:c52df770855b 460 * @arg SMBUS_FLAG_TXE: Transmit data register empty
jhon309 0:c52df770855b 461 * @arg SMBUS_FLAG_TXIS: Transmit interrupt status
jhon309 0:c52df770855b 462 * @arg SMBUS_FLAG_RXNE: Receive data register not empty
jhon309 0:c52df770855b 463 * @arg SMBUS_FLAG_ADDR: Address matched (slave mode)
jhon309 0:c52df770855b 464 * @arg SMBUS_FLAG_AF: NACK received flag
jhon309 0:c52df770855b 465 * @arg SMBUS_FLAG_STOPF: STOP detection flag
jhon309 0:c52df770855b 466 * @arg SMBUS_FLAG_TC: Transfer complete (master mode)
jhon309 0:c52df770855b 467 * @arg SMBUS_FLAG_TCR: Transfer complete reload
jhon309 0:c52df770855b 468 * @arg SMBUS_FLAG_BERR: Bus error
jhon309 0:c52df770855b 469 * @arg SMBUS_FLAG_ARLO: Arbitration lost
jhon309 0:c52df770855b 470 * @arg SMBUS_FLAG_OVR: Overrun/Underrun
jhon309 0:c52df770855b 471 * @arg SMBUS_FLAG_PECERR: PEC error in reception
jhon309 0:c52df770855b 472 * @arg SMBUS_FLAG_TIMEOUT: Timeout or Tlow detection flag
jhon309 0:c52df770855b 473 * @arg SMBUS_FLAG_ALERT: SMBus alert
jhon309 0:c52df770855b 474 * @arg SMBUS_FLAG_BUSY: Bus busy
jhon309 0:c52df770855b 475 * @arg SMBUS_FLAG_DIR: Transfer direction (slave mode)
jhon309 0:c52df770855b 476 *
jhon309 0:c52df770855b 477 * @retval The new state of __FLAG__ (TRUE or FALSE).
jhon309 0:c52df770855b 478 */
jhon309 0:c52df770855b 479 #define SMBUS_FLAG_MASK ((uint32_t)0x0001FFFF)
jhon309 0:c52df770855b 480 #define __HAL_SMBUS_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__) & SMBUS_FLAG_MASK)) == ((__FLAG__) & SMBUS_FLAG_MASK)))
jhon309 0:c52df770855b 481
jhon309 0:c52df770855b 482 /** @brief Clears the SMBUS pending flags which are cleared by writing 1 in a specific bit.
jhon309 0:c52df770855b 483 * @param __HANDLE__: specifies the SMBUS Handle.
jhon309 0:c52df770855b 484 * This parameter can be SMBUS where x: 1 or 2 to select the SMBUS peripheral.
jhon309 0:c52df770855b 485 * @param __FLAG__: specifies the flag to clear.
jhon309 0:c52df770855b 486 * This parameter can be any combination of the following values:
jhon309 0:c52df770855b 487 * @arg SMBUS_FLAG_ADDR: Address matched (slave mode)
jhon309 0:c52df770855b 488 * @arg SMBUS_FLAG_AF: NACK received flag
jhon309 0:c52df770855b 489 * @arg SMBUS_FLAG_STOPF: STOP detection flag
jhon309 0:c52df770855b 490 * @arg SMBUS_FLAG_BERR: Bus error
jhon309 0:c52df770855b 491 * @arg SMBUS_FLAG_ARLO: Arbitration lost
jhon309 0:c52df770855b 492 * @arg SMBUS_FLAG_OVR: Overrun/Underrun
jhon309 0:c52df770855b 493 * @arg SMBUS_FLAG_PECERR: PEC error in reception
jhon309 0:c52df770855b 494 * @arg SMBUS_FLAG_TIMEOUT: Timeout or Tlow detection flag
jhon309 0:c52df770855b 495 * @arg SMBUS_FLAG_ALERT: SMBus alert
jhon309 0:c52df770855b 496 *
jhon309 0:c52df770855b 497 * @retval None
jhon309 0:c52df770855b 498 */
jhon309 0:c52df770855b 499 #define __HAL_SMBUS_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
jhon309 0:c52df770855b 500
jhon309 0:c52df770855b 501
jhon309 0:c52df770855b 502 #define __HAL_SMBUS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= I2C_CR1_PE)
jhon309 0:c52df770855b 503 #define __HAL_SMBUS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~I2C_CR1_PE)
jhon309 0:c52df770855b 504
jhon309 0:c52df770855b 505 #define __HAL_SMBUS_RESET_CR1(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (uint32_t)~((uint32_t)(I2C_CR1_SMBHEN | I2C_CR1_SMBDEN | I2C_CR1_PECEN)))
jhon309 0:c52df770855b 506 #define __HAL_SMBUS_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN)))
jhon309 0:c52df770855b 507
jhon309 0:c52df770855b 508 #define __HAL_SMBUS_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == SMBUS_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \
jhon309 0:c52df770855b 509 (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN)))
jhon309 0:c52df770855b 510
jhon309 0:c52df770855b 511 #define __HAL_SMBUS_GET_ADDR_MATCH(__HANDLE__) (((__HANDLE__)->Instance->ISR & I2C_ISR_ADDCODE) >> 17)
jhon309 0:c52df770855b 512 #define __HAL_SMBUS_GET_DIR(__HANDLE__) (((__HANDLE__)->Instance->ISR & I2C_ISR_DIR) >> 16)
jhon309 0:c52df770855b 513 #define __HAL_SMBUS_GET_STOP_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_AUTOEND)
jhon309 0:c52df770855b 514 #define __HAL_SMBUS_GET_PEC_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_PECBYTE)
jhon309 0:c52df770855b 515 #define __HAL_SMBUS_GET_ALERT_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR1 & I2C_CR1_ALERTEN)
jhon309 0:c52df770855b 516 #define __HAL_SMBUS_GENERATE_NACK(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= I2C_CR2_NACK)
jhon309 0:c52df770855b 517
jhon309 0:c52df770855b 518 #define IS_SMBUS_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= (uint32_t)0x000003FF)
jhon309 0:c52df770855b 519 #define IS_SMBUS_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FF)
jhon309 0:c52df770855b 520 /**
jhon309 0:c52df770855b 521 * @}
jhon309 0:c52df770855b 522 */
jhon309 0:c52df770855b 523
jhon309 0:c52df770855b 524 /* Exported functions --------------------------------------------------------*/
jhon309 0:c52df770855b 525 /** @addtogroup SMBUS_Exported_Functions SMBUS Exported Functions
jhon309 0:c52df770855b 526 * @{
jhon309 0:c52df770855b 527 */
jhon309 0:c52df770855b 528
jhon309 0:c52df770855b 529 /** @addtogroup SMBUS_Exported_Functions_Group1 Initialization and de-initialization functions
jhon309 0:c52df770855b 530 * @{
jhon309 0:c52df770855b 531 */
jhon309 0:c52df770855b 532
jhon309 0:c52df770855b 533 /* Initialization and de-initialization functions **********************************/
jhon309 0:c52df770855b 534 HAL_StatusTypeDef HAL_SMBUS_Init(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 535 HAL_StatusTypeDef HAL_SMBUS_DeInit (SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 536 void HAL_SMBUS_MspInit(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 537 void HAL_SMBUS_MspDeInit(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 538
jhon309 0:c52df770855b 539 /**
jhon309 0:c52df770855b 540 * @}
jhon309 0:c52df770855b 541 */
jhon309 0:c52df770855b 542
jhon309 0:c52df770855b 543 /** @addtogroup SMBUS_Exported_Functions_Group2 Input and Output operation functions
jhon309 0:c52df770855b 544 * @{
jhon309 0:c52df770855b 545 */
jhon309 0:c52df770855b 546
jhon309 0:c52df770855b 547 /* IO operation functions *****************************************************/
jhon309 0:c52df770855b 548 /******* Blocking mode: Polling */
jhon309 0:c52df770855b 549 HAL_StatusTypeDef HAL_SMBUS_IsDeviceReady(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
jhon309 0:c52df770855b 550
jhon309 0:c52df770855b 551 /******* Non-Blocking mode: Interrupt */
jhon309 0:c52df770855b 552 HAL_StatusTypeDef HAL_SMBUS_Master_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
jhon309 0:c52df770855b 553 HAL_StatusTypeDef HAL_SMBUS_Master_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
jhon309 0:c52df770855b 554 HAL_StatusTypeDef HAL_SMBUS_Master_Abort_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress);
jhon309 0:c52df770855b 555 HAL_StatusTypeDef HAL_SMBUS_Slave_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
jhon309 0:c52df770855b 556 HAL_StatusTypeDef HAL_SMBUS_Slave_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
jhon309 0:c52df770855b 557
jhon309 0:c52df770855b 558 HAL_StatusTypeDef HAL_SMBUS_EnableAlert_IT(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 559 HAL_StatusTypeDef HAL_SMBUS_DisableAlert_IT(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 560 HAL_StatusTypeDef HAL_SMBUS_Slave_Listen_IT(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 561 HAL_StatusTypeDef HAL_SMBUS_DisableListen_IT(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 562
jhon309 0:c52df770855b 563 /* Aliases for new API and to insure inter STM32 series compatibility */
jhon309 0:c52df770855b 564 #define HAL_SMBUS_EnableListen_IT HAL_SMBUS_Slave_Listen_IT
jhon309 0:c52df770855b 565
jhon309 0:c52df770855b 566 /******* SMBUS IRQHandler and Callbacks used in non blocking modes (Interrupt) */
jhon309 0:c52df770855b 567 void HAL_SMBUS_EV_IRQHandler(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 568 void HAL_SMBUS_ER_IRQHandler(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 569 void HAL_SMBUS_MasterTxCpltCallback(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 570 void HAL_SMBUS_MasterRxCpltCallback(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 571 void HAL_SMBUS_SlaveTxCpltCallback(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 572 void HAL_SMBUS_SlaveRxCpltCallback(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 573 void HAL_SMBUS_SlaveAddrCallback(SMBUS_HandleTypeDef *hsmbus, uint8_t TransferDirection, uint16_t AddrMatchCode);
jhon309 0:c52df770855b 574 void HAL_SMBUS_SlaveListenCpltCallback(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 575
jhon309 0:c52df770855b 576 /* Aliases for new API and to insure inter STM32 series compatibility */
jhon309 0:c52df770855b 577 #define HAL_SMBUS_AddrCallback HAL_SMBUS_SlaveAddrCallback
jhon309 0:c52df770855b 578 #define HAL_SMBUS_ListenCpltCallback HAL_SMBUS_SlaveListenCpltCallback
jhon309 0:c52df770855b 579
jhon309 0:c52df770855b 580 void HAL_SMBUS_ErrorCallback(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 581
jhon309 0:c52df770855b 582 /**
jhon309 0:c52df770855b 583 * @}
jhon309 0:c52df770855b 584 */
jhon309 0:c52df770855b 585
jhon309 0:c52df770855b 586 /** @addtogroup SMBUS_Exported_Functions_Group3 Peripheral State and Errors functions
jhon309 0:c52df770855b 587 * @{
jhon309 0:c52df770855b 588 */
jhon309 0:c52df770855b 589
jhon309 0:c52df770855b 590 /* Peripheral State and Errors functions **************************************************/
jhon309 0:c52df770855b 591 uint32_t HAL_SMBUS_GetState(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 592 uint32_t HAL_SMBUS_GetError(SMBUS_HandleTypeDef *hsmbus);
jhon309 0:c52df770855b 593
jhon309 0:c52df770855b 594 /**
jhon309 0:c52df770855b 595 * @}
jhon309 0:c52df770855b 596 */
jhon309 0:c52df770855b 597
jhon309 0:c52df770855b 598 /**
jhon309 0:c52df770855b 599 * @}
jhon309 0:c52df770855b 600 */
jhon309 0:c52df770855b 601
jhon309 0:c52df770855b 602 /**
jhon309 0:c52df770855b 603 * @}
jhon309 0:c52df770855b 604 */
jhon309 0:c52df770855b 605
jhon309 0:c52df770855b 606 /**
jhon309 0:c52df770855b 607 * @}
jhon309 0:c52df770855b 608 */
jhon309 0:c52df770855b 609 #ifdef __cplusplus
jhon309 0:c52df770855b 610 }
jhon309 0:c52df770855b 611 #endif
jhon309 0:c52df770855b 612
jhon309 0:c52df770855b 613
jhon309 0:c52df770855b 614 #endif /* __STM32F0xx_HAL_SMBUS_H */
jhon309 0:c52df770855b 615
jhon309 0:c52df770855b 616 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
jhon309 0:c52df770855b 617