mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #if !defined(__FSL_I2C_HAL_H__)
mbed_official 146:f64d43ff0c18 31 #define __FSL_I2C_HAL_H__
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 #include <assert.h>
mbed_official 146:f64d43ff0c18 34 #include <stdbool.h>
mbed_official 146:f64d43ff0c18 35 #include "fsl_i2c_features.h"
mbed_official 146:f64d43ff0c18 36 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 37
mbed_official 146:f64d43ff0c18 38 /*!
mbed_official 146:f64d43ff0c18 39 * @addtogroup i2c_hal
mbed_official 146:f64d43ff0c18 40 * @{
mbed_official 146:f64d43ff0c18 41 */
mbed_official 146:f64d43ff0c18 42
mbed_official 146:f64d43ff0c18 43 /*******************************************************************************
mbed_official 146:f64d43ff0c18 44 * Definitions
mbed_official 146:f64d43ff0c18 45 ******************************************************************************/
mbed_official 324:406fd2029f23 46 /*! @brief I2C status return codes.*/
mbed_official 324:406fd2029f23 47 typedef enum _i2c_status {
mbed_official 324:406fd2029f23 48 kStatus_I2C_Success = 0x0U,
mbed_official 324:406fd2029f23 49 kStatus_I2C_OutOfRange = 0x1U,
mbed_official 324:406fd2029f23 50 kStatus_I2C_Fail = 0x2U,
mbed_official 324:406fd2029f23 51 kStatus_I2C_Busy = 0x3U, /*!< The master is already performing a transfer.*/
mbed_official 324:406fd2029f23 52 kStatus_I2C_Timeout = 0x4U, /*!< The transfer timed out.*/
mbed_official 324:406fd2029f23 53 kStatus_I2C_ReceivedNak = 0x5U, /*!< The slave device sent a NAK in response to a byte.*/
mbed_official 324:406fd2029f23 54 kStatus_I2C_SlaveTxUnderrun = 0x6U, /*!< I2C Slave TX Underrun error.*/
mbed_official 324:406fd2029f23 55 kStatus_I2C_SlaveRxOverrun = 0x7U, /*!< I2C Slave RX Overrun error.*/
mbed_official 324:406fd2029f23 56 kStatus_I2C_AribtrationLost = 0x8U, /*!< I2C Arbitration Lost error.*/
mbed_official 146:f64d43ff0c18 57 } i2c_status_t;
mbed_official 146:f64d43ff0c18 58
mbed_official 324:406fd2029f23 59 /*! @brief I2C status flags. */
mbed_official 324:406fd2029f23 60 typedef enum _i2c_status_flag {
mbed_official 324:406fd2029f23 61 kI2CTransferComplete = BP_I2C_S_TCF,
mbed_official 324:406fd2029f23 62 kI2CAddressAsSlave = BP_I2C_S_IAAS,
mbed_official 324:406fd2029f23 63 kI2CBusBusy = BP_I2C_S_BUSY,
mbed_official 324:406fd2029f23 64 kI2CArbitrationLost = BP_I2C_S_ARBL,
mbed_official 324:406fd2029f23 65 kI2CAddressMatch = BP_I2C_S_RAM,
mbed_official 324:406fd2029f23 66 kI2CSlaveTransmit = BP_I2C_S_SRW,
mbed_official 324:406fd2029f23 67 kI2CInterruptPending = BP_I2C_S_IICIF,
mbed_official 324:406fd2029f23 68 kI2CReceivedNak = BP_I2C_S_RXAK
mbed_official 324:406fd2029f23 69 } i2c_status_flag_t;
mbed_official 146:f64d43ff0c18 70
mbed_official 324:406fd2029f23 71 /*! @brief Direction of master and slave transfers.*/
mbed_official 324:406fd2029f23 72 typedef enum _i2c_direction {
mbed_official 324:406fd2029f23 73 kI2CReceive = 0U, /*!< Master and slave receive.*/
mbed_official 324:406fd2029f23 74 kI2CSend = 1U /*!< Master and slave transmit.*/
mbed_official 324:406fd2029f23 75 } i2c_direction_t;
mbed_official 146:f64d43ff0c18 76
mbed_official 146:f64d43ff0c18 77 /*******************************************************************************
mbed_official 146:f64d43ff0c18 78 * API
mbed_official 146:f64d43ff0c18 79 ******************************************************************************/
mbed_official 146:f64d43ff0c18 80
mbed_official 146:f64d43ff0c18 81 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 82 extern "C" {
mbed_official 146:f64d43ff0c18 83 #endif
mbed_official 146:f64d43ff0c18 84
mbed_official 146:f64d43ff0c18 85 /*!
mbed_official 324:406fd2029f23 86 * @name Module controls
mbed_official 324:406fd2029f23 87 * @{
mbed_official 146:f64d43ff0c18 88 */
mbed_official 146:f64d43ff0c18 89
mbed_official 146:f64d43ff0c18 90 /*!
mbed_official 146:f64d43ff0c18 91 * @brief Restores the I2C peripheral to reset state.
mbed_official 146:f64d43ff0c18 92 *
mbed_official 324:406fd2029f23 93 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 94 */
mbed_official 324:406fd2029f23 95 void I2C_HAL_Init(uint32_t baseAddr);
mbed_official 146:f64d43ff0c18 96
mbed_official 146:f64d43ff0c18 97 /*!
mbed_official 146:f64d43ff0c18 98 * @brief Enables the I2C module operation.
mbed_official 146:f64d43ff0c18 99 *
mbed_official 324:406fd2029f23 100 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 101 */
mbed_official 324:406fd2029f23 102 static inline void I2C_HAL_Enable(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 103 {
mbed_official 324:406fd2029f23 104 BW_I2C_C1_IICEN(baseAddr, 0x1U);
mbed_official 146:f64d43ff0c18 105 }
mbed_official 146:f64d43ff0c18 106
mbed_official 146:f64d43ff0c18 107 /*!
mbed_official 146:f64d43ff0c18 108 * @brief Disables the I2C module operation.
mbed_official 146:f64d43ff0c18 109 *
mbed_official 324:406fd2029f23 110 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 111 */
mbed_official 324:406fd2029f23 112 static inline void I2C_HAL_Disable(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 113 {
mbed_official 324:406fd2029f23 114 BW_I2C_C1_IICEN(baseAddr, 0x0U);
mbed_official 146:f64d43ff0c18 115 }
mbed_official 146:f64d43ff0c18 116
mbed_official 146:f64d43ff0c18 117 /*@}*/
mbed_official 146:f64d43ff0c18 118
mbed_official 324:406fd2029f23 119 /*!
mbed_official 324:406fd2029f23 120 * @name DMA
mbed_official 324:406fd2029f23 121 * @{
mbed_official 324:406fd2029f23 122 */
mbed_official 146:f64d43ff0c18 123
mbed_official 146:f64d43ff0c18 124 /*!
mbed_official 146:f64d43ff0c18 125 * @brief Enables or disables the DMA support.
mbed_official 146:f64d43ff0c18 126 *
mbed_official 324:406fd2029f23 127 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 128 * @param enable Pass true to enable DMA transfer signalling
mbed_official 146:f64d43ff0c18 129 */
mbed_official 324:406fd2029f23 130 static inline void I2C_HAL_SetDmaCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 131 {
mbed_official 324:406fd2029f23 132 BW_I2C_C1_DMAEN(baseAddr, (uint8_t)enable);
mbed_official 324:406fd2029f23 133 }
mbed_official 324:406fd2029f23 134
mbed_official 324:406fd2029f23 135 /*!
mbed_official 324:406fd2029f23 136 * @brief Returns whether I2C DMA support is enabled.
mbed_official 324:406fd2029f23 137 *
mbed_official 324:406fd2029f23 138 * @param baseAddr The I2C peripheral base address.
mbed_official 324:406fd2029f23 139 * @retval true I2C DMA is enabled.
mbed_official 324:406fd2029f23 140 * @retval false I2C DMA is disabled.
mbed_official 324:406fd2029f23 141 */
mbed_official 324:406fd2029f23 142 static inline bool I2C_HAL_GetDmaCmd(uint32_t baseAddr)
mbed_official 324:406fd2029f23 143 {
mbed_official 324:406fd2029f23 144 return BR_I2C_C1_DMAEN(baseAddr);
mbed_official 146:f64d43ff0c18 145 }
mbed_official 146:f64d43ff0c18 146
mbed_official 146:f64d43ff0c18 147 /*@}*/
mbed_official 146:f64d43ff0c18 148
mbed_official 324:406fd2029f23 149 /*!
mbed_official 324:406fd2029f23 150 * @name Pin functions
mbed_official 324:406fd2029f23 151 * @{
mbed_official 324:406fd2029f23 152 */
mbed_official 146:f64d43ff0c18 153
mbed_official 146:f64d43ff0c18 154 /*!
mbed_official 146:f64d43ff0c18 155 * @brief Controls the drive capability of the I2C pads.
mbed_official 146:f64d43ff0c18 156 *
mbed_official 324:406fd2029f23 157 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 158 * @param enable Passing true will enable high drive mode of the I2C pads. False sets normal
mbed_official 146:f64d43ff0c18 159 * drive mode.
mbed_official 146:f64d43ff0c18 160 */
mbed_official 324:406fd2029f23 161 static inline void I2C_HAL_SetHighDriveCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 162 {
mbed_official 324:406fd2029f23 163 BW_I2C_C2_HDRS(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 164 }
mbed_official 146:f64d43ff0c18 165
mbed_official 146:f64d43ff0c18 166 /*!
mbed_official 146:f64d43ff0c18 167 * @brief Controls the width of the programmable glitch filter.
mbed_official 146:f64d43ff0c18 168 *
mbed_official 146:f64d43ff0c18 169 * Controls the width of the glitch, in terms of bus clock cycles, that the filter must absorb.
mbed_official 146:f64d43ff0c18 170 * The filter does not allow any glitch whose size is less than or equal to this width setting,
mbed_official 146:f64d43ff0c18 171 * to pass.
mbed_official 146:f64d43ff0c18 172 *
mbed_official 324:406fd2029f23 173 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 174 * @param glitchWidth Maximum width in bus clock cycles of the glitches that is filtered.
mbed_official 146:f64d43ff0c18 175 * Pass zero to disable the glitch filter.
mbed_official 146:f64d43ff0c18 176 */
mbed_official 324:406fd2029f23 177 static inline void I2C_HAL_SetGlitchWidth(uint32_t baseAddr, uint8_t glitchWidth)
mbed_official 146:f64d43ff0c18 178 {
mbed_official 324:406fd2029f23 179 BW_I2C_FLT_FLT(baseAddr, glitchWidth);
mbed_official 146:f64d43ff0c18 180 }
mbed_official 146:f64d43ff0c18 181
mbed_official 146:f64d43ff0c18 182 /*@}*/
mbed_official 146:f64d43ff0c18 183
mbed_official 324:406fd2029f23 184 /*!
mbed_official 324:406fd2029f23 185 * @name Low power
mbed_official 324:406fd2029f23 186 * @{
mbed_official 324:406fd2029f23 187 */
mbed_official 146:f64d43ff0c18 188
mbed_official 146:f64d43ff0c18 189 /*!
mbed_official 146:f64d43ff0c18 190 * @brief Controls the I2C wakeup enable.
mbed_official 146:f64d43ff0c18 191 *
mbed_official 146:f64d43ff0c18 192 * The I2C module can wake the MCU from low power mode with no peripheral bus running when
mbed_official 146:f64d43ff0c18 193 * slave address matching occurs.
mbed_official 146:f64d43ff0c18 194 *
mbed_official 324:406fd2029f23 195 * @param baseAddr The I2C peripheral base address.
mbed_official 146:f64d43ff0c18 196 * @param enable true - Enables the wakeup function in low power mode.<br>
mbed_official 146:f64d43ff0c18 197 * false - Normal operation. No interrupt is generated when address matching in
mbed_official 146:f64d43ff0c18 198 * low power mode.
mbed_official 146:f64d43ff0c18 199 */
mbed_official 324:406fd2029f23 200 static inline void I2C_HAL_SetWakeupCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 201 {
mbed_official 324:406fd2029f23 202 BW_I2C_C1_WUEN(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 203 }
mbed_official 146:f64d43ff0c18 204
mbed_official 146:f64d43ff0c18 205 #if FSL_FEATURE_I2C_HAS_STOP_HOLD_OFF
mbed_official 146:f64d43ff0c18 206 /*!
mbed_official 146:f64d43ff0c18 207 * @brief Controls the stop mode hold off.
mbed_official 146:f64d43ff0c18 208 *
mbed_official 146:f64d43ff0c18 209 * This function lets you enable the hold off entry to low power stop mode when any data transmission
mbed_official 146:f64d43ff0c18 210 * or reception is occurring.
mbed_official 146:f64d43ff0c18 211 *
mbed_official 324:406fd2029f23 212 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 213 * @param enable false - Stop hold off is disabled. The MCU's entry to stop mode is not gated.<br>
mbed_official 146:f64d43ff0c18 214 * true - Stop hold off is enabled.
mbed_official 146:f64d43ff0c18 215 */
mbed_official 146:f64d43ff0c18 216
mbed_official 324:406fd2029f23 217 static inline void I2C_HAL_SetStopHoldoffCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 218 {
mbed_official 324:406fd2029f23 219 BW_I2C_FLT_SHEN(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 220 }
mbed_official 146:f64d43ff0c18 221 #endif /* FSL_FEATURE_I2C_HAS_STOP_HOLD_OFF*/
mbed_official 146:f64d43ff0c18 222
mbed_official 146:f64d43ff0c18 223 /*@}*/
mbed_official 146:f64d43ff0c18 224
mbed_official 146:f64d43ff0c18 225 /*!
mbed_official 324:406fd2029f23 226 * @name Baud rate
mbed_official 324:406fd2029f23 227 * @{
mbed_official 146:f64d43ff0c18 228 */
mbed_official 146:f64d43ff0c18 229
mbed_official 146:f64d43ff0c18 230 /*!
mbed_official 146:f64d43ff0c18 231 * @brief Sets the I2C bus frequency for master transactions.
mbed_official 146:f64d43ff0c18 232 *
mbed_official 324:406fd2029f23 233 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 234 * @param sourceClockInHz I2C source input clock in Hertz
mbed_official 146:f64d43ff0c18 235 * @param kbps Requested bus frequency in kilohertz. Common values are either 100 or 400.
mbed_official 146:f64d43ff0c18 236 * @param absoluteError_Hz If this parameter is not NULL, it is filled in with the
mbed_official 146:f64d43ff0c18 237 * difference in Hertz between the requested bus frequency and the closest frequency
mbed_official 146:f64d43ff0c18 238 * possible given available divider values.
mbed_official 146:f64d43ff0c18 239 *
mbed_official 146:f64d43ff0c18 240 * @retval kStatus_Success The baud rate was changed successfully. However, there is no
mbed_official 146:f64d43ff0c18 241 * guarantee on the minimum error. If you want to ensure that the baud was set to within
mbed_official 146:f64d43ff0c18 242 * a certain error, then use the @a absoluteError_Hz parameter.
mbed_official 146:f64d43ff0c18 243 * @retval kStatus_OutOfRange The requested baud rate was not within the range of rates
mbed_official 146:f64d43ff0c18 244 * supported by the peripheral.
mbed_official 146:f64d43ff0c18 245 */
mbed_official 324:406fd2029f23 246 i2c_status_t I2C_HAL_SetBaudRate(uint32_t baseAddr, uint32_t sourceClockInHz, uint32_t kbps,
mbed_official 146:f64d43ff0c18 247 uint32_t * absoluteError_Hz);
mbed_official 146:f64d43ff0c18 248
mbed_official 146:f64d43ff0c18 249 /*!
mbed_official 146:f64d43ff0c18 250 * @brief Sets the I2C baud rate multiplier and table entry.
mbed_official 146:f64d43ff0c18 251 *
mbed_official 146:f64d43ff0c18 252 * Use this function to set the I2C bus frequency register values directly, if they are
mbed_official 146:f64d43ff0c18 253 * known in advance.
mbed_official 146:f64d43ff0c18 254 *
mbed_official 324:406fd2029f23 255 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 256 * @param mult Value of the MULT bitfield, ranging from 0-2.
mbed_official 146:f64d43ff0c18 257 * @param icr The ICR bitfield value, which is the index into an internal table in the I2C
mbed_official 146:f64d43ff0c18 258 * hardware that selects the baud rate divisor and SCL hold time.
mbed_official 146:f64d43ff0c18 259 */
mbed_official 324:406fd2029f23 260 static inline void I2C_HAL_SetFreqDiv(uint32_t baseAddr, uint8_t mult, uint8_t icr)
mbed_official 146:f64d43ff0c18 261 {
mbed_official 324:406fd2029f23 262 HW_I2C_F_WR(baseAddr, BF_I2C_F_MULT(mult) | BF_I2C_F_ICR(icr));
mbed_official 146:f64d43ff0c18 263 }
mbed_official 146:f64d43ff0c18 264
mbed_official 146:f64d43ff0c18 265 /*!
mbed_official 146:f64d43ff0c18 266 * @brief Slave baud rate control
mbed_official 146:f64d43ff0c18 267 *
mbed_official 146:f64d43ff0c18 268 * Enables an independent slave mode baud rate at the maximum frequency. This forces clock stretching
mbed_official 146:f64d43ff0c18 269 * on the SCL in very fast I2C modes.
mbed_official 146:f64d43ff0c18 270 *
mbed_official 324:406fd2029f23 271 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 272 * @param enable true - Slave baud rate is independent of the master baud rate;<br>
mbed_official 146:f64d43ff0c18 273 * false - The slave baud rate follows the master baud rate and clock stretching may occur.
mbed_official 146:f64d43ff0c18 274 */
mbed_official 324:406fd2029f23 275 static inline void I2C_HAL_SetSlaveBaudCtrlCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 276 {
mbed_official 324:406fd2029f23 277 BW_I2C_C2_SBRC(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 278 }
mbed_official 146:f64d43ff0c18 279
mbed_official 146:f64d43ff0c18 280 /*@}*/
mbed_official 146:f64d43ff0c18 281
mbed_official 324:406fd2029f23 282 /*!
mbed_official 324:406fd2029f23 283 * @name Bus operations
mbed_official 324:406fd2029f23 284 * @{
mbed_official 324:406fd2029f23 285 */
mbed_official 146:f64d43ff0c18 286
mbed_official 146:f64d43ff0c18 287 /*!
mbed_official 146:f64d43ff0c18 288 * @brief Sends a START or a Repeated START signal on the I2C bus.
mbed_official 146:f64d43ff0c18 289 *
mbed_official 146:f64d43ff0c18 290 * This function is used to initiate a new master mode transfer by sending the START signal. It
mbed_official 146:f64d43ff0c18 291 * is also used to send a Repeated START signal when a transfer is already in progress.
mbed_official 146:f64d43ff0c18 292 *
mbed_official 324:406fd2029f23 293 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 294 */
mbed_official 324:406fd2029f23 295 void I2C_HAL_SendStart(uint32_t baseAddr);
mbed_official 146:f64d43ff0c18 296
mbed_official 146:f64d43ff0c18 297 /*!
mbed_official 146:f64d43ff0c18 298 * @brief Sends a STOP signal on the I2C bus.
mbed_official 146:f64d43ff0c18 299 *
mbed_official 324:406fd2029f23 300 * This function changes the direction to receive.
mbed_official 146:f64d43ff0c18 301 *
mbed_official 324:406fd2029f23 302 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 303 */
mbed_official 324:406fd2029f23 304 static inline void I2C_HAL_SendStop(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 305 {
mbed_official 324:406fd2029f23 306 assert(BR_I2C_C1_MST(baseAddr) == 1);
mbed_official 324:406fd2029f23 307 HW_I2C_C1_CLR(baseAddr, BM_I2C_C1_MST | BM_I2C_C1_TX);
mbed_official 146:f64d43ff0c18 308 }
mbed_official 146:f64d43ff0c18 309
mbed_official 146:f64d43ff0c18 310 /*!
mbed_official 146:f64d43ff0c18 311 * @brief Causes an ACK to be sent on the bus.
mbed_official 146:f64d43ff0c18 312 *
mbed_official 146:f64d43ff0c18 313 * This function specifies that an ACK signal is sent in response to the next received byte.
mbed_official 146:f64d43ff0c18 314 *
mbed_official 146:f64d43ff0c18 315 * Note that the behavior of this function is changed when the I2C peripheral is placed in
mbed_official 146:f64d43ff0c18 316 * Fast ACK mode. In this case, this function causes an ACK signal to be sent in
mbed_official 146:f64d43ff0c18 317 * response to the current byte, rather than the next received byte.
mbed_official 146:f64d43ff0c18 318 *
mbed_official 324:406fd2029f23 319 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 320 */
mbed_official 324:406fd2029f23 321 static inline void I2C_HAL_SendAck(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 322 {
mbed_official 324:406fd2029f23 323 BW_I2C_C1_TXAK(baseAddr, 0x0U);
mbed_official 146:f64d43ff0c18 324 }
mbed_official 146:f64d43ff0c18 325
mbed_official 146:f64d43ff0c18 326 /*!
mbed_official 146:f64d43ff0c18 327 * @brief Causes a NAK to be sent on the bus.
mbed_official 146:f64d43ff0c18 328 *
mbed_official 146:f64d43ff0c18 329 * This function specifies that a NAK signal is sent in response to the next received byte.
mbed_official 146:f64d43ff0c18 330 *
mbed_official 146:f64d43ff0c18 331 * Note that the behavior of this function is changed when the I2C peripheral is placed in the
mbed_official 146:f64d43ff0c18 332 * Fast ACK mode. In this case, this function causes an NAK signal to be sent in
mbed_official 146:f64d43ff0c18 333 * response to the current byte, rather than the next received byte.
mbed_official 146:f64d43ff0c18 334 *
mbed_official 324:406fd2029f23 335 * @param baseAddr The I2C peripheral base address
mbed_official 324:406fd2029f23 336 */
mbed_official 324:406fd2029f23 337 static inline void I2C_HAL_SendNak(uint32_t baseAddr)
mbed_official 324:406fd2029f23 338 {
mbed_official 324:406fd2029f23 339 BW_I2C_C1_TXAK(baseAddr, 0x1U);
mbed_official 324:406fd2029f23 340 }
mbed_official 324:406fd2029f23 341
mbed_official 324:406fd2029f23 342 /*!
mbed_official 324:406fd2029f23 343 * @brief Selects either transmit or receive mode.
mbed_official 324:406fd2029f23 344 *
mbed_official 324:406fd2029f23 345 * @param baseAddr The I2C peripheral base address.
mbed_official 324:406fd2029f23 346 * @param direction Specifies either transmit mode or receive mode. The valid values are:
mbed_official 324:406fd2029f23 347 * - #kI2CTransmit
mbed_official 324:406fd2029f23 348 * - #kI2CReceive
mbed_official 146:f64d43ff0c18 349 */
mbed_official 324:406fd2029f23 350 static inline void I2C_HAL_SetDirMode(uint32_t baseAddr, i2c_direction_t direction)
mbed_official 146:f64d43ff0c18 351 {
mbed_official 324:406fd2029f23 352 BW_I2C_C1_TX(baseAddr, (uint8_t)direction);
mbed_official 324:406fd2029f23 353 }
mbed_official 324:406fd2029f23 354
mbed_official 324:406fd2029f23 355 /*!
mbed_official 324:406fd2029f23 356 * @brief Returns the currently selected transmit or receive mode.
mbed_official 324:406fd2029f23 357 *
mbed_official 324:406fd2029f23 358 * @param baseAddr The I2C peripheral base address.
mbed_official 324:406fd2029f23 359 * @retval #kI2CTransmit I2C is configured for master or slave transmit mode.
mbed_official 324:406fd2029f23 360 * @retval #kI2CReceive I2C is configured for master or slave receive mode.
mbed_official 324:406fd2029f23 361 */
mbed_official 324:406fd2029f23 362 static inline i2c_direction_t I2C_HAL_GetDirMode(uint32_t baseAddr)
mbed_official 324:406fd2029f23 363 {
mbed_official 324:406fd2029f23 364 return (i2c_direction_t)BR_I2C_C1_TX(baseAddr);
mbed_official 146:f64d43ff0c18 365 }
mbed_official 146:f64d43ff0c18 366
mbed_official 146:f64d43ff0c18 367 /*@}*/
mbed_official 146:f64d43ff0c18 368
mbed_official 324:406fd2029f23 369 /*!
mbed_official 324:406fd2029f23 370 * @name Data transfer
mbed_official 324:406fd2029f23 371 * @{
mbed_official 324:406fd2029f23 372 */
mbed_official 146:f64d43ff0c18 373
mbed_official 146:f64d43ff0c18 374 /*!
mbed_official 146:f64d43ff0c18 375 * @brief Returns the last byte of data read from the bus and initiate another read.
mbed_official 146:f64d43ff0c18 376 *
mbed_official 146:f64d43ff0c18 377 * In a master receive mode, calling this function initiates receiving the next byte of data.
mbed_official 146:f64d43ff0c18 378 *
mbed_official 324:406fd2029f23 379 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 380 * @return This function returns the last byte received while the I2C module is configured in master
mbed_official 146:f64d43ff0c18 381 * receive or slave receive mode.
mbed_official 146:f64d43ff0c18 382 */
mbed_official 324:406fd2029f23 383 static inline uint8_t I2C_HAL_ReadByte(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 384 {
mbed_official 324:406fd2029f23 385 return HW_I2C_D_RD(baseAddr);
mbed_official 146:f64d43ff0c18 386 }
mbed_official 146:f64d43ff0c18 387
mbed_official 146:f64d43ff0c18 388 /*!
mbed_official 146:f64d43ff0c18 389 * @brief Writes one byte of data to the I2C bus.
mbed_official 146:f64d43ff0c18 390 *
mbed_official 146:f64d43ff0c18 391 * When this function is called in the master transmit mode, a data transfer is initiated. In slave
mbed_official 146:f64d43ff0c18 392 * mode, the same function is available after an address match occurs.
mbed_official 146:f64d43ff0c18 393 *
mbed_official 146:f64d43ff0c18 394 * In a master transmit mode, the first byte of data written following the start bit or repeated
mbed_official 146:f64d43ff0c18 395 * start bit is used for the address transfer and must consist of the slave address (in bits 7-1)
mbed_official 146:f64d43ff0c18 396 * concatenated with the required R/\#W bit (in position bit 0).
mbed_official 146:f64d43ff0c18 397 *
mbed_official 324:406fd2029f23 398 * @param baseAddr The I2C peripheral base address.
mbed_official 324:406fd2029f23 399 * @param byte The byte of data to transmit.
mbed_official 146:f64d43ff0c18 400 */
mbed_official 324:406fd2029f23 401 static inline void I2C_HAL_WriteByte(uint32_t baseAddr, uint8_t byte)
mbed_official 146:f64d43ff0c18 402 {
mbed_official 324:406fd2029f23 403 HW_I2C_D_WR(baseAddr, byte);
mbed_official 146:f64d43ff0c18 404 }
mbed_official 146:f64d43ff0c18 405
mbed_official 146:f64d43ff0c18 406 /*@}*/
mbed_official 146:f64d43ff0c18 407
mbed_official 324:406fd2029f23 408 /*!
mbed_official 324:406fd2029f23 409 * @name Slave address
mbed_official 324:406fd2029f23 410 * @{
mbed_official 324:406fd2029f23 411 */
mbed_official 146:f64d43ff0c18 412
mbed_official 146:f64d43ff0c18 413 /*!
mbed_official 146:f64d43ff0c18 414 * @brief Sets the primary 7-bit slave address.
mbed_official 146:f64d43ff0c18 415 *
mbed_official 324:406fd2029f23 416 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 417 * @param address The slave address in the upper 7 bits. Bit 0 of this value must be 0.
mbed_official 146:f64d43ff0c18 418 */
mbed_official 324:406fd2029f23 419 void I2C_HAL_SetAddress7bit(uint32_t baseAddr, uint8_t address);
mbed_official 146:f64d43ff0c18 420
mbed_official 146:f64d43ff0c18 421 /*!
mbed_official 146:f64d43ff0c18 422 * @brief Sets the primary slave address and enables 10-bit address mode.
mbed_official 146:f64d43ff0c18 423 *
mbed_official 324:406fd2029f23 424 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 425 * @param address The 10-bit slave address, in bits [10:1] of the value. Bit 0 must be 0.
mbed_official 146:f64d43ff0c18 426 */
mbed_official 324:406fd2029f23 427 void I2C_HAL_SetAddress10bit(uint32_t baseAddr, uint16_t address);
mbed_official 324:406fd2029f23 428
mbed_official 324:406fd2029f23 429 /*!
mbed_official 324:406fd2029f23 430 * @brief Enables or disables the extension address (10-bit).
mbed_official 324:406fd2029f23 431 *
mbed_official 324:406fd2029f23 432 * @param baseAddr The I2C peripheral base address
mbed_official 324:406fd2029f23 433 * @param enable true: 10-bit address is enabled.
mbed_official 324:406fd2029f23 434 * false: 10-bit address is not enabled.
mbed_official 324:406fd2029f23 435 */
mbed_official 324:406fd2029f23 436 static inline void I2C_HAL_SetExtensionAddrCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 437 {
mbed_official 324:406fd2029f23 438 BW_I2C_C2_ADEXT(baseAddr, (uint8_t)enable);
mbed_official 324:406fd2029f23 439 }
mbed_official 324:406fd2029f23 440
mbed_official 324:406fd2029f23 441 /*!
mbed_official 324:406fd2029f23 442 * @brief Returns whether the extension address is enabled or not.
mbed_official 324:406fd2029f23 443 *
mbed_official 324:406fd2029f23 444 * @param baseAddr The I2C peripheral base address
mbed_official 324:406fd2029f23 445 * @return true: 10-bit address is enabled.
mbed_official 324:406fd2029f23 446 * false: 10-bit address is not enabled.
mbed_official 324:406fd2029f23 447 */
mbed_official 324:406fd2029f23 448 static inline bool I2C_HAL_GetExtensionAddrCmd(uint32_t baseAddr)
mbed_official 324:406fd2029f23 449 {
mbed_official 324:406fd2029f23 450 return BR_I2C_C2_ADEXT(baseAddr);
mbed_official 324:406fd2029f23 451 }
mbed_official 146:f64d43ff0c18 452
mbed_official 146:f64d43ff0c18 453 /*!
mbed_official 146:f64d43ff0c18 454 * @brief Controls whether the general call address is recognized.
mbed_official 146:f64d43ff0c18 455 *
mbed_official 324:406fd2029f23 456 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 457 * @param enable Whether to enable the general call address.
mbed_official 146:f64d43ff0c18 458 */
mbed_official 324:406fd2029f23 459 static inline void I2C_HAL_SetGeneralCallCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 460 {
mbed_official 324:406fd2029f23 461 BW_I2C_C2_GCAEN(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 462 }
mbed_official 146:f64d43ff0c18 463
mbed_official 146:f64d43ff0c18 464 /*!
mbed_official 146:f64d43ff0c18 465 * @brief Enables or disables the slave address range matching.
mbed_official 146:f64d43ff0c18 466 *
mbed_official 324:406fd2029f23 467 * @param baseAddr The I2C peripheral base address.
mbed_official 324:406fd2029f23 468 * @param enable Pass true to enable range address matching. You must also call
mbed_official 324:406fd2029f23 469 * I2C_HAL_SetUpperAddress7bit() to set the upper address.
mbed_official 146:f64d43ff0c18 470 */
mbed_official 324:406fd2029f23 471 static inline void I2C_HAL_SetRangeMatchCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 472 {
mbed_official 324:406fd2029f23 473 BW_I2C_C2_RMEN(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 474 }
mbed_official 146:f64d43ff0c18 475
mbed_official 146:f64d43ff0c18 476 /*!
mbed_official 146:f64d43ff0c18 477 * @brief Sets the upper slave address.
mbed_official 146:f64d43ff0c18 478 *
mbed_official 146:f64d43ff0c18 479 * This slave address is used as a secondary slave address. If range address
mbed_official 146:f64d43ff0c18 480 * matching is enabled, this slave address acts as the upper bound on the slave address
mbed_official 146:f64d43ff0c18 481 * range.
mbed_official 146:f64d43ff0c18 482 *
mbed_official 324:406fd2029f23 483 * This function sets only a 7-bit slave address. If 10-bit addressing was enabled by calling
mbed_official 324:406fd2029f23 484 * I2C_HAL_SetAddress10bit(), then the top 3 bits set with that function are also used
mbed_official 146:f64d43ff0c18 485 * with the address set with this function to form a 10-bit address.
mbed_official 146:f64d43ff0c18 486 *
mbed_official 146:f64d43ff0c18 487 * Passing 0 for the @a address parameter disables matching the upper slave address.
mbed_official 146:f64d43ff0c18 488 *
mbed_official 324:406fd2029f23 489 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 490 * @param address The upper slave address in the upper 7 bits. Bit 0 of this value must be 0.
mbed_official 324:406fd2029f23 491 * In addition, this address must be greater than the primary slave address that is set by
mbed_official 324:406fd2029f23 492 * calling I2C_HAL_SetAddress7bit().
mbed_official 146:f64d43ff0c18 493 */
mbed_official 324:406fd2029f23 494 static inline void I2C_HAL_SetUpperAddress7bit(uint32_t baseAddr, uint8_t address)
mbed_official 146:f64d43ff0c18 495 {
mbed_official 146:f64d43ff0c18 496 assert((address & 1) == 0);
mbed_official 324:406fd2029f23 497 assert((address == 0) || (address > HW_I2C_A1_RD(baseAddr)));
mbed_official 324:406fd2029f23 498 HW_I2C_RA_WR(baseAddr, address);
mbed_official 146:f64d43ff0c18 499 }
mbed_official 146:f64d43ff0c18 500
mbed_official 146:f64d43ff0c18 501 /*@}*/
mbed_official 146:f64d43ff0c18 502
mbed_official 324:406fd2029f23 503 /*!
mbed_official 324:406fd2029f23 504 * @name Status
mbed_official 324:406fd2029f23 505 * @{
mbed_official 324:406fd2029f23 506 */
mbed_official 324:406fd2029f23 507
mbed_official 324:406fd2029f23 508 /*!
mbed_official 324:406fd2029f23 509 * @brief Gets the I2C status flag state.
mbed_official 324:406fd2029f23 510 *
mbed_official 324:406fd2029f23 511 * @param baseAddr The I2C peripheral base address.
mbed_official 324:406fd2029f23 512 * @param statusFlag The status flag, defined in type i2c_status_flag_t.
mbed_official 324:406fd2029f23 513 * @return State of the status flag: asserted (true) or not-asserted (false).
mbed_official 324:406fd2029f23 514 * - true: related status flag is being set.
mbed_official 324:406fd2029f23 515 * - false: related status flag is not set.
mbed_official 324:406fd2029f23 516 */
mbed_official 324:406fd2029f23 517 static inline bool I2C_HAL_GetStatusFlag(uint32_t baseAddr, i2c_status_flag_t statusFlag)
mbed_official 324:406fd2029f23 518 {
mbed_official 324:406fd2029f23 519 return (bool)((HW_I2C_S_RD(baseAddr) >> statusFlag) & 0x1U);
mbed_official 324:406fd2029f23 520 }
mbed_official 146:f64d43ff0c18 521
mbed_official 146:f64d43ff0c18 522 /*!
mbed_official 146:f64d43ff0c18 523 * @brief Returns whether the I2C module is in master mode.
mbed_official 146:f64d43ff0c18 524 *
mbed_official 324:406fd2029f23 525 * @param baseAddr The I2C peripheral base address.
mbed_official 146:f64d43ff0c18 526 * @retval true The module is in master mode, which implies it is also performing a transfer.
mbed_official 146:f64d43ff0c18 527 * @retval false The module is in slave mode.
mbed_official 146:f64d43ff0c18 528 */
mbed_official 324:406fd2029f23 529 static inline bool I2C_HAL_IsMaster(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 530 {
mbed_official 324:406fd2029f23 531 return (bool)BR_I2C_C1_MST(baseAddr);
mbed_official 146:f64d43ff0c18 532 }
mbed_official 146:f64d43ff0c18 533
mbed_official 146:f64d43ff0c18 534 /*!
mbed_official 146:f64d43ff0c18 535 * @brief Clears the arbitration lost flag.
mbed_official 146:f64d43ff0c18 536 *
mbed_official 324:406fd2029f23 537 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 538 */
mbed_official 324:406fd2029f23 539 static inline void I2C_HAL_ClearArbitrationLost(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 540 {
mbed_official 324:406fd2029f23 541 BW_I2C_S_ARBL(baseAddr, 0x1U);
mbed_official 146:f64d43ff0c18 542 }
mbed_official 146:f64d43ff0c18 543
mbed_official 146:f64d43ff0c18 544 /*@}*/
mbed_official 146:f64d43ff0c18 545
mbed_official 324:406fd2029f23 546 /*!
mbed_official 324:406fd2029f23 547 * @name Interrupt
mbed_official 324:406fd2029f23 548 * @{
mbed_official 324:406fd2029f23 549 */
mbed_official 146:f64d43ff0c18 550
mbed_official 146:f64d43ff0c18 551 /*!
mbed_official 324:406fd2029f23 552 * @brief Enables or disables I2C interrupt requests.
mbed_official 146:f64d43ff0c18 553 *
mbed_official 324:406fd2029f23 554 * @param baseAddr The I2C peripheral base address
mbed_official 324:406fd2029f23 555 * @param enable Pass true to enable interrupt, flase to disable.
mbed_official 146:f64d43ff0c18 556 */
mbed_official 324:406fd2029f23 557 static inline void I2C_HAL_SetIntCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 558 {
mbed_official 324:406fd2029f23 559 BW_I2C_C1_IICIE(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 560 }
mbed_official 146:f64d43ff0c18 561
mbed_official 146:f64d43ff0c18 562 /*!
mbed_official 146:f64d43ff0c18 563 * @brief Returns whether the I2C interrupts are enabled.
mbed_official 146:f64d43ff0c18 564 *
mbed_official 324:406fd2029f23 565 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 566 * @retval true I2C interrupts are enabled.
mbed_official 146:f64d43ff0c18 567 * @retval false I2C interrupts are disabled.
mbed_official 146:f64d43ff0c18 568 */
mbed_official 324:406fd2029f23 569 static inline bool I2C_HAL_GetIntCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 570 {
mbed_official 324:406fd2029f23 571 return (bool)BR_I2C_C1_IICIE(baseAddr);
mbed_official 146:f64d43ff0c18 572 }
mbed_official 146:f64d43ff0c18 573
mbed_official 146:f64d43ff0c18 574 /*!
mbed_official 146:f64d43ff0c18 575 * @brief Returns the current I2C interrupt flag.
mbed_official 146:f64d43ff0c18 576 *
mbed_official 324:406fd2029f23 577 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 578 * @retval true An interrupt is pending.
mbed_official 146:f64d43ff0c18 579 * @retval false No interrupt is pending.
mbed_official 146:f64d43ff0c18 580 */
mbed_official 324:406fd2029f23 581 static inline bool I2C_HAL_IsIntPending(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 582 {
mbed_official 324:406fd2029f23 583 return (bool)BR_I2C_S_IICIF(baseAddr);
mbed_official 146:f64d43ff0c18 584 }
mbed_official 146:f64d43ff0c18 585
mbed_official 146:f64d43ff0c18 586 /*!
mbed_official 146:f64d43ff0c18 587 * @brief Clears the I2C interrupt if set.
mbed_official 146:f64d43ff0c18 588 *
mbed_official 324:406fd2029f23 589 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 590 */
mbed_official 324:406fd2029f23 591 static inline void I2C_HAL_ClearInt(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 592 {
mbed_official 324:406fd2029f23 593 BW_I2C_S_IICIF(baseAddr, 0x1U);
mbed_official 146:f64d43ff0c18 594 }
mbed_official 146:f64d43ff0c18 595
mbed_official 146:f64d43ff0c18 596 /*@}*/
mbed_official 146:f64d43ff0c18 597
mbed_official 146:f64d43ff0c18 598 #if FSL_FEATURE_I2C_HAS_STOP_DETECT
mbed_official 146:f64d43ff0c18 599
mbed_official 324:406fd2029f23 600 /*!
mbed_official 324:406fd2029f23 601 * @name Bus stop detection status
mbed_official 324:406fd2029f23 602 * @{
mbed_official 324:406fd2029f23 603 */
mbed_official 146:f64d43ff0c18 604
mbed_official 146:f64d43ff0c18 605 /*!
mbed_official 146:f64d43ff0c18 606 * @brief Gets the flag indicating a STOP signal was detected on the I2C bus.
mbed_official 146:f64d43ff0c18 607 *
mbed_official 324:406fd2029f23 608 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 609 * @retval true STOP signal detected on bus.
mbed_official 146:f64d43ff0c18 610 * @retval false No STOP signal was detected on the bus.
mbed_official 146:f64d43ff0c18 611 */
mbed_official 324:406fd2029f23 612 static inline bool I2C_HAL_GetStopFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 613 {
mbed_official 324:406fd2029f23 614 return (bool)BR_I2C_FLT_STOPF(baseAddr);
mbed_official 146:f64d43ff0c18 615 }
mbed_official 146:f64d43ff0c18 616
mbed_official 146:f64d43ff0c18 617 /*!
mbed_official 146:f64d43ff0c18 618 * @brief Clears the bus STOP signal detected flag.
mbed_official 146:f64d43ff0c18 619 *
mbed_official 324:406fd2029f23 620 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 621 */
mbed_official 324:406fd2029f23 622 static inline void I2C_HAL_ClearStopFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 623 {
mbed_official 324:406fd2029f23 624 BW_I2C_FLT_STOPF(baseAddr, 0x1U);
mbed_official 146:f64d43ff0c18 625 }
mbed_official 146:f64d43ff0c18 626
mbed_official 146:f64d43ff0c18 627 /*@}*/
mbed_official 324:406fd2029f23 628
mbed_official 146:f64d43ff0c18 629 #if FSL_FEATURE_I2C_HAS_START_DETECT
mbed_official 146:f64d43ff0c18 630
mbed_official 324:406fd2029f23 631 /*!
mbed_official 324:406fd2029f23 632 * @name Bus stop detection interrupt
mbed_official 324:406fd2029f23 633 * @{
mbed_official 324:406fd2029f23 634 */
mbed_official 146:f64d43ff0c18 635
mbed_official 146:f64d43ff0c18 636 /*!
mbed_official 146:f64d43ff0c18 637 * @brief Enables the I2C bus stop detection interrupt.
mbed_official 146:f64d43ff0c18 638 *
mbed_official 324:406fd2029f23 639 * @param baseAddr The I2C peripheral base address
mbed_official 324:406fd2029f23 640 * @param enable Pass true to enable interrupt, flase to disable.
mbed_official 146:f64d43ff0c18 641 */
mbed_official 324:406fd2029f23 642 static inline void I2C_HAL_SetStopIntCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 643 {
mbed_official 324:406fd2029f23 644 BW_I2C_FLT_SSIE(baseAddr, enable);
mbed_official 146:f64d43ff0c18 645 }
mbed_official 146:f64d43ff0c18 646
mbed_official 146:f64d43ff0c18 647 /*!
mbed_official 146:f64d43ff0c18 648 * @brief Returns whether the I2C bus stop detection interrupts are enabled.
mbed_official 146:f64d43ff0c18 649 *
mbed_official 324:406fd2029f23 650 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 651 * @retval true Stop detect interrupts are enabled.
mbed_official 146:f64d43ff0c18 652 * @retval false Stop detect interrupts are disabled.
mbed_official 146:f64d43ff0c18 653 */
mbed_official 324:406fd2029f23 654 static inline bool I2C_HAL_GetStopIntCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 655 {
mbed_official 324:406fd2029f23 656 return (bool)BR_I2C_FLT_SSIE(baseAddr);
mbed_official 146:f64d43ff0c18 657 }
mbed_official 146:f64d43ff0c18 658
mbed_official 146:f64d43ff0c18 659 #else
mbed_official 146:f64d43ff0c18 660
mbed_official 146:f64d43ff0c18 661 /*! @name Bus stop detection interrupt*/
mbed_official 146:f64d43ff0c18 662 /*@{*/
mbed_official 146:f64d43ff0c18 663
mbed_official 146:f64d43ff0c18 664 /*!
mbed_official 146:f64d43ff0c18 665 * @brief Enables the I2C bus stop detection interrupt.
mbed_official 146:f64d43ff0c18 666 *
mbed_official 324:406fd2029f23 667 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 668 */
mbed_official 324:406fd2029f23 669 static inline void I2C_HAL_SetStopIntCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 670 {
mbed_official 324:406fd2029f23 671 BW_I2C_FLT_STOPIE(baseAddr, enable);
mbed_official 146:f64d43ff0c18 672 }
mbed_official 146:f64d43ff0c18 673
mbed_official 146:f64d43ff0c18 674 /*!
mbed_official 146:f64d43ff0c18 675 * @brief Returns whether the I2C bus stop detection interrupts are enabled.
mbed_official 146:f64d43ff0c18 676 *
mbed_official 324:406fd2029f23 677 * @param baseAddr The I2C peripheral base address
mbed_official 146:f64d43ff0c18 678 * @retval true Stop detect interrupts are enabled.
mbed_official 146:f64d43ff0c18 679 * @retval false Stop detect interrupts are disabled.
mbed_official 146:f64d43ff0c18 680 */
mbed_official 324:406fd2029f23 681 static inline bool I2C_HAL_GetStopIntCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 682 {
mbed_official 324:406fd2029f23 683 return (bool)BR_I2C_FLT_STOPIE(baseAddr);
mbed_official 146:f64d43ff0c18 684 }
mbed_official 146:f64d43ff0c18 685
mbed_official 146:f64d43ff0c18 686 #endif /* FSL_FEATURE_I2C_HAS_START_DETECT*/
mbed_official 146:f64d43ff0c18 687
mbed_official 146:f64d43ff0c18 688 /*@}*/
mbed_official 146:f64d43ff0c18 689 #endif /* FSL_FEATURE_I2C_HAS_STOP_DETECT*/
mbed_official 146:f64d43ff0c18 690
mbed_official 146:f64d43ff0c18 691 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 692 }
mbed_official 146:f64d43ff0c18 693 #endif
mbed_official 146:f64d43ff0c18 694
mbed_official 324:406fd2029f23 695 /*! @} */
mbed_official 146:f64d43ff0c18 696
mbed_official 146:f64d43ff0c18 697 #endif /* __FSL_I2C_HAL_H__*/
mbed_official 146:f64d43ff0c18 698 /*******************************************************************************
mbed_official 146:f64d43ff0c18 699 * EOF
mbed_official 146:f64d43ff0c18 700 ******************************************************************************/
mbed_official 146:f64d43ff0c18 701
mbed_official 324:406fd2029f23 702