I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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