Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
109:9296ab0bfc11
.

Who changed what in which revision?

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