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