mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Aug 14 13:15:17 2015 +0100
Revision:
610:813dcc80987e
Synchronized with git revision 6d84db41c6833e0b9b024741eb0616a5f62d5599

Full URL: https://github.com/mbedmicro/mbed/commit/6d84db41c6833e0b9b024741eb0616a5f62d5599/

DISCO_F746NG - Improvements

Who changed what in which revision?

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