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:
Mon Sep 28 10:45:10 2015 +0100
Revision:
630:825f75ca301e
Parent:
441:d2c15dda23c1
Synchronized with git revision 54fbe4144faf309c37205a5d39fa665daa919f10

Full URL: https://github.com/mbedmicro/mbed/commit/54fbe4144faf309c37205a5d39fa665daa919f10/

NUCLEO_F031K6 : Add new target

Who changed what in which revision?

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