cc y / mbed

Fork of mbed by mbed official

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
92:4fc01daae5a5
Child:
123:b0220dba8be7
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

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