fsl_lpi2c.h
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FSL_LPI2C_H_
#define _FSL_LPI2C_H_
#include <stddef.h>
#include "fsl_device_registers.h"
#include "fsl_common.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define FSL_LPI2C_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
enum _lpi2c_status
{
kStatus_LPI2C_Busy = MAKE_STATUS(kStatusGroup_LPI2C, 0),
kStatus_LPI2C_Idle = MAKE_STATUS(kStatusGroup_LPI2C, 1),
kStatus_LPI2C_Nak = MAKE_STATUS(kStatusGroup_LPI2C, 2),
kStatus_LPI2C_FifoError = MAKE_STATUS(kStatusGroup_LPI2C, 3),
kStatus_LPI2C_BitError = MAKE_STATUS(kStatusGroup_LPI2C, 4),
kStatus_LPI2C_ArbitrationLost = MAKE_STATUS(kStatusGroup_LPI2C, 5),
kStatus_LPI2C_PinLowTimeout =
MAKE_STATUS(kStatusGroup_LPI2C, 6),
kStatus_LPI2C_NoTransferInProgress =
MAKE_STATUS(kStatusGroup_LPI2C, 7),
kStatus_LPI2C_DmaRequestFail = MAKE_STATUS(kStatusGroup_LPI2C, 7),
};
enum _lpi2c_master_flags
{
kLPI2C_MasterTxReadyFlag = LPI2C_MSR_TDF_MASK,
kLPI2C_MasterRxReadyFlag = LPI2C_MSR_RDF_MASK,
kLPI2C_MasterEndOfPacketFlag = LPI2C_MSR_EPF_MASK,
kLPI2C_MasterStopDetectFlag = LPI2C_MSR_SDF_MASK,
kLPI2C_MasterNackDetectFlag = LPI2C_MSR_NDF_MASK,
kLPI2C_MasterArbitrationLostFlag = LPI2C_MSR_ALF_MASK,
kLPI2C_MasterFifoErrFlag = LPI2C_MSR_FEF_MASK,
kLPI2C_MasterPinLowTimeoutFlag = LPI2C_MSR_PLTF_MASK,
kLPI2C_MasterDataMatchFlag = LPI2C_MSR_DMF_MASK,
kLPI2C_MasterBusyFlag = LPI2C_MSR_MBF_MASK,
kLPI2C_MasterBusBusyFlag = LPI2C_MSR_BBF_MASK
};
typedef enum _lpi2c_direction {
kLPI2C_Write = 0U,
kLPI2C_Read = 1U
} lpi2c_direction_t;
typedef enum _lpi2c_master_pin_config {
kLPI2C_2PinOpenDrain = 0x0U,
kLPI2C_2PinOutputOnly = 0x1U,
kLPI2C_2PinPushPull = 0x2U,
kLPI2C_4PinPushPull = 0x3U,
kLPI2C_2PinOpenDrainWithSeparateSlave =
0x4U,
kLPI2C_2PinOutputOnlyWithSeparateSlave =
0x5U,
kLPI2C_2PinPushPullWithSeparateSlave =
0x6U,
kLPI2C_4PinPushPullWithInvertedOutput = 0x7U
} lpi2c_master_pin_config_t;
typedef enum _lpi2c_host_request_source {
kLPI2C_HostRequestExternalPin = 0x0U,
kLPI2C_HostRequestInputTrigger = 0x1U,
} lpi2c_host_request_source_t;
typedef enum _lpi2c_host_request_polarity {
kLPI2C_HostRequestPinActiveLow = 0x0U,
kLPI2C_HostRequestPinActiveHigh = 0x1U
} lpi2c_host_request_polarity_t;
typedef struct _lpi2c_master_config
{
bool enableMaster;
bool enableDoze;
bool debugEnable;
bool ignoreAck;
lpi2c_master_pin_config_t pinConfig;
uint32_t baudRate_Hz;
uint32_t busIdleTimeout_ns;
uint32_t pinLowTimeout_ns;
uint8_t sdaGlitchFilterWidth_ns;
uint8_t sclGlitchFilterWidth_ns;
struct
{
bool enable;
lpi2c_host_request_source_t source;
lpi2c_host_request_polarity_t polarity;
} hostRequest;
} lpi2c_master_config_t;
typedef enum _lpi2c_data_match_config_mode {
kLPI2C_MatchDisabled = 0x0U,
kLPI2C_1stWordEqualsM0OrM1 = 0x2U,
kLPI2C_AnyWordEqualsM0OrM1 = 0x3U,
kLPI2C_1stWordEqualsM0And2ndWordEqualsM1 =
0x4U,
kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1 =
0x5U,
kLPI2C_1stWordAndM1EqualsM0AndM1 =
0x6U,
kLPI2C_AnyWordAndM1EqualsM0AndM1 =
0x7U
} lpi2c_data_match_config_mode_t;
typedef struct _lpi2c_match_config
{
lpi2c_data_match_config_mode_t matchMode;
bool rxDataMatchOnly;
uint32_t match0;
uint32_t match1;
} lpi2c_data_match_config_t;
/* Forward declaration of the transfer descriptor and handle typedefs. */
typedef struct _lpi2c_master_transfer lpi2c_master_transfer_t;
typedef struct _lpi2c_master_handle lpi2c_master_handle_t;
typedef void (*lpi2c_master_transfer_callback_t)(LPI2C_Type *base,
lpi2c_master_handle_t *handle,
status_t completionStatus,
void *userData);
enum _lpi2c_master_transfer_flags
{
kLPI2C_TransferDefaultFlag = 0x00U,
kLPI2C_TransferNoStartFlag = 0x01U,
kLPI2C_TransferRepeatedStartFlag = 0x02U,
kLPI2C_TransferNoStopFlag = 0x04U,
};
struct _lpi2c_master_transfer
{
uint32_t flags;
uint16_t slaveAddress;
lpi2c_direction_t direction;
uint32_t subaddress;
size_t subaddressSize;
void *data;
size_t dataSize;
};
struct _lpi2c_master_handle
{
uint8_t state;
uint16_t remainingBytes;
uint8_t *buf;
uint16_t commandBuffer[7];
lpi2c_master_transfer_t transfer;
lpi2c_master_transfer_callback_t completionCallback;
void *userData;
};
enum _lpi2c_slave_flags
{
kLPI2C_SlaveTxReadyFlag = LPI2C_SSR_TDF_MASK,
kLPI2C_SlaveRxReadyFlag = LPI2C_SSR_RDF_MASK,
kLPI2C_SlaveAddressValidFlag = LPI2C_SSR_AVF_MASK,
kLPI2C_SlaveTransmitAckFlag = LPI2C_SSR_TAF_MASK,
kLPI2C_SlaveRepeatedStartDetectFlag = LPI2C_SSR_RSF_MASK,
kLPI2C_SlaveStopDetectFlag = LPI2C_SSR_SDF_MASK,
kLPI2C_SlaveBitErrFlag = LPI2C_SSR_BEF_MASK,
kLPI2C_SlaveFifoErrFlag = LPI2C_SSR_FEF_MASK,
kLPI2C_SlaveAddressMatch0Flag = LPI2C_SSR_AM0F_MASK,
kLPI2C_SlaveAddressMatch1Flag = LPI2C_SSR_AM1F_MASK,
kLPI2C_SlaveGeneralCallFlag = LPI2C_SSR_GCF_MASK,
kLPI2C_SlaveBusyFlag = LPI2C_SSR_SBF_MASK,
kLPI2C_SlaveBusBusyFlag = LPI2C_SSR_BBF_MASK,
};
typedef enum _lpi2c_slave_address_match {
kLPI2C_MatchAddress0 = 0U,
kLPI2C_MatchAddress0OrAddress1 = 2U,
kLPI2C_MatchAddress0ThroughAddress1 = 6U,
} lpi2c_slave_address_match_t;
typedef struct _lpi2c_slave_config
{
bool enableSlave;
uint8_t address0;
uint8_t address1;
lpi2c_slave_address_match_t addressMatchMode;
bool filterDozeEnable;
bool filterEnable;
bool enableGeneralCall;
struct
{
bool enableAck;
bool enableTx;
bool enableRx;
bool enableAddress;
} sclStall;
bool ignoreAck;
bool enableReceivedAddressRead;
uint32_t sdaGlitchFilterWidth_ns;
uint32_t sclGlitchFilterWidth_ns;
uint32_t dataValidDelay_ns;
uint32_t clockHoldTime_ns;
} lpi2c_slave_config_t;
typedef enum _lpi2c_slave_transfer_event {
kLPI2C_SlaveAddressMatchEvent = 0x01U,
kLPI2C_SlaveTransmitEvent = 0x02U,
kLPI2C_SlaveReceiveEvent = 0x04U,
kLPI2C_SlaveTransmitAckEvent = 0x08U,
kLPI2C_SlaveRepeatedStartEvent = 0x10U,
kLPI2C_SlaveCompletionEvent = 0x20U,
kLPI2C_SlaveAllEvents = kLPI2C_SlaveAddressMatchEvent | kLPI2C_SlaveTransmitEvent | kLPI2C_SlaveReceiveEvent |
kLPI2C_SlaveTransmitAckEvent | kLPI2C_SlaveRepeatedStartEvent | kLPI2C_SlaveCompletionEvent,
} lpi2c_slave_transfer_event_t;
typedef struct _lpi2c_slave_transfer
{
lpi2c_slave_transfer_event_t event;
uint8_t receivedAddress;
uint8_t *data;
size_t dataSize;
status_t completionStatus;
size_t transferredCount;
} lpi2c_slave_transfer_t;
/* Forward declaration. */
typedef struct _lpi2c_slave_handle lpi2c_slave_handle_t;
typedef void (*lpi2c_slave_transfer_callback_t)(LPI2C_Type *base, lpi2c_slave_transfer_t *transfer, void *userData);
struct _lpi2c_slave_handle
{
lpi2c_slave_transfer_t transfer;
bool isBusy;
bool wasTransmit;
uint32_t eventMask;
uint32_t transferredCount;
lpi2c_slave_transfer_callback_t callback;
void *userData;
};
/*******************************************************************************
* API
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif
void LPI2C_MasterGetDefaultConfig(lpi2c_master_config_t *masterConfig);
void LPI2C_MasterInit(LPI2C_Type *base, const lpi2c_master_config_t *masterConfig, uint32_t sourceClock_Hz);
void LPI2C_MasterDeinit(LPI2C_Type *base);
void LPI2C_MasterConfigureDataMatch(LPI2C_Type *base, const lpi2c_data_match_config_t *config);
static inline void LPI2C_MasterReset(LPI2C_Type *base)
{
base->MCR = LPI2C_MCR_RST_MASK;
base->MCR = 0;
}
static inline void LPI2C_MasterEnable(LPI2C_Type *base, bool enable)
{
base->MCR = (base->MCR & ~LPI2C_MCR_MEN_MASK) | LPI2C_MCR_MEN(enable);
}
static inline uint32_t LPI2C_MasterGetStatusFlags(LPI2C_Type *base)
{
return base->MSR;
}
static inline void LPI2C_MasterClearStatusFlags(LPI2C_Type *base, uint32_t statusMask)
{
base->MSR = statusMask;
}
static inline void LPI2C_MasterEnableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
{
base->MIER |= interruptMask;
}
static inline void LPI2C_MasterDisableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
{
base->MIER &= ~interruptMask;
}
static inline uint32_t LPI2C_MasterGetEnabledInterrupts(LPI2C_Type *base)
{
return base->MIER;
}
static inline void LPI2C_MasterEnableDMA(LPI2C_Type *base, bool enableTx, bool enableRx)
{
base->MDER = LPI2C_MDER_TDDE(enableTx) | LPI2C_MDER_RDDE(enableRx);
}
static inline uint32_t LPI2C_MasterGetTxFifoAddress(LPI2C_Type *base)
{
return (uint32_t)&base->MTDR;
}
static inline uint32_t LPI2C_MasterGetRxFifoAddress(LPI2C_Type *base)
{
return (uint32_t)&base->MRDR;
}
static inline void LPI2C_MasterSetWatermarks(LPI2C_Type *base, size_t txWords, size_t rxWords)
{
base->MFCR = LPI2C_MFCR_TXWATER(txWords) | LPI2C_MFCR_RXWATER(rxWords);
}
static inline void LPI2C_MasterGetFifoCounts(LPI2C_Type *base, size_t *rxCount, size_t *txCount)
{
if (txCount)
{
*txCount = (base->MFSR & LPI2C_MFSR_TXCOUNT_MASK) >> LPI2C_MFSR_TXCOUNT_SHIFT;
}
if (rxCount)
{
*rxCount = (base->MFSR & LPI2C_MFSR_RXCOUNT_MASK) >> LPI2C_MFSR_RXCOUNT_SHIFT;
}
}
void LPI2C_MasterSetBaudRate(LPI2C_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Hz);
static inline bool LPI2C_MasterGetBusIdleState(LPI2C_Type *base)
{
return (base->MSR & LPI2C_MSR_BBF_MASK) >> LPI2C_MSR_BBF_SHIFT;
}
status_t LPI2C_MasterStart(LPI2C_Type *base, uint8_t address, lpi2c_direction_t dir);
static inline status_t LPI2C_MasterRepeatedStart(LPI2C_Type *base, uint8_t address, lpi2c_direction_t dir)
{
return LPI2C_MasterStart(base, address, dir);
}
status_t LPI2C_MasterSend(LPI2C_Type *base, const void *txBuff, size_t txSize);
status_t LPI2C_MasterReceive(LPI2C_Type *base, void *rxBuff, size_t rxSize);
status_t LPI2C_MasterStop(LPI2C_Type *base);
void LPI2C_MasterCreateHandle(LPI2C_Type *base,
lpi2c_master_handle_t *handle,
lpi2c_master_transfer_callback_t callback,
void *userData);
status_t LPI2C_MasterTransferNonBlocking(LPI2C_Type *base,
lpi2c_master_handle_t *handle,
lpi2c_master_transfer_t *transfer);
status_t LPI2C_MasterGetTransferCount(LPI2C_Type *base, lpi2c_master_handle_t *handle, size_t *count);
void LPI2C_MasterAbortTransfer(LPI2C_Type *base, lpi2c_master_handle_t *handle);
void LPI2C_MasterHandleInterrupt(LPI2C_Type *base, lpi2c_master_handle_t *handle);
void LPI2C_SlaveGetDefaultConfig(lpi2c_slave_config_t *slaveConfig);
void LPI2C_SlaveInit(LPI2C_Type *base, const lpi2c_slave_config_t *slaveConfig, uint32_t sourceClock_Hz);
void LPI2C_SlaveDeinit(LPI2C_Type *base);
static inline void LPI2C_SlaveReset(LPI2C_Type *base)
{
base->SCR = LPI2C_SCR_RST_MASK;
base->SCR = 0;
}
static inline void LPI2C_SlaveEnable(LPI2C_Type *base, bool enable)
{
base->SCR = (base->SCR & ~LPI2C_SCR_SEN_MASK) | LPI2C_SCR_SEN(enable);
}
static inline uint32_t LPI2C_SlaveGetStatusFlags(LPI2C_Type *base)
{
return base->SSR;
}
static inline void LPI2C_SlaveClearStatusFlags(LPI2C_Type *base, uint32_t statusMask)
{
base->SSR = statusMask;
}
static inline void LPI2C_SlaveEnableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
{
base->SIER |= interruptMask;
}
static inline void LPI2C_SlaveDisableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
{
base->SIER &= ~interruptMask;
}
static inline uint32_t LPI2C_SlaveGetEnabledInterrupts(LPI2C_Type *base)
{
return base->SIER;
}
static inline void LPI2C_SlaveEnableDMA(LPI2C_Type *base, bool enableAddressValid, bool enableRx, bool enableTx)
{
base->SDER = (base->SDER & ~(LPI2C_SDER_AVDE_MASK | LPI2C_SDER_RDDE_MASK | LPI2C_SDER_TDDE_MASK)) |
LPI2C_SDER_AVDE(enableAddressValid) | LPI2C_SDER_RDDE(enableRx) | LPI2C_SDER_TDDE(enableTx);
}
static inline bool LPI2C_SlaveGetBusIdleState(LPI2C_Type *base)
{
return (base->SSR & LPI2C_SSR_BBF_MASK) >> LPI2C_SSR_BBF_SHIFT;
}
static inline void LPI2C_SlaveTransmitAck(LPI2C_Type *base, bool ackOrNack)
{
base->STAR = LPI2C_STAR_TXNACK(!ackOrNack);
}
static inline uint32_t LPI2C_SlaveGetReceivedAddress(LPI2C_Type *base)
{
return base->SASR & LPI2C_SASR_RADDR_MASK;
}
status_t LPI2C_SlaveSend(LPI2C_Type *base, const void *txBuff, size_t txSize, size_t *actualTxSize);
status_t LPI2C_SlaveReceive(LPI2C_Type *base, void *rxBuff, size_t rxSize, size_t *actualRxSize);
void LPI2C_SlaveCreateHandle(LPI2C_Type *base,
lpi2c_slave_handle_t *handle,
lpi2c_slave_transfer_callback_t callback,
void *userData);
status_t LPI2C_SlaveTransferNonBlocking(LPI2C_Type *base, lpi2c_slave_handle_t *handle, uint32_t eventMask);
status_t LPI2C_SlaveGetTransferCount(LPI2C_Type *base, lpi2c_slave_handle_t *handle, size_t *count);
void LPI2C_SlaveAbortTransfer(LPI2C_Type *base, lpi2c_slave_handle_t *handle);
void LPI2C_SlaveHandleInterrupt(LPI2C_Type *base, lpi2c_slave_handle_t *handle);
#if defined(__cplusplus)
}
#endif
#endif /* _FSL_LPI2C_H_ */
LPI2C_SlaveGetTransferCount
status_t LPI2C_SlaveGetTransferCount(LPI2C_Type *base, lpi2c_slave_handle_t *handle, size_t *count)
Get slave transfer status during a non-blocking transfer.
Definition: fsl_lpi2c.c:1329
kLPI2C_SlaveTransmitAckEvent
Definition: fsl_lpi2c.h:357
LPI2C_MasterStop
status_t LPI2C_MasterStop(LPI2C_Type *base)
Sends a STOP signal on the I2C bus.
Definition: fsl_lpi2c.c:540
kLPI2C_AnyWordAndM1EqualsM0AndM1
Definition: fsl_lpi2c.h:178
lpi2c_master_config_t::debugEnable
bool debugEnable
Definition: fsl_lpi2c.h:151
LPI2C_MasterAbortTransfer
void LPI2C_MasterAbortTransfer(LPI2C_Type *base, lpi2c_master_handle_t *handle)
Terminates a non-blocking LPI2C master transmission early.
Definition: fsl_lpi2c.c:1001
LPI2C_SlaveTransferNonBlocking
status_t LPI2C_SlaveTransferNonBlocking(LPI2C_Type *base, lpi2c_slave_handle_t *handle, uint32_t eventMask)
Start accepting slave transfers.
Definition: fsl_lpi2c.c:1286
kLPI2C_MasterArbitrationLostFlag
Definition: fsl_lpi2c.h:97
kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1
Definition: fsl_lpi2c.h:174
lpi2c_slave_transfer_t::completionStatus
status_t completionStatus
Definition: fsl_lpi2c.h:373
lpi2c_host_request_source_t
lpi2c_host_request_source_t
LPI2C master host request selection.
Definition: fsl_lpi2c.h:127
lpi2c_data_match_config_mode_t
lpi2c_data_match_config_mode_t
LPI2C master data match configuration modes.
Definition: fsl_lpi2c.h:168
LPI2C_SlaveReset
static void LPI2C_SlaveReset(LPI2C_Type *base)
Perform software reset of the LPI2C slave peripheral.
Definition: fsl_lpi2c.h:949
_lpi2c_master_transfer::subaddress
uint32_t subaddress
Definition: fsl_lpi2c.h:235
LPI2C_SlaveGetStatusFlags
static uint32_t LPI2C_SlaveGetStatusFlags(LPI2C_Type *base)
Gets the LPI2C slave status flags.
Definition: fsl_lpi2c.h:983
LPI2C_SlaveGetBusIdleState
static bool LPI2C_SlaveGetBusIdleState(LPI2C_Type *base)
Return whether the bus is idle.
Definition: fsl_lpi2c.h:1090
lpi2c_slave_transfer_t
LPI2C slave transfer structure.
Definition: fsl_lpi2c.h:367
lpi2c_slave_transfer_callback_t
void(* lpi2c_slave_transfer_callback_t)(LPI2C_Type *base, lpi2c_slave_transfer_t *transfer, void *userData)
Slave event callback function pointer type.
Definition: fsl_lpi2c.h:391
lpi2c_data_match_config_t::match1
uint32_t match1
Definition: fsl_lpi2c.h:188
kLPI2C_MasterPinLowTimeoutFlag
Definition: fsl_lpi2c.h:99
lpi2c_slave_config_t::filterEnable
bool filterEnable
Definition: fsl_lpi2c.h:317
kLPI2C_HostRequestPinActiveLow
Definition: fsl_lpi2c.h:134
LPI2C_MasterReset
static void LPI2C_MasterReset(LPI2C_Type *base)
Perform software reset.
Definition: fsl_lpi2c.h:492
LPI2C_MasterRepeatedStart
static status_t LPI2C_MasterRepeatedStart(LPI2C_Type *base, uint8_t address, lpi2c_direction_t dir)
Sends a repeated START signal and slave address on the I2C bus.
Definition: fsl_lpi2c.h:748
_lpi2c_slave_handle::callback
lpi2c_slave_transfer_callback_t callback
Definition: fsl_lpi2c.h:404
kLPI2C_MasterBusBusyFlag
Definition: fsl_lpi2c.h:102
kStatus_LPI2C_ArbitrationLost
Definition: fsl_lpi2c.h:58
LPI2C_SlaveDeinit
void LPI2C_SlaveDeinit(LPI2C_Type *base)
Deinitializes the LPI2C slave peripheral.
Definition: fsl_lpi2c.c:1106
kLPI2C_Write
Definition: fsl_lpi2c.h:107
kLPI2C_HostRequestInputTrigger
Definition: fsl_lpi2c.h:129
lpi2c_master_config_t::baudRate_Hz
uint32_t baudRate_Hz
Definition: fsl_lpi2c.h:154
kLPI2C_2PinOutputOnly
Definition: fsl_lpi2c.h:114
kLPI2C_MasterNackDetectFlag
Definition: fsl_lpi2c.h:96
lpi2c_master_config_t::enableDoze
bool enableDoze
Definition: fsl_lpi2c.h:150
LPI2C_MasterGetTxFifoAddress
static uint32_t LPI2C_MasterGetTxFifoAddress(LPI2C_Type *base)
Gets LPI2C master transmit data register address for DMA transfer.
Definition: fsl_lpi2c.h:626
kLPI2C_MasterFifoErrFlag
Definition: fsl_lpi2c.h:98
lpi2c_slave_config_t::clockHoldTime_ns
uint32_t clockHoldTime_ns
Definition: fsl_lpi2c.h:338
LPI2C_MasterInit
void LPI2C_MasterInit(LPI2C_Type *base, const lpi2c_master_config_t *masterConfig, uint32_t sourceClock_Hz)
Initializes the LPI2C master peripheral.
Definition: fsl_lpi2c.c:348
lpi2c_slave_transfer_event_t
lpi2c_slave_transfer_event_t
Set of events sent to the callback for nonblocking slave transfers.
Definition: fsl_lpi2c.h:351
kStatus_LPI2C_BitError
Definition: fsl_lpi2c.h:57
kLPI2C_SlaveTxReadyFlag
Definition: fsl_lpi2c.h:279
LPI2C_SlaveTransmitAck
static void LPI2C_SlaveTransmitAck(LPI2C_Type *base, bool ackOrNack)
Transmit either an Ack or Nak on the I2C bus in response to a byte from the master.
Definition: fsl_lpi2c.h:1105
lpi2c_slave_config_t::enableReceivedAddressRead
bool enableReceivedAddressRead
Definition: fsl_lpi2c.h:334
LPI2C_SlaveGetDefaultConfig
void LPI2C_SlaveGetDefaultConfig(lpi2c_slave_config_t *slaveConfig)
Provides a default configuration for the LPI2C slave peripheral.
Definition: fsl_lpi2c.c:1052
_lpi2c_slave_handle::isBusy
bool isBusy
Definition: fsl_lpi2c.h:400
kLPI2C_SlaveTransmitEvent
Definition: fsl_lpi2c.h:353
lpi2c_data_match_config_t::rxDataMatchOnly
bool rxDataMatchOnly
Definition: fsl_lpi2c.h:186
_lpi2c_master_transfer::dataSize
size_t dataSize
Definition: fsl_lpi2c.h:238
LPI2C_MasterTransferNonBlocking
status_t LPI2C_MasterTransferNonBlocking(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_t *transfer)
Performs a non-blocking transaction on the I2C bus.
Definition: fsl_lpi2c.c:898
kLPI2C_2PinPushPullWithSeparateSlave
Definition: fsl_lpi2c.h:121
LPI2C_SlaveAbortTransfer
void LPI2C_SlaveAbortTransfer(LPI2C_Type *base, lpi2c_slave_handle_t *handle)
Abort slave non-blocking transfers.
Definition: fsl_lpi2c.c:1351
lpi2c_master_transfer_callback_t
void(* lpi2c_master_transfer_callback_t)(LPI2C_Type *base, lpi2c_master_handle_t *handle, status_t completionStatus, void *userData)
Master completion callback function pointer type.
Definition: fsl_lpi2c.h:205
LPI2C_MasterDeinit
void LPI2C_MasterDeinit(LPI2C_Type *base)
Deinitializes the LPI2C master peripheral.
Definition: fsl_lpi2c.c:417
kLPI2C_1stWordEqualsM0OrM1
Definition: fsl_lpi2c.h:170
_lpi2c_slave_handle::transfer
lpi2c_slave_transfer_t transfer
Definition: fsl_lpi2c.h:399
kStatus_LPI2C_FifoError
Definition: fsl_lpi2c.h:56
kLPI2C_4PinPushPullWithInvertedOutput
Definition: fsl_lpi2c.h:123
kLPI2C_MasterEndOfPacketFlag
Definition: fsl_lpi2c.h:94
LPI2C_MasterEnableInterrupts
static void LPI2C_MasterEnableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
Enable LPI2C master interrupt requests.
Definition: fsl_lpi2c.h:571
lpi2c_slave_config_t::addressMatchMode
lpi2c_slave_address_match_t addressMatchMode
Definition: fsl_lpi2c.h:315
lpi2c_master_pin_config_t
lpi2c_master_pin_config_t
LPI2C pin configuration.
Definition: fsl_lpi2c.h:112
LPI2C_SlaveSend
status_t LPI2C_SlaveSend(LPI2C_Type *base, const void *txBuff, size_t txSize, size_t *actualTxSize)
Performs a polling send transfer on the I2C bus.
Definition: fsl_lpi2c.c:1149
LPI2C_SlaveCreateHandle
void LPI2C_SlaveCreateHandle(LPI2C_Type *base, lpi2c_slave_handle_t *handle, lpi2c_slave_transfer_callback_t callback, void *userData)
Create a new handle for the LPI2C slave non-blocking APIs.
Definition: fsl_lpi2c.c:1253
LPI2C_SlaveEnable
static void LPI2C_SlaveEnable(LPI2C_Type *base, bool enable)
Enables or disables the LPI2C module as slave.
Definition: fsl_lpi2c.h:961
kStatus_LPI2C_NoTransferInProgress
Definition: fsl_lpi2c.h:61
kLPI2C_2PinOutputOnlyWithSeparateSlave
Definition: fsl_lpi2c.h:119
lpi2c_direction_t
lpi2c_direction_t
Direction of master and slave transfers.
Definition: fsl_lpi2c.h:106
kLPI2C_AnyWordEqualsM0OrM1
Definition: fsl_lpi2c.h:171
lpi2c_host_request_polarity_t
lpi2c_host_request_polarity_t
LPI2C master host request pin polarity configuration.
Definition: fsl_lpi2c.h:133
_lpi2c_slave_handle::wasTransmit
bool wasTransmit
Definition: fsl_lpi2c.h:401
kLPI2C_TransferNoStartFlag
Definition: fsl_lpi2c.h:219
_lpi2c_status
_lpi2c_status
LPI2C status return codes.
Definition: fsl_lpi2c.h:51
lpi2c_master_config_t::sclGlitchFilterWidth_ns
uint8_t sclGlitchFilterWidth_ns
Definition: fsl_lpi2c.h:158
lpi2c_slave_address_match_t
lpi2c_slave_address_match_t
LPI2C slave address match options.
Definition: fsl_lpi2c.h:295
kStatus_LPI2C_PinLowTimeout
Definition: fsl_lpi2c.h:59
lpi2c_slave_transfer_t::dataSize
size_t dataSize
Definition: fsl_lpi2c.h:372
_lpi2c_master_handle
Driver handle for master non-blocking APIs.
Definition: fsl_lpi2c.h:245
lpi2c_slave_transfer_t::receivedAddress
uint8_t receivedAddress
Definition: fsl_lpi2c.h:370
lpi2c_master_config_t::busIdleTimeout_ns
uint32_t busIdleTimeout_ns
Definition: fsl_lpi2c.h:155
lpi2c_slave_transfer_t::data
uint8_t * data
Definition: fsl_lpi2c.h:371
kLPI2C_1stWordAndM1EqualsM0AndM1
Definition: fsl_lpi2c.h:176
kLPI2C_2PinPushPull
Definition: fsl_lpi2c.h:115
lpi2c_slave_config_t::address0
uint8_t address0
Definition: fsl_lpi2c.h:313
LPI2C_SlaveGetEnabledInterrupts
static uint32_t LPI2C_SlaveGetEnabledInterrupts(LPI2C_Type *base)
Returns the set of currently enabled LPI2C slave interrupt requests.
Definition: fsl_lpi2c.h:1051
LPI2C_MasterCreateHandle
void LPI2C_MasterCreateHandle(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_callback_t callback, void *userData)
Create a new handle for the LPI2C master non-blocking APIs.
Definition: fsl_lpi2c.c:644
kLPI2C_TransferRepeatedStartFlag
Definition: fsl_lpi2c.h:220
LPI2C_SlaveReceive
status_t LPI2C_SlaveReceive(LPI2C_Type *base, void *rxBuff, size_t rxSize, size_t *actualRxSize)
Performs a polling receive transfer on the I2C bus.
Definition: fsl_lpi2c.c:1201
lpi2c_slave_config_t::sdaGlitchFilterWidth_ns
uint32_t sdaGlitchFilterWidth_ns
Definition: fsl_lpi2c.h:335
_lpi2c_master_transfer::direction
lpi2c_direction_t direction
Definition: fsl_lpi2c.h:234
LPI2C_SlaveEnableDMA
static void LPI2C_SlaveEnableDMA(LPI2C_Type *base, bool enableAddressValid, bool enableRx, bool enableTx)
Enable or disable LPI2C slave peripheral DMA requests.
Definition: fsl_lpi2c.h:1070
kLPI2C_MatchAddress0ThroughAddress1
Definition: fsl_lpi2c.h:298
LPI2C_MasterGetBusIdleState
static bool LPI2C_MasterGetBusIdleState(LPI2C_Type *base)
Return whether the bus is idle.
Definition: fsl_lpi2c.h:710
LPI2C_MasterGetFifoCounts
static void LPI2C_MasterGetFifoCounts(LPI2C_Type *base, size_t *rxCount, size_t *txCount)
Get the current number of words in the LPI2C master FIFOs.
Definition: fsl_lpi2c.h:672
lpi2c_master_config_t::enableMaster
bool enableMaster
Definition: fsl_lpi2c.h:149
LPI2C_MasterSetBaudRate
void LPI2C_MasterSetBaudRate(LPI2C_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Hz)
Sets the I2C bus frequency for master transactions.
Definition: fsl_lpi2c.c:443
_lpi2c_master_handle::userData
void * userData
Definition: fsl_lpi2c.h:253
lpi2c_data_match_config_t::matchMode
lpi2c_data_match_config_mode_t matchMode
Definition: fsl_lpi2c.h:185
kLPI2C_2PinOpenDrain
Definition: fsl_lpi2c.h:113
LPI2C_SlaveGetReceivedAddress
static uint32_t LPI2C_SlaveGetReceivedAddress(LPI2C_Type *base)
Returns the slave address sent by the I2C master.
Definition: fsl_lpi2c.h:1119
kLPI2C_SlaveAddressMatch1Flag
Definition: fsl_lpi2c.h:288
LPI2C_MasterGetDefaultConfig
void LPI2C_MasterGetDefaultConfig(lpi2c_master_config_t *masterConfig)
Provides a default configuration for the LPI2C master peripheral.
Definition: fsl_lpi2c.c:332
LPI2C_MasterDisableInterrupts
static void LPI2C_MasterDisableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
Disable LPI2C master interrupt requests.
Definition: fsl_lpi2c.h:586
kLPI2C_SlaveGeneralCallFlag
Definition: fsl_lpi2c.h:289
kLPI2C_SlaveCompletionEvent
Definition: fsl_lpi2c.h:359
lpi2c_slave_config_t::filterDozeEnable
bool filterDozeEnable
Definition: fsl_lpi2c.h:316
LPI2C_SlaveEnableInterrupts
static void LPI2C_SlaveEnableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
Enable LPI2C slave interrupt requests.
Definition: fsl_lpi2c.h:1025
_lpi2c_master_transfer::subaddressSize
size_t subaddressSize
Definition: fsl_lpi2c.h:236
_lpi2c_slave_handle::userData
void * userData
Definition: fsl_lpi2c.h:405
LPI2C_MasterGetTransferCount
status_t LPI2C_MasterGetTransferCount(LPI2C_Type *base, lpi2c_master_handle_t *handle, size_t *count)
Returns number of bytes transferred so far.
Definition: fsl_lpi2c.c:949
LPI2C_SlaveInit
void LPI2C_SlaveInit(LPI2C_Type *base, const lpi2c_slave_config_t *slaveConfig, uint32_t sourceClock_Hz)
Initializes the LPI2C slave peripheral.
Definition: fsl_lpi2c.c:1073
lpi2c_master_config_t
Structure with settings to initialize the LPI2C master module.
Definition: fsl_lpi2c.h:147
kLPI2C_HostRequestExternalPin
Definition: fsl_lpi2c.h:128
kLPI2C_MasterTxReadyFlag
Definition: fsl_lpi2c.h:92
LPI2C_SlaveClearStatusFlags
static void LPI2C_SlaveClearStatusFlags(LPI2C_Type *base, uint32_t statusMask)
Clears the LPI2C status flag state.
Definition: fsl_lpi2c.h:1005
kLPI2C_MatchAddress0
Definition: fsl_lpi2c.h:296
LPI2C_MasterGetStatusFlags
static uint32_t LPI2C_MasterGetStatusFlags(LPI2C_Type *base)
Gets the LPI2C master status flags.
Definition: fsl_lpi2c.h:526
_lpi2c_master_flags
_lpi2c_master_flags
LPI2C master peripheral flags.
Definition: fsl_lpi2c.h:90
_lpi2c_master_transfer::data
void * data
Definition: fsl_lpi2c.h:237
kStatus_LPI2C_Nak
Definition: fsl_lpi2c.h:55
_lpi2c_master_handle::completionCallback
lpi2c_master_transfer_callback_t completionCallback
Definition: fsl_lpi2c.h:252
_lpi2c_master_handle::transfer
lpi2c_master_transfer_t transfer
Definition: fsl_lpi2c.h:251
LPI2C_MasterEnable
static void LPI2C_MasterEnable(LPI2C_Type *base, bool enable)
Enables or disables the LPI2C module as master.
Definition: fsl_lpi2c.h:504
lpi2c_data_match_config_t
LPI2C master data match config struct.
Definition: fsl_lpi2c.h:183
LPI2C_MasterClearStatusFlags
static void LPI2C_MasterClearStatusFlags(LPI2C_Type *base, uint32_t statusMask)
Clears the LPI2C master status flag state.
Definition: fsl_lpi2c.h:551
kLPI2C_SlaveRxReadyFlag
Definition: fsl_lpi2c.h:280
_lpi2c_master_transfer_flags
_lpi2c_master_transfer_flags
Transfer option flags.
Definition: fsl_lpi2c.h:216
kLPI2C_SlaveStopDetectFlag
Definition: fsl_lpi2c.h:284
kLPI2C_SlaveTransmitAckFlag
Definition: fsl_lpi2c.h:282
lpi2c_master_config_t::pinConfig
lpi2c_master_pin_config_t pinConfig
Definition: fsl_lpi2c.h:153
kLPI2C_SlaveAddressValidFlag
Definition: fsl_lpi2c.h:281
LPI2C_MasterSend
status_t LPI2C_MasterSend(LPI2C_Type *base, const void *txBuff, size_t txSize)
Performs a polling send transfer on the I2C bus.
Definition: fsl_lpi2c.c:621
lpi2c_data_match_config_t::match0
uint32_t match0
Definition: fsl_lpi2c.h:187
kLPI2C_SlaveAddressMatch0Flag
Definition: fsl_lpi2c.h:287
_lpi2c_slave_flags
_lpi2c_slave_flags
LPI2C slave peripheral flags.
Definition: fsl_lpi2c.h:277
kLPI2C_SlaveRepeatedStartEvent
Definition: fsl_lpi2c.h:358
lpi2c_slave_transfer_t::event
lpi2c_slave_transfer_event_t event
Definition: fsl_lpi2c.h:369
lpi2c_slave_transfer_t::transferredCount
size_t transferredCount
Definition: fsl_lpi2c.h:375
_lpi2c_master_handle::remainingBytes
uint16_t remainingBytes
Definition: fsl_lpi2c.h:248
_lpi2c_master_handle::state
uint8_t state
Definition: fsl_lpi2c.h:247
_lpi2c_master_transfer::slaveAddress
uint16_t slaveAddress
Definition: fsl_lpi2c.h:233
kLPI2C_SlaveAllEvents
Definition: fsl_lpi2c.h:362
lpi2c_master_config_t::sdaGlitchFilterWidth_ns
uint8_t sdaGlitchFilterWidth_ns
Definition: fsl_lpi2c.h:157
_lpi2c_master_handle::buf
uint8_t * buf
Definition: fsl_lpi2c.h:249
kLPI2C_SlaveBusBusyFlag
Definition: fsl_lpi2c.h:291
kLPI2C_MatchAddress0OrAddress1
Definition: fsl_lpi2c.h:297
kLPI2C_MasterBusyFlag
Definition: fsl_lpi2c.h:101
lpi2c_slave_config_t::ignoreAck
bool ignoreAck
Definition: fsl_lpi2c.h:333
lpi2c_master_config_t::ignoreAck
bool ignoreAck
Definition: fsl_lpi2c.h:152
kLPI2C_SlaveRepeatedStartDetectFlag
Definition: fsl_lpi2c.h:283
lpi2c_master_config_t::pinLowTimeout_ns
uint32_t pinLowTimeout_ns
Definition: fsl_lpi2c.h:156
lpi2c_slave_config_t::sclGlitchFilterWidth_ns
uint32_t sclGlitchFilterWidth_ns
Definition: fsl_lpi2c.h:336
lpi2c_slave_config_t::enableGeneralCall
bool enableGeneralCall
Definition: fsl_lpi2c.h:318
kStatus_LPI2C_Busy
Definition: fsl_lpi2c.h:53
kLPI2C_Read
Definition: fsl_lpi2c.h:108
LPI2C_SlaveHandleInterrupt
void LPI2C_SlaveHandleInterrupt(LPI2C_Type *base, lpi2c_slave_handle_t *handle)
Reusable routine to handle slave interrupts.
Definition: fsl_lpi2c.c:1372
LPI2C_MasterSetWatermarks
static void LPI2C_MasterSetWatermarks(LPI2C_Type *base, size_t txWords, size_t rxWords)
Set the watermarks for LPI2C master FIFOs.
Definition: fsl_lpi2c.h:658
lpi2c_slave_config_t::dataValidDelay_ns
uint32_t dataValidDelay_ns
Definition: fsl_lpi2c.h:337
_lpi2c_master_transfer::flags
uint32_t flags
Definition: fsl_lpi2c.h:231
LPI2C_MasterGetEnabledInterrupts
static uint32_t LPI2C_MasterGetEnabledInterrupts(LPI2C_Type *base)
Returns the set of currently enabled LPI2C master interrupt requests.
Definition: fsl_lpi2c.h:598
kLPI2C_MatchDisabled
Definition: fsl_lpi2c.h:169
kLPI2C_SlaveFifoErrFlag
Definition: fsl_lpi2c.h:286
lpi2c_slave_config_t::enableSlave
bool enableSlave
Definition: fsl_lpi2c.h:312
kLPI2C_MasterDataMatchFlag
Definition: fsl_lpi2c.h:100
kLPI2C_1stWordEqualsM0And2ndWordEqualsM1
Definition: fsl_lpi2c.h:172
kLPI2C_SlaveBusyFlag
Definition: fsl_lpi2c.h:290
LPI2C_MasterReceive
status_t LPI2C_MasterReceive(LPI2C_Type *base, void *rxBuff, size_t rxSize)
Performs a polling receive transfer on the I2C bus.
Definition: fsl_lpi2c.c:572
kStatus_LPI2C_Idle
Definition: fsl_lpi2c.h:54
kStatus_LPI2C_DmaRequestFail
Definition: fsl_lpi2c.h:63
_lpi2c_slave_handle
LPI2C slave handle structure.
Definition: fsl_lpi2c.h:397
LPI2C_SlaveDisableInterrupts
static void LPI2C_SlaveDisableInterrupts(LPI2C_Type *base, uint32_t interruptMask)
Disable LPI2C slave interrupt requests.
Definition: fsl_lpi2c.h:1040
LPI2C_MasterStart
status_t LPI2C_MasterStart(LPI2C_Type *base, uint8_t address, lpi2c_direction_t dir)
Sends a START signal and slave address on the I2C bus.
Definition: fsl_lpi2c.c:512
kLPI2C_TransferDefaultFlag
Definition: fsl_lpi2c.h:218
status_t
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:121
kLPI2C_4PinPushPull
Definition: fsl_lpi2c.h:116
LPI2C_MasterHandleInterrupt
void LPI2C_MasterHandleInterrupt(LPI2C_Type *base, lpi2c_master_handle_t *handle)
Reusable routine to handle master interrupts.
Definition: fsl_lpi2c.c:1019
lpi2c_slave_config_t::address1
uint8_t address1
Definition: fsl_lpi2c.h:314
kLPI2C_SlaveBitErrFlag
Definition: fsl_lpi2c.h:285
kLPI2C_SlaveReceiveEvent
Definition: fsl_lpi2c.h:355
kLPI2C_MasterStopDetectFlag
Definition: fsl_lpi2c.h:95
lpi2c_slave_config_t
Structure with settings to initialize the LPI2C slave module.
Definition: fsl_lpi2c.h:310
kLPI2C_HostRequestPinActiveHigh
Definition: fsl_lpi2c.h:135
LPI2C_MasterGetRxFifoAddress
static uint32_t LPI2C_MasterGetRxFifoAddress(LPI2C_Type *base)
Gets LPI2C master receive data register address for DMA transfer.
Definition: fsl_lpi2c.h:637
kStatusGroup_LPI2C
Definition: fsl_common.h:74
_lpi2c_slave_handle::eventMask
uint32_t eventMask
Definition: fsl_lpi2c.h:402
LPI2C_MasterEnableDMA
static void LPI2C_MasterEnableDMA(LPI2C_Type *base, bool enableTx, bool enableRx)
Enables or disables LPI2C master DMA requests.
Definition: fsl_lpi2c.h:615
_lpi2c_slave_handle::transferredCount
uint32_t transferredCount
Definition: fsl_lpi2c.h:403
kLPI2C_TransferNoStopFlag
Definition: fsl_lpi2c.h:221
LPI2C_MasterConfigureDataMatch
void LPI2C_MasterConfigureDataMatch(LPI2C_Type *base, const lpi2c_data_match_config_t *config)
Configure LPI2C master data match feature.
Definition: fsl_lpi2c.c:426
kLPI2C_SlaveAddressMatchEvent
Definition: fsl_lpi2c.h:352
kLPI2C_2PinOpenDrainWithSeparateSlave
Definition: fsl_lpi2c.h:117
_lpi2c_master_transfer
Non-blocking transfer descriptor structure.
Definition: fsl_lpi2c.h:229
kLPI2C_MasterRxReadyFlag
Definition: fsl_lpi2c.h:93