MacroRat / MouseCode

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /*
sahilmgandhi 18:6a4db94011d3 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
sahilmgandhi 18:6a4db94011d3 3 * All rights reserved.
sahilmgandhi 18:6a4db94011d3 4 *
sahilmgandhi 18:6a4db94011d3 5 * Redistribution and use in source and binary forms, with or without modification,
sahilmgandhi 18:6a4db94011d3 6 * are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * o Redistributions of source code must retain the above copyright notice, this list
sahilmgandhi 18:6a4db94011d3 9 * of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 10 *
sahilmgandhi 18:6a4db94011d3 11 * o Redistributions in binary form must reproduce the above copyright notice, this
sahilmgandhi 18:6a4db94011d3 12 * list of conditions and the following disclaimer in the documentation and/or
sahilmgandhi 18:6a4db94011d3 13 * other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 14 *
sahilmgandhi 18:6a4db94011d3 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
sahilmgandhi 18:6a4db94011d3 16 * contributors may be used to endorse or promote products derived from this
sahilmgandhi 18:6a4db94011d3 17 * software without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 18 *
sahilmgandhi 18:6a4db94011d3 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
sahilmgandhi 18:6a4db94011d3 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
sahilmgandhi 18:6a4db94011d3 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
sahilmgandhi 18:6a4db94011d3 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
sahilmgandhi 18:6a4db94011d3 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
sahilmgandhi 18:6a4db94011d3 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
sahilmgandhi 18:6a4db94011d3 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
sahilmgandhi 18:6a4db94011d3 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
sahilmgandhi 18:6a4db94011d3 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
sahilmgandhi 18:6a4db94011d3 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 29 */
sahilmgandhi 18:6a4db94011d3 30 #ifndef _FSL_I2C_H_
sahilmgandhi 18:6a4db94011d3 31 #define _FSL_I2C_H_
sahilmgandhi 18:6a4db94011d3 32
sahilmgandhi 18:6a4db94011d3 33 #include "fsl_common.h"
sahilmgandhi 18:6a4db94011d3 34
sahilmgandhi 18:6a4db94011d3 35 /*!
sahilmgandhi 18:6a4db94011d3 36 * @addtogroup i2c_driver
sahilmgandhi 18:6a4db94011d3 37 * @{
sahilmgandhi 18:6a4db94011d3 38 */
sahilmgandhi 18:6a4db94011d3 39
sahilmgandhi 18:6a4db94011d3 40 /*******************************************************************************
sahilmgandhi 18:6a4db94011d3 41 * Definitions
sahilmgandhi 18:6a4db94011d3 42 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 43
sahilmgandhi 18:6a4db94011d3 44 /*! @name Driver version */
sahilmgandhi 18:6a4db94011d3 45 /*@{*/
sahilmgandhi 18:6a4db94011d3 46 /*! @brief I2C driver version 2.0.2. */
sahilmgandhi 18:6a4db94011d3 47 #define FSL_I2C_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
sahilmgandhi 18:6a4db94011d3 48 /*@}*/
sahilmgandhi 18:6a4db94011d3 49
sahilmgandhi 18:6a4db94011d3 50 #if (defined(FSL_FEATURE_I2C_HAS_START_STOP_DETECT) && FSL_FEATURE_I2C_HAS_START_STOP_DETECT || \
sahilmgandhi 18:6a4db94011d3 51 defined(FSL_FEATURE_I2C_HAS_STOP_DETECT) && FSL_FEATURE_I2C_HAS_STOP_DETECT)
sahilmgandhi 18:6a4db94011d3 52 #define I2C_HAS_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 53 #endif /* FSL_FEATURE_I2C_HAS_START_STOP_DETECT / FSL_FEATURE_I2C_HAS_STOP_DETECT */
sahilmgandhi 18:6a4db94011d3 54
sahilmgandhi 18:6a4db94011d3 55 /*! @brief I2C status return codes. */
sahilmgandhi 18:6a4db94011d3 56 enum _i2c_status
sahilmgandhi 18:6a4db94011d3 57 {
sahilmgandhi 18:6a4db94011d3 58 kStatus_I2C_Busy = MAKE_STATUS(kStatusGroup_I2C, 0), /*!< I2C is busy with current transfer. */
sahilmgandhi 18:6a4db94011d3 59 kStatus_I2C_Idle = MAKE_STATUS(kStatusGroup_I2C, 1), /*!< Bus is Idle. */
sahilmgandhi 18:6a4db94011d3 60 kStatus_I2C_Nak = MAKE_STATUS(kStatusGroup_I2C, 2), /*!< NAK received during transfer. */
sahilmgandhi 18:6a4db94011d3 61 kStatus_I2C_ArbitrationLost = MAKE_STATUS(kStatusGroup_I2C, 3), /*!< Arbitration lost during transfer. */
sahilmgandhi 18:6a4db94011d3 62 kStatus_I2C_Timeout = MAKE_STATUS(kStatusGroup_I2C, 4), /*!< Wait event timeout. */
sahilmgandhi 18:6a4db94011d3 63 kStatus_I2C_Addr_Nak = MAKE_STATUS(kStatusGroup_I2C, 5), /*!< NAK received during the address probe. */
sahilmgandhi 18:6a4db94011d3 64 };
sahilmgandhi 18:6a4db94011d3 65
sahilmgandhi 18:6a4db94011d3 66 /*!
sahilmgandhi 18:6a4db94011d3 67 * @brief I2C peripheral flags
sahilmgandhi 18:6a4db94011d3 68 *
sahilmgandhi 18:6a4db94011d3 69 * The following status register flags can be cleared:
sahilmgandhi 18:6a4db94011d3 70 * - #kI2C_ArbitrationLostFlag
sahilmgandhi 18:6a4db94011d3 71 * - #kI2C_IntPendingFlag
sahilmgandhi 18:6a4db94011d3 72 * - #kI2C_StartDetectFlag
sahilmgandhi 18:6a4db94011d3 73 * - #kI2C_StopDetectFlag
sahilmgandhi 18:6a4db94011d3 74 *
sahilmgandhi 18:6a4db94011d3 75 * @note These enumerations are meant to be OR'd together to form a bit mask.
sahilmgandhi 18:6a4db94011d3 76 *
sahilmgandhi 18:6a4db94011d3 77 */
sahilmgandhi 18:6a4db94011d3 78 enum _i2c_flags
sahilmgandhi 18:6a4db94011d3 79 {
sahilmgandhi 18:6a4db94011d3 80 kI2C_ReceiveNakFlag = I2C_S_RXAK_MASK, /*!< I2C receive NAK flag. */
sahilmgandhi 18:6a4db94011d3 81 kI2C_IntPendingFlag = I2C_S_IICIF_MASK, /*!< I2C interrupt pending flag. */
sahilmgandhi 18:6a4db94011d3 82 kI2C_TransferDirectionFlag = I2C_S_SRW_MASK, /*!< I2C transfer direction flag. */
sahilmgandhi 18:6a4db94011d3 83 kI2C_RangeAddressMatchFlag = I2C_S_RAM_MASK, /*!< I2C range address match flag. */
sahilmgandhi 18:6a4db94011d3 84 kI2C_ArbitrationLostFlag = I2C_S_ARBL_MASK, /*!< I2C arbitration lost flag. */
sahilmgandhi 18:6a4db94011d3 85 kI2C_BusBusyFlag = I2C_S_BUSY_MASK, /*!< I2C bus busy flag. */
sahilmgandhi 18:6a4db94011d3 86 kI2C_AddressMatchFlag = I2C_S_IAAS_MASK, /*!< I2C address match flag. */
sahilmgandhi 18:6a4db94011d3 87 kI2C_TransferCompleteFlag = I2C_S_TCF_MASK, /*!< I2C transfer complete flag. */
sahilmgandhi 18:6a4db94011d3 88 #ifdef I2C_HAS_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 89 kI2C_StopDetectFlag = I2C_FLT_STOPF_MASK << 8, /*!< I2C stop detect flag. */
sahilmgandhi 18:6a4db94011d3 90 #endif /* FSL_FEATURE_I2C_HAS_START_STOP_DETECT / FSL_FEATURE_I2C_HAS_STOP_DETECT */
sahilmgandhi 18:6a4db94011d3 91
sahilmgandhi 18:6a4db94011d3 92 #if defined(FSL_FEATURE_I2C_HAS_START_STOP_DETECT) && FSL_FEATURE_I2C_HAS_START_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 93 kI2C_StartDetectFlag = I2C_FLT_STARTF_MASK << 8, /*!< I2C start detect flag. */
sahilmgandhi 18:6a4db94011d3 94 #endif /* FSL_FEATURE_I2C_HAS_START_STOP_DETECT */
sahilmgandhi 18:6a4db94011d3 95 };
sahilmgandhi 18:6a4db94011d3 96
sahilmgandhi 18:6a4db94011d3 97 /*! @brief I2C feature interrupt source. */
sahilmgandhi 18:6a4db94011d3 98 enum _i2c_interrupt_enable
sahilmgandhi 18:6a4db94011d3 99 {
sahilmgandhi 18:6a4db94011d3 100 kI2C_GlobalInterruptEnable = I2C_C1_IICIE_MASK, /*!< I2C global interrupt. */
sahilmgandhi 18:6a4db94011d3 101
sahilmgandhi 18:6a4db94011d3 102 #if defined(FSL_FEATURE_I2C_HAS_STOP_DETECT) && FSL_FEATURE_I2C_HAS_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 103 kI2C_StopDetectInterruptEnable = I2C_FLT_STOPIE_MASK, /*!< I2C stop detect interrupt. */
sahilmgandhi 18:6a4db94011d3 104 #endif /* FSL_FEATURE_I2C_HAS_STOP_DETECT */
sahilmgandhi 18:6a4db94011d3 105
sahilmgandhi 18:6a4db94011d3 106 #if defined(FSL_FEATURE_I2C_HAS_START_STOP_DETECT) && FSL_FEATURE_I2C_HAS_START_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 107 kI2C_StartStopDetectInterruptEnable = I2C_FLT_SSIE_MASK, /*!< I2C start&stop detect interrupt. */
sahilmgandhi 18:6a4db94011d3 108 #endif /* FSL_FEATURE_I2C_HAS_START_STOP_DETECT */
sahilmgandhi 18:6a4db94011d3 109 };
sahilmgandhi 18:6a4db94011d3 110
sahilmgandhi 18:6a4db94011d3 111 /*! @brief The direction of master and slave transfers. */
sahilmgandhi 18:6a4db94011d3 112 typedef enum _i2c_direction
sahilmgandhi 18:6a4db94011d3 113 {
sahilmgandhi 18:6a4db94011d3 114 kI2C_Write = 0x0U, /*!< Master transmits to the slave. */
sahilmgandhi 18:6a4db94011d3 115 kI2C_Read = 0x1U, /*!< Master receives from the slave. */
sahilmgandhi 18:6a4db94011d3 116 } i2c_direction_t;
sahilmgandhi 18:6a4db94011d3 117
sahilmgandhi 18:6a4db94011d3 118 /*! @brief Addressing mode. */
sahilmgandhi 18:6a4db94011d3 119 typedef enum _i2c_slave_address_mode
sahilmgandhi 18:6a4db94011d3 120 {
sahilmgandhi 18:6a4db94011d3 121 kI2C_Address7bit = 0x0U, /*!< 7-bit addressing mode. */
sahilmgandhi 18:6a4db94011d3 122 kI2C_RangeMatch = 0X2U, /*!< Range address match addressing mode. */
sahilmgandhi 18:6a4db94011d3 123 } i2c_slave_address_mode_t;
sahilmgandhi 18:6a4db94011d3 124
sahilmgandhi 18:6a4db94011d3 125 /*! @brief I2C transfer control flag. */
sahilmgandhi 18:6a4db94011d3 126 enum _i2c_master_transfer_flags
sahilmgandhi 18:6a4db94011d3 127 {
sahilmgandhi 18:6a4db94011d3 128 kI2C_TransferDefaultFlag = 0x0U, /*!< A transfer starts with a start signal, stops with a stop signal. */
sahilmgandhi 18:6a4db94011d3 129 kI2C_TransferNoStartFlag = 0x1U, /*!< A transfer starts without a start signal. */
sahilmgandhi 18:6a4db94011d3 130 kI2C_TransferRepeatedStartFlag = 0x2U, /*!< A transfer starts with a repeated start signal. */
sahilmgandhi 18:6a4db94011d3 131 kI2C_TransferNoStopFlag = 0x4U, /*!< A transfer ends without a stop signal. */
sahilmgandhi 18:6a4db94011d3 132 };
sahilmgandhi 18:6a4db94011d3 133
sahilmgandhi 18:6a4db94011d3 134 /*!
sahilmgandhi 18:6a4db94011d3 135 * @brief Set of events sent to the callback for nonblocking slave transfers.
sahilmgandhi 18:6a4db94011d3 136 *
sahilmgandhi 18:6a4db94011d3 137 * These event enumerations are used for two related purposes. First, a bit mask created by OR'ing together
sahilmgandhi 18:6a4db94011d3 138 * events is passed to I2C_SlaveTransferNonBlocking() to specify which events to enable.
sahilmgandhi 18:6a4db94011d3 139 * Then, when the slave callback is invoked, it is passed the current event through its @a transfer
sahilmgandhi 18:6a4db94011d3 140 * parameter.
sahilmgandhi 18:6a4db94011d3 141 *
sahilmgandhi 18:6a4db94011d3 142 * @note These enumerations are meant to be OR'd together to form a bit mask of events.
sahilmgandhi 18:6a4db94011d3 143 */
sahilmgandhi 18:6a4db94011d3 144 typedef enum _i2c_slave_transfer_event
sahilmgandhi 18:6a4db94011d3 145 {
sahilmgandhi 18:6a4db94011d3 146 kI2C_SlaveAddressMatchEvent = 0x01U, /*!< Received the slave address after a start or repeated start. */
sahilmgandhi 18:6a4db94011d3 147 kI2C_SlaveTransmitEvent = 0x02U, /*!< A callback is requested to provide data to transmit
sahilmgandhi 18:6a4db94011d3 148 (slave-transmitter role). */
sahilmgandhi 18:6a4db94011d3 149 kI2C_SlaveReceiveEvent = 0x04U, /*!< A callback is requested to provide a buffer in which to place received
sahilmgandhi 18:6a4db94011d3 150 data (slave-receiver role). */
sahilmgandhi 18:6a4db94011d3 151 kI2C_SlaveTransmitAckEvent = 0x08U, /*!< A callback needs to either transmit an ACK or NACK. */
sahilmgandhi 18:6a4db94011d3 152 #if defined(FSL_FEATURE_I2C_HAS_START_STOP_DETECT) && FSL_FEATURE_I2C_HAS_START_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 153 kI2C_SlaveStartEvent = 0x10U, /*!< A start/repeated start was detected. */
sahilmgandhi 18:6a4db94011d3 154 #endif
sahilmgandhi 18:6a4db94011d3 155 kI2C_SlaveCompletionEvent = 0x20U, /*!< A stop was detected or finished transfer, completing the transfer. */
sahilmgandhi 18:6a4db94011d3 156 kI2C_SlaveGenaralcallEvent = 0x40U, /*!< Received the general call address after a start or repeated start. */
sahilmgandhi 18:6a4db94011d3 157
sahilmgandhi 18:6a4db94011d3 158 /*! A bit mask of all available events. */
sahilmgandhi 18:6a4db94011d3 159 kI2C_SlaveAllEvents = kI2C_SlaveAddressMatchEvent | kI2C_SlaveTransmitEvent | kI2C_SlaveReceiveEvent |
sahilmgandhi 18:6a4db94011d3 160 #if defined(FSL_FEATURE_I2C_HAS_START_STOP_DETECT) && FSL_FEATURE_I2C_HAS_START_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 161 kI2C_SlaveStartEvent |
sahilmgandhi 18:6a4db94011d3 162 #endif
sahilmgandhi 18:6a4db94011d3 163 kI2C_SlaveCompletionEvent | kI2C_SlaveGenaralcallEvent,
sahilmgandhi 18:6a4db94011d3 164 } i2c_slave_transfer_event_t;
sahilmgandhi 18:6a4db94011d3 165
sahilmgandhi 18:6a4db94011d3 166 /*! @brief I2C master user configuration. */
sahilmgandhi 18:6a4db94011d3 167 typedef struct _i2c_master_config
sahilmgandhi 18:6a4db94011d3 168 {
sahilmgandhi 18:6a4db94011d3 169 bool enableMaster; /*!< Enables the I2C peripheral at initialization time. */
sahilmgandhi 18:6a4db94011d3 170 #if defined(FSL_FEATURE_I2C_HAS_HIGH_DRIVE_SELECTION) && FSL_FEATURE_I2C_HAS_HIGH_DRIVE_SELECTION
sahilmgandhi 18:6a4db94011d3 171 bool enableHighDrive; /*!< Controls the drive capability of the I2C pads. */
sahilmgandhi 18:6a4db94011d3 172 #endif
sahilmgandhi 18:6a4db94011d3 173 #if defined(FSL_FEATURE_I2C_HAS_STOP_HOLD_OFF) && FSL_FEATURE_I2C_HAS_STOP_HOLD_OFF
sahilmgandhi 18:6a4db94011d3 174 bool enableStopHold; /*!< Controls the stop hold enable. */
sahilmgandhi 18:6a4db94011d3 175 #endif
sahilmgandhi 18:6a4db94011d3 176 #if defined(FSL_FEATURE_I2C_HAS_DOUBLE_BUFFER_ENABLE) && FSL_FEATURE_I2C_HAS_DOUBLE_BUFFER_ENABLE
sahilmgandhi 18:6a4db94011d3 177 bool enableDoubleBuffering; /*!< Controls double buffer enable; notice that
sahilmgandhi 18:6a4db94011d3 178 enabling the double buffer disables the clock stretch. */
sahilmgandhi 18:6a4db94011d3 179 #endif
sahilmgandhi 18:6a4db94011d3 180 uint32_t baudRate_Bps; /*!< Baud rate configuration of I2C peripheral. */
sahilmgandhi 18:6a4db94011d3 181 uint8_t glitchFilterWidth; /*!< Controls the width of the glitch. */
sahilmgandhi 18:6a4db94011d3 182 } i2c_master_config_t;
sahilmgandhi 18:6a4db94011d3 183
sahilmgandhi 18:6a4db94011d3 184 /*! @brief I2C slave user configuration. */
sahilmgandhi 18:6a4db94011d3 185 typedef struct _i2c_slave_config
sahilmgandhi 18:6a4db94011d3 186 {
sahilmgandhi 18:6a4db94011d3 187 bool enableSlave; /*!< Enables the I2C peripheral at initialization time. */
sahilmgandhi 18:6a4db94011d3 188 bool enableGeneralCall; /*!< Enables the general call addressing mode. */
sahilmgandhi 18:6a4db94011d3 189 bool enableWakeUp; /*!< Enables/disables waking up MCU from low-power mode. */
sahilmgandhi 18:6a4db94011d3 190 #if defined(FSL_FEATURE_I2C_HAS_HIGH_DRIVE_SELECTION) && FSL_FEATURE_I2C_HAS_HIGH_DRIVE_SELECTION
sahilmgandhi 18:6a4db94011d3 191 bool enableHighDrive; /*!< Controls the drive capability of the I2C pads. */
sahilmgandhi 18:6a4db94011d3 192 #endif
sahilmgandhi 18:6a4db94011d3 193 #if defined(FSL_FEATURE_I2C_HAS_DOUBLE_BUFFER_ENABLE) && FSL_FEATURE_I2C_HAS_DOUBLE_BUFFER_ENABLE
sahilmgandhi 18:6a4db94011d3 194 bool enableDoubleBuffering; /*!< Controls a double buffer enable; notice that
sahilmgandhi 18:6a4db94011d3 195 enabling the double buffer disables the clock stretch. */
sahilmgandhi 18:6a4db94011d3 196 #endif
sahilmgandhi 18:6a4db94011d3 197 bool enableBaudRateCtl; /*!< Enables/disables independent slave baud rate on SCL in very fast I2C modes. */
sahilmgandhi 18:6a4db94011d3 198 uint16_t slaveAddress; /*!< A slave address configuration. */
sahilmgandhi 18:6a4db94011d3 199 uint16_t upperAddress; /*!< A maximum boundary slave address used in a range matching mode. */
sahilmgandhi 18:6a4db94011d3 200 i2c_slave_address_mode_t
sahilmgandhi 18:6a4db94011d3 201 addressingMode; /*!< An addressing mode configuration of i2c_slave_address_mode_config_t. */
sahilmgandhi 18:6a4db94011d3 202 uint32_t sclStopHoldTime_ns; /*!< the delay from the rising edge of SCL (I2C clock) to the rising edge of SDA (I2C
sahilmgandhi 18:6a4db94011d3 203 data) while SCL is high (stop condition), SDA hold time and SCL start hold time
sahilmgandhi 18:6a4db94011d3 204 are also configured according to the SCL stop hold time. */
sahilmgandhi 18:6a4db94011d3 205 } i2c_slave_config_t;
sahilmgandhi 18:6a4db94011d3 206
sahilmgandhi 18:6a4db94011d3 207 /*! @brief I2C master handle typedef. */
sahilmgandhi 18:6a4db94011d3 208 typedef struct _i2c_master_handle i2c_master_handle_t;
sahilmgandhi 18:6a4db94011d3 209
sahilmgandhi 18:6a4db94011d3 210 /*! @brief I2C master transfer callback typedef. */
sahilmgandhi 18:6a4db94011d3 211 typedef void (*i2c_master_transfer_callback_t)(I2C_Type *base,
sahilmgandhi 18:6a4db94011d3 212 i2c_master_handle_t *handle,
sahilmgandhi 18:6a4db94011d3 213 status_t status,
sahilmgandhi 18:6a4db94011d3 214 void *userData);
sahilmgandhi 18:6a4db94011d3 215
sahilmgandhi 18:6a4db94011d3 216 /*! @brief I2C slave handle typedef. */
sahilmgandhi 18:6a4db94011d3 217 typedef struct _i2c_slave_handle i2c_slave_handle_t;
sahilmgandhi 18:6a4db94011d3 218
sahilmgandhi 18:6a4db94011d3 219 /*! @brief I2C master transfer structure. */
sahilmgandhi 18:6a4db94011d3 220 typedef struct _i2c_master_transfer
sahilmgandhi 18:6a4db94011d3 221 {
sahilmgandhi 18:6a4db94011d3 222 uint32_t flags; /*!< A transfer flag which controls the transfer. */
sahilmgandhi 18:6a4db94011d3 223 uint8_t slaveAddress; /*!< 7-bit slave address. */
sahilmgandhi 18:6a4db94011d3 224 i2c_direction_t direction; /*!< A transfer direction, read or write. */
sahilmgandhi 18:6a4db94011d3 225 uint32_t subaddress; /*!< A sub address. Transferred MSB first. */
sahilmgandhi 18:6a4db94011d3 226 uint8_t subaddressSize; /*!< A size of the command buffer. */
sahilmgandhi 18:6a4db94011d3 227 uint8_t *volatile data; /*!< A transfer buffer. */
sahilmgandhi 18:6a4db94011d3 228 volatile size_t dataSize; /*!< A transfer size. */
sahilmgandhi 18:6a4db94011d3 229 } i2c_master_transfer_t;
sahilmgandhi 18:6a4db94011d3 230
sahilmgandhi 18:6a4db94011d3 231 /*! @brief I2C master handle structure. */
sahilmgandhi 18:6a4db94011d3 232 struct _i2c_master_handle
sahilmgandhi 18:6a4db94011d3 233 {
sahilmgandhi 18:6a4db94011d3 234 i2c_master_transfer_t transfer; /*!< I2C master transfer copy. */
sahilmgandhi 18:6a4db94011d3 235 size_t transferSize; /*!< Total bytes to be transferred. */
sahilmgandhi 18:6a4db94011d3 236 uint8_t state; /*!< A transfer state maintained during transfer. */
sahilmgandhi 18:6a4db94011d3 237 i2c_master_transfer_callback_t completionCallback; /*!< A callback function called when the transfer is finished. */
sahilmgandhi 18:6a4db94011d3 238 void *userData; /*!< A callback parameter passed to the callback function. */
sahilmgandhi 18:6a4db94011d3 239 };
sahilmgandhi 18:6a4db94011d3 240
sahilmgandhi 18:6a4db94011d3 241 /*! @brief I2C slave transfer structure. */
sahilmgandhi 18:6a4db94011d3 242 typedef struct _i2c_slave_transfer
sahilmgandhi 18:6a4db94011d3 243 {
sahilmgandhi 18:6a4db94011d3 244 i2c_slave_transfer_event_t event; /*!< A reason that the callback is invoked. */
sahilmgandhi 18:6a4db94011d3 245 uint8_t *volatile data; /*!< A transfer buffer. */
sahilmgandhi 18:6a4db94011d3 246 volatile size_t dataSize; /*!< A transfer size. */
sahilmgandhi 18:6a4db94011d3 247 status_t completionStatus; /*!< Success or error code describing how the transfer completed. Only applies for
sahilmgandhi 18:6a4db94011d3 248 #kI2C_SlaveCompletionEvent. */
sahilmgandhi 18:6a4db94011d3 249 size_t transferredCount; /*!< A number of bytes actually transferred since the start or since the last repeated
sahilmgandhi 18:6a4db94011d3 250 start. */
sahilmgandhi 18:6a4db94011d3 251 } i2c_slave_transfer_t;
sahilmgandhi 18:6a4db94011d3 252
sahilmgandhi 18:6a4db94011d3 253 /*! @brief I2C slave transfer callback typedef. */
sahilmgandhi 18:6a4db94011d3 254 typedef void (*i2c_slave_transfer_callback_t)(I2C_Type *base, i2c_slave_transfer_t *xfer, void *userData);
sahilmgandhi 18:6a4db94011d3 255
sahilmgandhi 18:6a4db94011d3 256 /*! @brief I2C slave handle structure. */
sahilmgandhi 18:6a4db94011d3 257 struct _i2c_slave_handle
sahilmgandhi 18:6a4db94011d3 258 {
sahilmgandhi 18:6a4db94011d3 259 volatile bool isBusy; /*!< Indicates whether a transfer is busy. */
sahilmgandhi 18:6a4db94011d3 260 i2c_slave_transfer_t transfer; /*!< I2C slave transfer copy. */
sahilmgandhi 18:6a4db94011d3 261 uint32_t eventMask; /*!< A mask of enabled events. */
sahilmgandhi 18:6a4db94011d3 262 i2c_slave_transfer_callback_t callback; /*!< A callback function called at the transfer event. */
sahilmgandhi 18:6a4db94011d3 263 void *userData; /*!< A callback parameter passed to the callback. */
sahilmgandhi 18:6a4db94011d3 264 };
sahilmgandhi 18:6a4db94011d3 265
sahilmgandhi 18:6a4db94011d3 266 /*******************************************************************************
sahilmgandhi 18:6a4db94011d3 267 * API
sahilmgandhi 18:6a4db94011d3 268 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 269
sahilmgandhi 18:6a4db94011d3 270 #if defined(__cplusplus)
sahilmgandhi 18:6a4db94011d3 271 extern "C" {
sahilmgandhi 18:6a4db94011d3 272 #endif /*_cplusplus. */
sahilmgandhi 18:6a4db94011d3 273
sahilmgandhi 18:6a4db94011d3 274 /*!
sahilmgandhi 18:6a4db94011d3 275 * @name Initialization and deinitialization
sahilmgandhi 18:6a4db94011d3 276 * @{
sahilmgandhi 18:6a4db94011d3 277 */
sahilmgandhi 18:6a4db94011d3 278
sahilmgandhi 18:6a4db94011d3 279 /*!
sahilmgandhi 18:6a4db94011d3 280 * @brief Initializes the I2C peripheral. Call this API to ungate the I2C clock
sahilmgandhi 18:6a4db94011d3 281 * and configure the I2C with master configuration.
sahilmgandhi 18:6a4db94011d3 282 *
sahilmgandhi 18:6a4db94011d3 283 * @note This API should be called at the beginning of the application.
sahilmgandhi 18:6a4db94011d3 284 * Otherwise, any operation to the I2C module can cause a hard fault
sahilmgandhi 18:6a4db94011d3 285 * because the clock is not enabled. The configuration structure can be custom filled
sahilmgandhi 18:6a4db94011d3 286 * or it can be set with default values by using the I2C_MasterGetDefaultConfig().
sahilmgandhi 18:6a4db94011d3 287 * After calling this API, the master is ready to transfer.
sahilmgandhi 18:6a4db94011d3 288 * This is an example.
sahilmgandhi 18:6a4db94011d3 289 * @code
sahilmgandhi 18:6a4db94011d3 290 * i2c_master_config_t config = {
sahilmgandhi 18:6a4db94011d3 291 * .enableMaster = true,
sahilmgandhi 18:6a4db94011d3 292 * .enableStopHold = false,
sahilmgandhi 18:6a4db94011d3 293 * .highDrive = false,
sahilmgandhi 18:6a4db94011d3 294 * .baudRate_Bps = 100000,
sahilmgandhi 18:6a4db94011d3 295 * .glitchFilterWidth = 0
sahilmgandhi 18:6a4db94011d3 296 * };
sahilmgandhi 18:6a4db94011d3 297 * I2C_MasterInit(I2C0, &config, 12000000U);
sahilmgandhi 18:6a4db94011d3 298 * @endcode
sahilmgandhi 18:6a4db94011d3 299 *
sahilmgandhi 18:6a4db94011d3 300 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 301 * @param masterConfig A pointer to the master configuration structure
sahilmgandhi 18:6a4db94011d3 302 * @param srcClock_Hz I2C peripheral clock frequency in Hz
sahilmgandhi 18:6a4db94011d3 303 */
sahilmgandhi 18:6a4db94011d3 304 void I2C_MasterInit(I2C_Type *base, const i2c_master_config_t *masterConfig, uint32_t srcClock_Hz);
sahilmgandhi 18:6a4db94011d3 305
sahilmgandhi 18:6a4db94011d3 306 /*!
sahilmgandhi 18:6a4db94011d3 307 * @brief Initializes the I2C peripheral. Call this API to ungate the I2C clock
sahilmgandhi 18:6a4db94011d3 308 * and initialize the I2C with the slave configuration.
sahilmgandhi 18:6a4db94011d3 309 *
sahilmgandhi 18:6a4db94011d3 310 * @note This API should be called at the beginning of the application.
sahilmgandhi 18:6a4db94011d3 311 * Otherwise, any operation to the I2C module can cause a hard fault
sahilmgandhi 18:6a4db94011d3 312 * because the clock is not enabled. The configuration structure can partly be set
sahilmgandhi 18:6a4db94011d3 313 * with default values by I2C_SlaveGetDefaultConfig() or it can be custom filled by the user.
sahilmgandhi 18:6a4db94011d3 314 * This is an example.
sahilmgandhi 18:6a4db94011d3 315 * @code
sahilmgandhi 18:6a4db94011d3 316 * i2c_slave_config_t config = {
sahilmgandhi 18:6a4db94011d3 317 * .enableSlave = true,
sahilmgandhi 18:6a4db94011d3 318 * .enableGeneralCall = false,
sahilmgandhi 18:6a4db94011d3 319 * .addressingMode = kI2C_Address7bit,
sahilmgandhi 18:6a4db94011d3 320 * .slaveAddress = 0x1DU,
sahilmgandhi 18:6a4db94011d3 321 * .enableWakeUp = false,
sahilmgandhi 18:6a4db94011d3 322 * .enablehighDrive = false,
sahilmgandhi 18:6a4db94011d3 323 * .enableBaudRateCtl = false,
sahilmgandhi 18:6a4db94011d3 324 * .sclStopHoldTime_ns = 4000
sahilmgandhi 18:6a4db94011d3 325 * };
sahilmgandhi 18:6a4db94011d3 326 * I2C_SlaveInit(I2C0, &config, 12000000U);
sahilmgandhi 18:6a4db94011d3 327 * @endcode
sahilmgandhi 18:6a4db94011d3 328 *
sahilmgandhi 18:6a4db94011d3 329 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 330 * @param slaveConfig A pointer to the slave configuration structure
sahilmgandhi 18:6a4db94011d3 331 * @param srcClock_Hz I2C peripheral clock frequency in Hz
sahilmgandhi 18:6a4db94011d3 332 */
sahilmgandhi 18:6a4db94011d3 333 void I2C_SlaveInit(I2C_Type *base, const i2c_slave_config_t *slaveConfig, uint32_t srcClock_Hz);
sahilmgandhi 18:6a4db94011d3 334
sahilmgandhi 18:6a4db94011d3 335 /*!
sahilmgandhi 18:6a4db94011d3 336 * @brief De-initializes the I2C master peripheral. Call this API to gate the I2C clock.
sahilmgandhi 18:6a4db94011d3 337 * The I2C master module can't work unless the I2C_MasterInit is called.
sahilmgandhi 18:6a4db94011d3 338 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 339 */
sahilmgandhi 18:6a4db94011d3 340 void I2C_MasterDeinit(I2C_Type *base);
sahilmgandhi 18:6a4db94011d3 341
sahilmgandhi 18:6a4db94011d3 342 /*!
sahilmgandhi 18:6a4db94011d3 343 * @brief De-initializes the I2C slave peripheral. Calling this API gates the I2C clock.
sahilmgandhi 18:6a4db94011d3 344 * The I2C slave module can't work unless the I2C_SlaveInit is called to enable the clock.
sahilmgandhi 18:6a4db94011d3 345 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 346 */
sahilmgandhi 18:6a4db94011d3 347 void I2C_SlaveDeinit(I2C_Type *base);
sahilmgandhi 18:6a4db94011d3 348
sahilmgandhi 18:6a4db94011d3 349 /*!
sahilmgandhi 18:6a4db94011d3 350 * @brief Sets the I2C master configuration structure to default values.
sahilmgandhi 18:6a4db94011d3 351 *
sahilmgandhi 18:6a4db94011d3 352 * The purpose of this API is to get the configuration structure initialized for use in the I2C_MasterConfigure().
sahilmgandhi 18:6a4db94011d3 353 * Use the initialized structure unchanged in the I2C_MasterConfigure() or modify
sahilmgandhi 18:6a4db94011d3 354 * the structure before calling the I2C_MasterConfigure().
sahilmgandhi 18:6a4db94011d3 355 * This is an example.
sahilmgandhi 18:6a4db94011d3 356 * @code
sahilmgandhi 18:6a4db94011d3 357 * i2c_master_config_t config;
sahilmgandhi 18:6a4db94011d3 358 * I2C_MasterGetDefaultConfig(&config);
sahilmgandhi 18:6a4db94011d3 359 * @endcode
sahilmgandhi 18:6a4db94011d3 360 * @param masterConfig A pointer to the master configuration structure.
sahilmgandhi 18:6a4db94011d3 361 */
sahilmgandhi 18:6a4db94011d3 362 void I2C_MasterGetDefaultConfig(i2c_master_config_t *masterConfig);
sahilmgandhi 18:6a4db94011d3 363
sahilmgandhi 18:6a4db94011d3 364 /*!
sahilmgandhi 18:6a4db94011d3 365 * @brief Sets the I2C slave configuration structure to default values.
sahilmgandhi 18:6a4db94011d3 366 *
sahilmgandhi 18:6a4db94011d3 367 * The purpose of this API is to get the configuration structure initialized for use in the I2C_SlaveConfigure().
sahilmgandhi 18:6a4db94011d3 368 * Modify fields of the structure before calling the I2C_SlaveConfigure().
sahilmgandhi 18:6a4db94011d3 369 * This is an example.
sahilmgandhi 18:6a4db94011d3 370 * @code
sahilmgandhi 18:6a4db94011d3 371 * i2c_slave_config_t config;
sahilmgandhi 18:6a4db94011d3 372 * I2C_SlaveGetDefaultConfig(&config);
sahilmgandhi 18:6a4db94011d3 373 * @endcode
sahilmgandhi 18:6a4db94011d3 374 * @param slaveConfig A pointer to the slave configuration structure.
sahilmgandhi 18:6a4db94011d3 375 */
sahilmgandhi 18:6a4db94011d3 376 void I2C_SlaveGetDefaultConfig(i2c_slave_config_t *slaveConfig);
sahilmgandhi 18:6a4db94011d3 377
sahilmgandhi 18:6a4db94011d3 378 /*!
sahilmgandhi 18:6a4db94011d3 379 * @brief Enables or disabless the I2C peripheral operation.
sahilmgandhi 18:6a4db94011d3 380 *
sahilmgandhi 18:6a4db94011d3 381 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 382 * @param enable Pass true to enable and false to disable the module.
sahilmgandhi 18:6a4db94011d3 383 */
sahilmgandhi 18:6a4db94011d3 384 static inline void I2C_Enable(I2C_Type *base, bool enable)
sahilmgandhi 18:6a4db94011d3 385 {
sahilmgandhi 18:6a4db94011d3 386 if (enable)
sahilmgandhi 18:6a4db94011d3 387 {
sahilmgandhi 18:6a4db94011d3 388 base->C1 |= I2C_C1_IICEN_MASK;
sahilmgandhi 18:6a4db94011d3 389 }
sahilmgandhi 18:6a4db94011d3 390 else
sahilmgandhi 18:6a4db94011d3 391 {
sahilmgandhi 18:6a4db94011d3 392 base->C1 &= ~I2C_C1_IICEN_MASK;
sahilmgandhi 18:6a4db94011d3 393 }
sahilmgandhi 18:6a4db94011d3 394 }
sahilmgandhi 18:6a4db94011d3 395
sahilmgandhi 18:6a4db94011d3 396 /* @} */
sahilmgandhi 18:6a4db94011d3 397
sahilmgandhi 18:6a4db94011d3 398 /*!
sahilmgandhi 18:6a4db94011d3 399 * @name Status
sahilmgandhi 18:6a4db94011d3 400 * @{
sahilmgandhi 18:6a4db94011d3 401 */
sahilmgandhi 18:6a4db94011d3 402
sahilmgandhi 18:6a4db94011d3 403 /*!
sahilmgandhi 18:6a4db94011d3 404 * @brief Gets the I2C status flags.
sahilmgandhi 18:6a4db94011d3 405 *
sahilmgandhi 18:6a4db94011d3 406 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 407 * @return status flag, use status flag to AND #_i2c_flags to get the related status.
sahilmgandhi 18:6a4db94011d3 408 */
sahilmgandhi 18:6a4db94011d3 409 uint32_t I2C_MasterGetStatusFlags(I2C_Type *base);
sahilmgandhi 18:6a4db94011d3 410
sahilmgandhi 18:6a4db94011d3 411 /*!
sahilmgandhi 18:6a4db94011d3 412 * @brief Gets the I2C status flags.
sahilmgandhi 18:6a4db94011d3 413 *
sahilmgandhi 18:6a4db94011d3 414 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 415 * @return status flag, use status flag to AND #_i2c_flags to get the related status.
sahilmgandhi 18:6a4db94011d3 416 */
sahilmgandhi 18:6a4db94011d3 417 static inline uint32_t I2C_SlaveGetStatusFlags(I2C_Type *base)
sahilmgandhi 18:6a4db94011d3 418 {
sahilmgandhi 18:6a4db94011d3 419 return I2C_MasterGetStatusFlags(base);
sahilmgandhi 18:6a4db94011d3 420 }
sahilmgandhi 18:6a4db94011d3 421
sahilmgandhi 18:6a4db94011d3 422 /*!
sahilmgandhi 18:6a4db94011d3 423 * @brief Clears the I2C status flag state.
sahilmgandhi 18:6a4db94011d3 424 *
sahilmgandhi 18:6a4db94011d3 425 * The following status register flags can be cleared kI2C_ArbitrationLostFlag and kI2C_IntPendingFlag.
sahilmgandhi 18:6a4db94011d3 426 *
sahilmgandhi 18:6a4db94011d3 427 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 428 * @param statusMask The status flag mask, defined in type i2c_status_flag_t.
sahilmgandhi 18:6a4db94011d3 429 * The parameter can be any combination of the following values:
sahilmgandhi 18:6a4db94011d3 430 * @arg kI2C_StartDetectFlag (if available)
sahilmgandhi 18:6a4db94011d3 431 * @arg kI2C_StopDetectFlag (if available)
sahilmgandhi 18:6a4db94011d3 432 * @arg kI2C_ArbitrationLostFlag
sahilmgandhi 18:6a4db94011d3 433 * @arg kI2C_IntPendingFlagFlag
sahilmgandhi 18:6a4db94011d3 434 */
sahilmgandhi 18:6a4db94011d3 435 static inline void I2C_MasterClearStatusFlags(I2C_Type *base, uint32_t statusMask)
sahilmgandhi 18:6a4db94011d3 436 {
sahilmgandhi 18:6a4db94011d3 437 /* Must clear the STARTF / STOPF bits prior to clearing IICIF */
sahilmgandhi 18:6a4db94011d3 438 #if defined(FSL_FEATURE_I2C_HAS_START_STOP_DETECT) && FSL_FEATURE_I2C_HAS_START_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 439 if (statusMask & kI2C_StartDetectFlag)
sahilmgandhi 18:6a4db94011d3 440 {
sahilmgandhi 18:6a4db94011d3 441 /* Shift the odd-ball flags back into place. */
sahilmgandhi 18:6a4db94011d3 442 base->FLT |= (uint8_t)(statusMask >> 8U);
sahilmgandhi 18:6a4db94011d3 443 }
sahilmgandhi 18:6a4db94011d3 444 #endif
sahilmgandhi 18:6a4db94011d3 445
sahilmgandhi 18:6a4db94011d3 446 #ifdef I2C_HAS_STOP_DETECT
sahilmgandhi 18:6a4db94011d3 447 if (statusMask & kI2C_StopDetectFlag)
sahilmgandhi 18:6a4db94011d3 448 {
sahilmgandhi 18:6a4db94011d3 449 /* Shift the odd-ball flags back into place. */
sahilmgandhi 18:6a4db94011d3 450 base->FLT |= (uint8_t)(statusMask >> 8U);
sahilmgandhi 18:6a4db94011d3 451 }
sahilmgandhi 18:6a4db94011d3 452 #endif
sahilmgandhi 18:6a4db94011d3 453
sahilmgandhi 18:6a4db94011d3 454 base->S = (uint8_t)statusMask;
sahilmgandhi 18:6a4db94011d3 455 }
sahilmgandhi 18:6a4db94011d3 456
sahilmgandhi 18:6a4db94011d3 457 /*!
sahilmgandhi 18:6a4db94011d3 458 * @brief Clears the I2C status flag state.
sahilmgandhi 18:6a4db94011d3 459 *
sahilmgandhi 18:6a4db94011d3 460 * The following status register flags can be cleared kI2C_ArbitrationLostFlag and kI2C_IntPendingFlag
sahilmgandhi 18:6a4db94011d3 461 *
sahilmgandhi 18:6a4db94011d3 462 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 463 * @param statusMask The status flag mask, defined in type i2c_status_flag_t.
sahilmgandhi 18:6a4db94011d3 464 * The parameter can be any combination of the following values:
sahilmgandhi 18:6a4db94011d3 465 * @arg kI2C_StartDetectFlag (if available)
sahilmgandhi 18:6a4db94011d3 466 * @arg kI2C_StopDetectFlag (if available)
sahilmgandhi 18:6a4db94011d3 467 * @arg kI2C_ArbitrationLostFlag
sahilmgandhi 18:6a4db94011d3 468 * @arg kI2C_IntPendingFlagFlag
sahilmgandhi 18:6a4db94011d3 469 */
sahilmgandhi 18:6a4db94011d3 470 static inline void I2C_SlaveClearStatusFlags(I2C_Type *base, uint32_t statusMask)
sahilmgandhi 18:6a4db94011d3 471 {
sahilmgandhi 18:6a4db94011d3 472 I2C_MasterClearStatusFlags(base, statusMask);
sahilmgandhi 18:6a4db94011d3 473 }
sahilmgandhi 18:6a4db94011d3 474
sahilmgandhi 18:6a4db94011d3 475 /* @} */
sahilmgandhi 18:6a4db94011d3 476
sahilmgandhi 18:6a4db94011d3 477 /*!
sahilmgandhi 18:6a4db94011d3 478 * @name Interrupts
sahilmgandhi 18:6a4db94011d3 479 * @{
sahilmgandhi 18:6a4db94011d3 480 */
sahilmgandhi 18:6a4db94011d3 481
sahilmgandhi 18:6a4db94011d3 482 /*!
sahilmgandhi 18:6a4db94011d3 483 * @brief Enables I2C interrupt requests.
sahilmgandhi 18:6a4db94011d3 484 *
sahilmgandhi 18:6a4db94011d3 485 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 486 * @param mask interrupt source
sahilmgandhi 18:6a4db94011d3 487 * The parameter can be combination of the following source if defined:
sahilmgandhi 18:6a4db94011d3 488 * @arg kI2C_GlobalInterruptEnable
sahilmgandhi 18:6a4db94011d3 489 * @arg kI2C_StopDetectInterruptEnable/kI2C_StartDetectInterruptEnable
sahilmgandhi 18:6a4db94011d3 490 * @arg kI2C_SdaTimeoutInterruptEnable
sahilmgandhi 18:6a4db94011d3 491 */
sahilmgandhi 18:6a4db94011d3 492 void I2C_EnableInterrupts(I2C_Type *base, uint32_t mask);
sahilmgandhi 18:6a4db94011d3 493
sahilmgandhi 18:6a4db94011d3 494 /*!
sahilmgandhi 18:6a4db94011d3 495 * @brief Disables I2C interrupt requests.
sahilmgandhi 18:6a4db94011d3 496 *
sahilmgandhi 18:6a4db94011d3 497 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 498 * @param mask interrupt source
sahilmgandhi 18:6a4db94011d3 499 * The parameter can be combination of the following source if defined:
sahilmgandhi 18:6a4db94011d3 500 * @arg kI2C_GlobalInterruptEnable
sahilmgandhi 18:6a4db94011d3 501 * @arg kI2C_StopDetectInterruptEnable/kI2C_StartDetectInterruptEnable
sahilmgandhi 18:6a4db94011d3 502 * @arg kI2C_SdaTimeoutInterruptEnable
sahilmgandhi 18:6a4db94011d3 503 */
sahilmgandhi 18:6a4db94011d3 504 void I2C_DisableInterrupts(I2C_Type *base, uint32_t mask);
sahilmgandhi 18:6a4db94011d3 505
sahilmgandhi 18:6a4db94011d3 506 /*!
sahilmgandhi 18:6a4db94011d3 507 * @name DMA Control
sahilmgandhi 18:6a4db94011d3 508 * @{
sahilmgandhi 18:6a4db94011d3 509 */
sahilmgandhi 18:6a4db94011d3 510 #if defined(FSL_FEATURE_I2C_HAS_DMA_SUPPORT) && FSL_FEATURE_I2C_HAS_DMA_SUPPORT
sahilmgandhi 18:6a4db94011d3 511 /*!
sahilmgandhi 18:6a4db94011d3 512 * @brief Enables/disables the I2C DMA interrupt.
sahilmgandhi 18:6a4db94011d3 513 *
sahilmgandhi 18:6a4db94011d3 514 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 515 * @param enable true to enable, false to disable
sahilmgandhi 18:6a4db94011d3 516 */
sahilmgandhi 18:6a4db94011d3 517 static inline void I2C_EnableDMA(I2C_Type *base, bool enable)
sahilmgandhi 18:6a4db94011d3 518 {
sahilmgandhi 18:6a4db94011d3 519 if (enable)
sahilmgandhi 18:6a4db94011d3 520 {
sahilmgandhi 18:6a4db94011d3 521 base->C1 |= I2C_C1_DMAEN_MASK;
sahilmgandhi 18:6a4db94011d3 522 }
sahilmgandhi 18:6a4db94011d3 523 else
sahilmgandhi 18:6a4db94011d3 524 {
sahilmgandhi 18:6a4db94011d3 525 base->C1 &= ~I2C_C1_DMAEN_MASK;
sahilmgandhi 18:6a4db94011d3 526 }
sahilmgandhi 18:6a4db94011d3 527 }
sahilmgandhi 18:6a4db94011d3 528
sahilmgandhi 18:6a4db94011d3 529 #endif /* FSL_FEATURE_I2C_HAS_DMA_SUPPORT */
sahilmgandhi 18:6a4db94011d3 530
sahilmgandhi 18:6a4db94011d3 531 /*!
sahilmgandhi 18:6a4db94011d3 532 * @brief Gets the I2C tx/rx data register address. This API is used to provide a transfer address
sahilmgandhi 18:6a4db94011d3 533 * for I2C DMA transfer configuration.
sahilmgandhi 18:6a4db94011d3 534 *
sahilmgandhi 18:6a4db94011d3 535 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 536 * @return data register address
sahilmgandhi 18:6a4db94011d3 537 */
sahilmgandhi 18:6a4db94011d3 538 static inline uint32_t I2C_GetDataRegAddr(I2C_Type *base)
sahilmgandhi 18:6a4db94011d3 539 {
sahilmgandhi 18:6a4db94011d3 540 return (uint32_t)(&(base->D));
sahilmgandhi 18:6a4db94011d3 541 }
sahilmgandhi 18:6a4db94011d3 542
sahilmgandhi 18:6a4db94011d3 543 /* @} */
sahilmgandhi 18:6a4db94011d3 544 /*!
sahilmgandhi 18:6a4db94011d3 545 * @name Bus Operations
sahilmgandhi 18:6a4db94011d3 546 * @{
sahilmgandhi 18:6a4db94011d3 547 */
sahilmgandhi 18:6a4db94011d3 548
sahilmgandhi 18:6a4db94011d3 549 /*!
sahilmgandhi 18:6a4db94011d3 550 * @brief Sets the I2C master transfer baud rate.
sahilmgandhi 18:6a4db94011d3 551 *
sahilmgandhi 18:6a4db94011d3 552 * @param base I2C base pointer
sahilmgandhi 18:6a4db94011d3 553 * @param baudRate_Bps the baud rate value in bps
sahilmgandhi 18:6a4db94011d3 554 * @param srcClock_Hz Source clock
sahilmgandhi 18:6a4db94011d3 555 */
sahilmgandhi 18:6a4db94011d3 556 void I2C_MasterSetBaudRate(I2C_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz);
sahilmgandhi 18:6a4db94011d3 557
sahilmgandhi 18:6a4db94011d3 558 /*!
sahilmgandhi 18:6a4db94011d3 559 * @brief Sends a START on the I2C bus.
sahilmgandhi 18:6a4db94011d3 560 *
sahilmgandhi 18:6a4db94011d3 561 * This function is used to initiate a new master mode transfer by sending the START signal.
sahilmgandhi 18:6a4db94011d3 562 * The slave address is sent following the I2C START signal.
sahilmgandhi 18:6a4db94011d3 563 *
sahilmgandhi 18:6a4db94011d3 564 * @param base I2C peripheral base pointer
sahilmgandhi 18:6a4db94011d3 565 * @param address 7-bit slave device address.
sahilmgandhi 18:6a4db94011d3 566 * @param direction Master transfer directions(transmit/receive).
sahilmgandhi 18:6a4db94011d3 567 * @retval kStatus_Success Successfully send the start signal.
sahilmgandhi 18:6a4db94011d3 568 * @retval kStatus_I2C_Busy Current bus is busy.
sahilmgandhi 18:6a4db94011d3 569 */
sahilmgandhi 18:6a4db94011d3 570 status_t I2C_MasterStart(I2C_Type *base, uint8_t address, i2c_direction_t direction);
sahilmgandhi 18:6a4db94011d3 571
sahilmgandhi 18:6a4db94011d3 572 /*!
sahilmgandhi 18:6a4db94011d3 573 * @brief Sends a STOP signal on the I2C bus.
sahilmgandhi 18:6a4db94011d3 574 *
sahilmgandhi 18:6a4db94011d3 575 * @retval kStatus_Success Successfully send the stop signal.
sahilmgandhi 18:6a4db94011d3 576 * @retval kStatus_I2C_Timeout Send stop signal failed, timeout.
sahilmgandhi 18:6a4db94011d3 577 */
sahilmgandhi 18:6a4db94011d3 578 status_t I2C_MasterStop(I2C_Type *base);
sahilmgandhi 18:6a4db94011d3 579
sahilmgandhi 18:6a4db94011d3 580 /*!
sahilmgandhi 18:6a4db94011d3 581 * @brief Sends a REPEATED START on the I2C bus.
sahilmgandhi 18:6a4db94011d3 582 *
sahilmgandhi 18:6a4db94011d3 583 * @param base I2C peripheral base pointer
sahilmgandhi 18:6a4db94011d3 584 * @param address 7-bit slave device address.
sahilmgandhi 18:6a4db94011d3 585 * @param direction Master transfer directions(transmit/receive).
sahilmgandhi 18:6a4db94011d3 586 * @retval kStatus_Success Successfully send the start signal.
sahilmgandhi 18:6a4db94011d3 587 * @retval kStatus_I2C_Busy Current bus is busy but not occupied by current I2C master.
sahilmgandhi 18:6a4db94011d3 588 */
sahilmgandhi 18:6a4db94011d3 589 status_t I2C_MasterRepeatedStart(I2C_Type *base, uint8_t address, i2c_direction_t direction);
sahilmgandhi 18:6a4db94011d3 590
sahilmgandhi 18:6a4db94011d3 591 /*!
sahilmgandhi 18:6a4db94011d3 592 * @brief Performs a polling send transaction on the I2C bus.
sahilmgandhi 18:6a4db94011d3 593 *
sahilmgandhi 18:6a4db94011d3 594 * @param base The I2C peripheral base pointer.
sahilmgandhi 18:6a4db94011d3 595 * @param txBuff The pointer to the data to be transferred.
sahilmgandhi 18:6a4db94011d3 596 * @param txSize The length in bytes of the data to be transferred.
sahilmgandhi 18:6a4db94011d3 597 * @param flags Transfer control flag to decide whether need to send a stop, use kI2C_TransferDefaultFlag
sahilmgandhi 18:6a4db94011d3 598 * to issue a stop and kI2C_TransferNoStop to not send a stop.
sahilmgandhi 18:6a4db94011d3 599 * @retval kStatus_Success Successfully complete the data transmission.
sahilmgandhi 18:6a4db94011d3 600 * @retval kStatus_I2C_ArbitrationLost Transfer error, arbitration lost.
sahilmgandhi 18:6a4db94011d3 601 * @retval kStataus_I2C_Nak Transfer error, receive NAK during transfer.
sahilmgandhi 18:6a4db94011d3 602 */
sahilmgandhi 18:6a4db94011d3 603 status_t I2C_MasterWriteBlocking(I2C_Type *base, const uint8_t *txBuff, size_t txSize, uint32_t flags);
sahilmgandhi 18:6a4db94011d3 604
sahilmgandhi 18:6a4db94011d3 605 /*!
sahilmgandhi 18:6a4db94011d3 606 * @brief Performs a polling receive transaction on the I2C bus.
sahilmgandhi 18:6a4db94011d3 607 *
sahilmgandhi 18:6a4db94011d3 608 * @note The I2C_MasterReadBlocking function stops the bus before reading the final byte.
sahilmgandhi 18:6a4db94011d3 609 * Without stopping the bus prior for the final read, the bus issues another read, resulting
sahilmgandhi 18:6a4db94011d3 610 * in garbage data being read into the data register.
sahilmgandhi 18:6a4db94011d3 611 *
sahilmgandhi 18:6a4db94011d3 612 * @param base I2C peripheral base pointer.
sahilmgandhi 18:6a4db94011d3 613 * @param rxBuff The pointer to the data to store the received data.
sahilmgandhi 18:6a4db94011d3 614 * @param rxSize The length in bytes of the data to be received.
sahilmgandhi 18:6a4db94011d3 615 * @param flags Transfer control flag to decide whether need to send a stop, use kI2C_TransferDefaultFlag
sahilmgandhi 18:6a4db94011d3 616 * to issue a stop and kI2C_TransferNoStop to not send a stop.
sahilmgandhi 18:6a4db94011d3 617 * @retval kStatus_Success Successfully complete the data transmission.
sahilmgandhi 18:6a4db94011d3 618 * @retval kStatus_I2C_Timeout Send stop signal failed, timeout.
sahilmgandhi 18:6a4db94011d3 619 */
sahilmgandhi 18:6a4db94011d3 620 status_t I2C_MasterReadBlocking(I2C_Type *base, uint8_t *rxBuff, size_t rxSize, uint32_t flags);
sahilmgandhi 18:6a4db94011d3 621
sahilmgandhi 18:6a4db94011d3 622 /*!
sahilmgandhi 18:6a4db94011d3 623 * @brief Performs a polling send transaction on the I2C bus.
sahilmgandhi 18:6a4db94011d3 624 *
sahilmgandhi 18:6a4db94011d3 625 * @param base The I2C peripheral base pointer.
sahilmgandhi 18:6a4db94011d3 626 * @param txBuff The pointer to the data to be transferred.
sahilmgandhi 18:6a4db94011d3 627 * @param txSize The length in bytes of the data to be transferred.
sahilmgandhi 18:6a4db94011d3 628 * @retval kStatus_Success Successfully complete the data transmission.
sahilmgandhi 18:6a4db94011d3 629 * @retval kStatus_I2C_ArbitrationLost Transfer error, arbitration lost.
sahilmgandhi 18:6a4db94011d3 630 * @retval kStataus_I2C_Nak Transfer error, receive NAK during transfer.
sahilmgandhi 18:6a4db94011d3 631 */
sahilmgandhi 18:6a4db94011d3 632 status_t I2C_SlaveWriteBlocking(I2C_Type *base, const uint8_t *txBuff, size_t txSize);
sahilmgandhi 18:6a4db94011d3 633
sahilmgandhi 18:6a4db94011d3 634 /*!
sahilmgandhi 18:6a4db94011d3 635 * @brief Performs a polling receive transaction on the I2C bus.
sahilmgandhi 18:6a4db94011d3 636 *
sahilmgandhi 18:6a4db94011d3 637 * @param base I2C peripheral base pointer.
sahilmgandhi 18:6a4db94011d3 638 * @param rxBuff The pointer to the data to store the received data.
sahilmgandhi 18:6a4db94011d3 639 * @param rxSize The length in bytes of the data to be received.
sahilmgandhi 18:6a4db94011d3 640 */
sahilmgandhi 18:6a4db94011d3 641 void I2C_SlaveReadBlocking(I2C_Type *base, uint8_t *rxBuff, size_t rxSize);
sahilmgandhi 18:6a4db94011d3 642
sahilmgandhi 18:6a4db94011d3 643 /*!
sahilmgandhi 18:6a4db94011d3 644 * @brief Performs a master polling transfer on the I2C bus.
sahilmgandhi 18:6a4db94011d3 645 *
sahilmgandhi 18:6a4db94011d3 646 * @note The API does not return until the transfer succeeds or fails due
sahilmgandhi 18:6a4db94011d3 647 * to arbitration lost or receiving a NAK.
sahilmgandhi 18:6a4db94011d3 648 *
sahilmgandhi 18:6a4db94011d3 649 * @param base I2C peripheral base address.
sahilmgandhi 18:6a4db94011d3 650 * @param xfer Pointer to the transfer structure.
sahilmgandhi 18:6a4db94011d3 651 * @retval kStatus_Success Successfully complete the data transmission.
sahilmgandhi 18:6a4db94011d3 652 * @retval kStatus_I2C_Busy Previous transmission still not finished.
sahilmgandhi 18:6a4db94011d3 653 * @retval kStatus_I2C_Timeout Transfer error, wait signal timeout.
sahilmgandhi 18:6a4db94011d3 654 * @retval kStatus_I2C_ArbitrationLost Transfer error, arbitration lost.
sahilmgandhi 18:6a4db94011d3 655 * @retval kStataus_I2C_Nak Transfer error, receive NAK during transfer.
sahilmgandhi 18:6a4db94011d3 656 */
sahilmgandhi 18:6a4db94011d3 657 status_t I2C_MasterTransferBlocking(I2C_Type *base, i2c_master_transfer_t *xfer);
sahilmgandhi 18:6a4db94011d3 658
sahilmgandhi 18:6a4db94011d3 659 /* @} */
sahilmgandhi 18:6a4db94011d3 660
sahilmgandhi 18:6a4db94011d3 661 /*!
sahilmgandhi 18:6a4db94011d3 662 * @name Transactional
sahilmgandhi 18:6a4db94011d3 663 * @{
sahilmgandhi 18:6a4db94011d3 664 */
sahilmgandhi 18:6a4db94011d3 665
sahilmgandhi 18:6a4db94011d3 666 /*!
sahilmgandhi 18:6a4db94011d3 667 * @brief Initializes the I2C handle which is used in transactional functions.
sahilmgandhi 18:6a4db94011d3 668 *
sahilmgandhi 18:6a4db94011d3 669 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 670 * @param handle pointer to i2c_master_handle_t structure to store the transfer state.
sahilmgandhi 18:6a4db94011d3 671 * @param callback pointer to user callback function.
sahilmgandhi 18:6a4db94011d3 672 * @param userData user parameter passed to the callback function.
sahilmgandhi 18:6a4db94011d3 673 */
sahilmgandhi 18:6a4db94011d3 674 void I2C_MasterTransferCreateHandle(I2C_Type *base,
sahilmgandhi 18:6a4db94011d3 675 i2c_master_handle_t *handle,
sahilmgandhi 18:6a4db94011d3 676 i2c_master_transfer_callback_t callback,
sahilmgandhi 18:6a4db94011d3 677 void *userData);
sahilmgandhi 18:6a4db94011d3 678
sahilmgandhi 18:6a4db94011d3 679 /*!
sahilmgandhi 18:6a4db94011d3 680 * @brief Performs a master interrupt non-blocking transfer on the I2C bus.
sahilmgandhi 18:6a4db94011d3 681 *
sahilmgandhi 18:6a4db94011d3 682 * @note Calling the API returns immediately after transfer initiates. The user needs
sahilmgandhi 18:6a4db94011d3 683 * to call I2C_MasterGetTransferCount to poll the transfer status to check whether
sahilmgandhi 18:6a4db94011d3 684 * the transfer is finished. If the return status is not kStatus_I2C_Busy, the transfer
sahilmgandhi 18:6a4db94011d3 685 * is finished.
sahilmgandhi 18:6a4db94011d3 686 *
sahilmgandhi 18:6a4db94011d3 687 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 688 * @param handle pointer to i2c_master_handle_t structure which stores the transfer state.
sahilmgandhi 18:6a4db94011d3 689 * @param xfer pointer to i2c_master_transfer_t structure.
sahilmgandhi 18:6a4db94011d3 690 * @retval kStatus_Success Successfully start the data transmission.
sahilmgandhi 18:6a4db94011d3 691 * @retval kStatus_I2C_Busy Previous transmission still not finished.
sahilmgandhi 18:6a4db94011d3 692 * @retval kStatus_I2C_Timeout Transfer error, wait signal timeout.
sahilmgandhi 18:6a4db94011d3 693 */
sahilmgandhi 18:6a4db94011d3 694 status_t I2C_MasterTransferNonBlocking(I2C_Type *base, i2c_master_handle_t *handle, i2c_master_transfer_t *xfer);
sahilmgandhi 18:6a4db94011d3 695
sahilmgandhi 18:6a4db94011d3 696 /*!
sahilmgandhi 18:6a4db94011d3 697 * @brief Gets the master transfer status during a interrupt non-blocking transfer.
sahilmgandhi 18:6a4db94011d3 698 *
sahilmgandhi 18:6a4db94011d3 699 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 700 * @param handle pointer to i2c_master_handle_t structure which stores the transfer state.
sahilmgandhi 18:6a4db94011d3 701 * @param count Number of bytes transferred so far by the non-blocking transaction.
sahilmgandhi 18:6a4db94011d3 702 * @retval kStatus_InvalidArgument count is Invalid.
sahilmgandhi 18:6a4db94011d3 703 * @retval kStatus_Success Successfully return the count.
sahilmgandhi 18:6a4db94011d3 704 */
sahilmgandhi 18:6a4db94011d3 705 status_t I2C_MasterTransferGetCount(I2C_Type *base, i2c_master_handle_t *handle, size_t *count);
sahilmgandhi 18:6a4db94011d3 706
sahilmgandhi 18:6a4db94011d3 707 /*!
sahilmgandhi 18:6a4db94011d3 708 * @brief Aborts an interrupt non-blocking transfer early.
sahilmgandhi 18:6a4db94011d3 709 *
sahilmgandhi 18:6a4db94011d3 710 * @note This API can be called at any time when an interrupt non-blocking transfer initiates
sahilmgandhi 18:6a4db94011d3 711 * to abort the transfer early.
sahilmgandhi 18:6a4db94011d3 712 *
sahilmgandhi 18:6a4db94011d3 713 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 714 * @param handle pointer to i2c_master_handle_t structure which stores the transfer state
sahilmgandhi 18:6a4db94011d3 715 */
sahilmgandhi 18:6a4db94011d3 716 void I2C_MasterTransferAbort(I2C_Type *base, i2c_master_handle_t *handle);
sahilmgandhi 18:6a4db94011d3 717
sahilmgandhi 18:6a4db94011d3 718 /*!
sahilmgandhi 18:6a4db94011d3 719 * @brief Master interrupt handler.
sahilmgandhi 18:6a4db94011d3 720 *
sahilmgandhi 18:6a4db94011d3 721 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 722 * @param i2cHandle pointer to i2c_master_handle_t structure.
sahilmgandhi 18:6a4db94011d3 723 */
sahilmgandhi 18:6a4db94011d3 724 void I2C_MasterTransferHandleIRQ(I2C_Type *base, void *i2cHandle);
sahilmgandhi 18:6a4db94011d3 725
sahilmgandhi 18:6a4db94011d3 726 /*!
sahilmgandhi 18:6a4db94011d3 727 * @brief Initializes the I2C handle which is used in transactional functions.
sahilmgandhi 18:6a4db94011d3 728 *
sahilmgandhi 18:6a4db94011d3 729 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 730 * @param handle pointer to i2c_slave_handle_t structure to store the transfer state.
sahilmgandhi 18:6a4db94011d3 731 * @param callback pointer to user callback function.
sahilmgandhi 18:6a4db94011d3 732 * @param userData user parameter passed to the callback function.
sahilmgandhi 18:6a4db94011d3 733 */
sahilmgandhi 18:6a4db94011d3 734 void I2C_SlaveTransferCreateHandle(I2C_Type *base,
sahilmgandhi 18:6a4db94011d3 735 i2c_slave_handle_t *handle,
sahilmgandhi 18:6a4db94011d3 736 i2c_slave_transfer_callback_t callback,
sahilmgandhi 18:6a4db94011d3 737 void *userData);
sahilmgandhi 18:6a4db94011d3 738
sahilmgandhi 18:6a4db94011d3 739 /*!
sahilmgandhi 18:6a4db94011d3 740 * @brief Starts accepting slave transfers.
sahilmgandhi 18:6a4db94011d3 741 *
sahilmgandhi 18:6a4db94011d3 742 * Call this API after calling the I2C_SlaveInit() and I2C_SlaveTransferCreateHandle() to start processing
sahilmgandhi 18:6a4db94011d3 743 * transactions driven by an I2C master. The slave monitors the I2C bus and passes events to the
sahilmgandhi 18:6a4db94011d3 744 * callback that was passed into the call to I2C_SlaveTransferCreateHandle(). The callback is always invoked
sahilmgandhi 18:6a4db94011d3 745 * from the interrupt context.
sahilmgandhi 18:6a4db94011d3 746 *
sahilmgandhi 18:6a4db94011d3 747 * The set of events received by the callback is customizable. To do so, set the @a eventMask parameter to
sahilmgandhi 18:6a4db94011d3 748 * the OR'd combination of #i2c_slave_transfer_event_t enumerators for the events you wish to receive.
sahilmgandhi 18:6a4db94011d3 749 * The #kI2C_SlaveTransmitEvent and #kLPI2C_SlaveReceiveEvent events are always enabled and do not need
sahilmgandhi 18:6a4db94011d3 750 * to be included in the mask. Alternatively, pass 0 to get a default set of only the transmit and
sahilmgandhi 18:6a4db94011d3 751 * receive events that are always enabled. In addition, the #kI2C_SlaveAllEvents constant is provided as
sahilmgandhi 18:6a4db94011d3 752 * a convenient way to enable all events.
sahilmgandhi 18:6a4db94011d3 753 *
sahilmgandhi 18:6a4db94011d3 754 * @param base The I2C peripheral base address.
sahilmgandhi 18:6a4db94011d3 755 * @param handle Pointer to #i2c_slave_handle_t structure which stores the transfer state.
sahilmgandhi 18:6a4db94011d3 756 * @param eventMask Bit mask formed by OR'ing together #i2c_slave_transfer_event_t enumerators to specify
sahilmgandhi 18:6a4db94011d3 757 * which events to send to the callback. Other accepted values are 0 to get a default set of
sahilmgandhi 18:6a4db94011d3 758 * only the transmit and receive events, and #kI2C_SlaveAllEvents to enable all events.
sahilmgandhi 18:6a4db94011d3 759 *
sahilmgandhi 18:6a4db94011d3 760 * @retval #kStatus_Success Slave transfers were successfully started.
sahilmgandhi 18:6a4db94011d3 761 * @retval #kStatus_I2C_Busy Slave transfers have already been started on this handle.
sahilmgandhi 18:6a4db94011d3 762 */
sahilmgandhi 18:6a4db94011d3 763 status_t I2C_SlaveTransferNonBlocking(I2C_Type *base, i2c_slave_handle_t *handle, uint32_t eventMask);
sahilmgandhi 18:6a4db94011d3 764
sahilmgandhi 18:6a4db94011d3 765 /*!
sahilmgandhi 18:6a4db94011d3 766 * @brief Aborts the slave transfer.
sahilmgandhi 18:6a4db94011d3 767 *
sahilmgandhi 18:6a4db94011d3 768 * @note This API can be called at any time to stop slave for handling the bus events.
sahilmgandhi 18:6a4db94011d3 769 *
sahilmgandhi 18:6a4db94011d3 770 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 771 * @param handle pointer to i2c_slave_handle_t structure which stores the transfer state.
sahilmgandhi 18:6a4db94011d3 772 */
sahilmgandhi 18:6a4db94011d3 773 void I2C_SlaveTransferAbort(I2C_Type *base, i2c_slave_handle_t *handle);
sahilmgandhi 18:6a4db94011d3 774
sahilmgandhi 18:6a4db94011d3 775 /*!
sahilmgandhi 18:6a4db94011d3 776 * @brief Gets the slave transfer remaining bytes during a interrupt non-blocking transfer.
sahilmgandhi 18:6a4db94011d3 777 *
sahilmgandhi 18:6a4db94011d3 778 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 779 * @param handle pointer to i2c_slave_handle_t structure.
sahilmgandhi 18:6a4db94011d3 780 * @param count Number of bytes transferred so far by the non-blocking transaction.
sahilmgandhi 18:6a4db94011d3 781 * @retval kStatus_InvalidArgument count is Invalid.
sahilmgandhi 18:6a4db94011d3 782 * @retval kStatus_Success Successfully return the count.
sahilmgandhi 18:6a4db94011d3 783 */
sahilmgandhi 18:6a4db94011d3 784 status_t I2C_SlaveTransferGetCount(I2C_Type *base, i2c_slave_handle_t *handle, size_t *count);
sahilmgandhi 18:6a4db94011d3 785
sahilmgandhi 18:6a4db94011d3 786 /*!
sahilmgandhi 18:6a4db94011d3 787 * @brief Slave interrupt handler.
sahilmgandhi 18:6a4db94011d3 788 *
sahilmgandhi 18:6a4db94011d3 789 * @param base I2C base pointer.
sahilmgandhi 18:6a4db94011d3 790 * @param i2cHandle pointer to i2c_slave_handle_t structure which stores the transfer state
sahilmgandhi 18:6a4db94011d3 791 */
sahilmgandhi 18:6a4db94011d3 792 void I2C_SlaveTransferHandleIRQ(I2C_Type *base, void *i2cHandle);
sahilmgandhi 18:6a4db94011d3 793
sahilmgandhi 18:6a4db94011d3 794 /* @} */
sahilmgandhi 18:6a4db94011d3 795 #if defined(__cplusplus)
sahilmgandhi 18:6a4db94011d3 796 }
sahilmgandhi 18:6a4db94011d3 797 #endif /*_cplusplus. */
sahilmgandhi 18:6a4db94011d3 798 /*@}*/
sahilmgandhi 18:6a4db94011d3 799
sahilmgandhi 18:6a4db94011d3 800 #endif /* _FSL_I2C_H_*/