MacroRat / MouseCode

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

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