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