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