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:
Kojto
Date:
Wed May 27 08:07:35 2015 +0100
Revision:
100:cbbeb26dbd92
Release 100 of the mbed library

Changes:
- new target: DISCOF334C8
- API: Ticker/Timer bugfix with constness
- Silabs: RTC, PWM, Serial clocks bufixes
- Renesas: i2c bugfix
- Maxim: 326000 - pin definitions for v2, spi freq fix

Who changed what in which revision?

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