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