| Kinetis SDK v.2.0 API Reference Manual Rev. 0 Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Typedefs | Enumerations
LPI2C Master Driver
LPI2C: Low Power I2C Driver

## Overview

## Data Structures
struct | lpi2c_master_config_t
| Structure with settings to initialize the LPI2C master module. More...
struct | lpi2c_data_match_config_t
| LPI2C master data match configuration structure. More...
struct | lpi2c_master_transfer_t
| Non-blocking transfer descriptor structure. More...
struct | lpi2c_master_handle_t
| Driver handle for master non-blocking APIs. More...

## Typedefs
typedef 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. More...

## Enumerations
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 }
| LPI2C master peripheral flags. More...
enum | lpi2c_direction_t { kLPI2C_Write = 0U, kLPI2C_Read = 1U }
| Direction of master and slave transfers. More...
enum | lpi2c_master_pin_config_t { kLPI2C_2PinOpenDrain = 0x0U, kLPI2C_2PinOutputOnly = 0x1U, kLPI2C_2PinPushPull = 0x2U, kLPI2C_4PinPushPull = 0x3U, kLPI2C_2PinOpenDrainWithSeparateSlave, kLPI2C_2PinOutputOnlyWithSeparateSlave, kLPI2C_2PinPushPullWithSeparateSlave, kLPI2C_4PinPushPullWithInvertedOutput = 0x7U }
| LPI2C pin configuration. More...
enum | lpi2c_host_request_source_t { kLPI2C_HostRequestExternalPin = 0x0U, kLPI2C_HostRequestInputTrigger = 0x1U }
| LPI2C master host request selection. More...
enum | lpi2c_host_request_polarity_t { kLPI2C_HostRequestPinActiveLow = 0x0U, kLPI2C_HostRequestPinActiveHigh = 0x1U }
| LPI2C master host request pin polarity configuration. More...
enum | lpi2c_data_match_config_mode_t { kLPI2C_MatchDisabled = 0x0U, kLPI2C_1stWordEqualsM0OrM1 = 0x2U, kLPI2C_AnyWordEqualsM0OrM1 = 0x3U, kLPI2C_1stWordEqualsM0And2ndWordEqualsM1, kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1, kLPI2C_1stWordAndM1EqualsM0AndM1, kLPI2C_AnyWordAndM1EqualsM0AndM1 }
| LPI2C master data match configuration modes. More...
enum | _lpi2c_master_transfer_flags { kLPI2C_TransferDefaultFlag = 0x00U, kLPI2C_TransferNoStartFlag = 0x01U, kLPI2C_TransferRepeatedStartFlag = 0x02U, kLPI2C_TransferNoStopFlag = 0x04U }
| Transfer option flags. More...

## Initialization and deinitialization
void | LPI2C_MasterGetDefaultConfig (lpi2c_master_config_t *masterConfig)
| Provides a default configuration for the LPI2C master peripheral. More...
void | LPI2C_MasterInit (LPI2C_Type *base, const lpi2c_master_config_t *masterConfig, uint32_t sourceClock_Hz)
| Initializes the LPI2C master peripheral. More...
void | LPI2C_MasterDeinit (LPI2C_Type *base)
| Deinitializes the LPI2C master peripheral. More...
void | LPI2C_MasterConfigureDataMatch (LPI2C_Type *base, const lpi2c_data_match_config_t *config)
| Configures LPI2C master data match feature. More...
static void | LPI2C_MasterReset (LPI2C_Type *base)
| Performs a software reset. More...
static void | LPI2C_MasterEnable (LPI2C_Type *base, bool enable)
| Enables or disables the LPI2C module as master. More...

## Status
static uint32_t | LPI2C_MasterGetStatusFlags (LPI2C_Type *base)
| Gets the LPI2C master status flags. More...
static void | LPI2C_MasterClearStatusFlags (LPI2C_Type *base, uint32_t statusMask)
| Clears the LPI2C master status flag state. More...

## Interrupts
static void | LPI2C_MasterEnableInterrupts (LPI2C_Type *base, uint32_t interruptMask)
| Enables the LPI2C master interrupt requests. More...
static void | LPI2C_MasterDisableInterrupts (LPI2C_Type *base, uint32_t interruptMask)
| Disables the LPI2C master interrupt requests. More...
static uint32_t | LPI2C_MasterGetEnabledInterrupts (LPI2C_Type *base)
| Returns the set of currently enabled LPI2C master interrupt requests. More...

## DMA control
static void | LPI2C_MasterEnableDMA (LPI2C_Type *base, bool enableTx, bool enableRx)
| Enables or disables LPI2C master DMA requests. More...
static uint32_t | LPI2C_MasterGetTxFifoAddress (LPI2C_Type *base)
| Gets LPI2C master transmit data register address for DMA transfer. More...
static uint32_t | LPI2C_MasterGetRxFifoAddress (LPI2C_Type *base)
| Gets LPI2C master receive data register address for DMA transfer. More...

## FIFO control
static void | LPI2C_MasterSetWatermarks (LPI2C_Type *base, size_t txWords, size_t rxWords)
| Sets the watermarks for LPI2C master FIFOs. More...
static void | LPI2C_MasterGetFifoCounts (LPI2C_Type *base, size_t *rxCount, size_t *txCount)
| Gets the current number of words in the LPI2C master FIFOs. More...

## Bus operations
void | LPI2C_MasterSetBaudRate (LPI2C_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Hz)
| Sets the I2C bus frequency for master transactions. More...
static bool | LPI2C_MasterGetBusIdleState (LPI2C_Type *base)
| Returns whether the bus is idle. More...
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. More...
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. More...
status_t | LPI2C_MasterSend (LPI2C_Type *base, const void *txBuff, size_t txSize)
| Performs a polling send transfer on the I2C bus. More...
status_t | LPI2C_MasterReceive (LPI2C_Type *base, void *rxBuff, size_t rxSize)
| Performs a polling receive transfer on the I2C bus. More...
status_t | LPI2C_MasterStop (LPI2C_Type *base)
| Sends a STOP signal on the I2C bus. More...

## Non-blocking
void | LPI2C_MasterTransferCreateHandle (LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_callback_t callback, void *userData)
| Creates a new handle for the LPI2C master non-blocking APIs. More...
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. More...
status_t | LPI2C_MasterTransferGetCount (LPI2C_Type *base, lpi2c_master_handle_t *handle, size_t *count)
| Returns number of bytes transferred so far. More...
void | LPI2C_MasterTransferAbort (LPI2C_Type *base, lpi2c_master_handle_t *handle)
| Terminates a non-blocking LPI2C master transmission early. More...

## IRQ handler
void | LPI2C_MasterTransferHandleIRQ (LPI2C_Type *base, lpi2c_master_handle_t *handle)
| Reusable routine to handle master interrupts. More...

## Data Structure Documentation

struct lpi2c_master_config_t

This structure holds configuration settings for the LPI2C peripheral. To initialize this structure to reasonable defaults, call the LPI2C_MasterGetDefaultConfig() function and pass a pointer to your configuration structure instance.

The configuration structure can be made constant so it resides in flash.

### Data Fields
bool | enableMaster
| Whether to enable master mode. More...
bool | enableDoze
| Whether master is enabled in doze mode. More...
bool | debugEnable
| Enable transfers to continue when halted in debug mode. More...
bool | ignoreAck
| Whether to ignore ACK/NACK. More...
lpi2c_master_pin_config_t | pinConfig
| The pin configuration option. More...
uint32_t | baudRate_Hz
| Desired baud rate in Hertz. More...
uint32_t | busIdleTimeout_ns
| Bus idle timeout in nanoseconds. More...
uint32_t | pinLowTimeout_ns
| Pin low timeout in nanoseconds. More...
uint8_t | sdaGlitchFilterWidth_ns
| Width in nanoseconds of glitch filter on SDA pin. More...
uint8_t | sclGlitchFilterWidth_ns
| Width in nanoseconds of glitch filter on SCL pin. More...
struct {
bool enable
| Enable host request. More...
lpi2c_host_request_source_t source
| Host request source. More...
lpi2c_host_request_polarity_t polarity
| Host request pin polarity. More...
} | hostRequest
| Host request options. More...

#### Field Documentation

bool lpi2c_master_config_t::enableMaster

bool lpi2c_master_config_t::enableDoze

bool lpi2c_master_config_t::debugEnable

bool lpi2c_master_config_t::ignoreAck

lpi2c_master_pin_config_t lpi2c_master_config_t::pinConfig

uint32_t lpi2c_master_config_t::baudRate_Hz

uint32_t lpi2c_master_config_t::busIdleTimeout_ns

Set to 0 to disable.

uint32_t lpi2c_master_config_t::pinLowTimeout_ns

Set to 0 to disable.

uint8_t lpi2c_master_config_t::sdaGlitchFilterWidth_ns

Set to 0 to disable.

uint8_t lpi2c_master_config_t::sclGlitchFilterWidth_ns

Set to 0 to disable.

bool lpi2c_master_config_t::enable

lpi2c_host_request_source_t lpi2c_master_config_t::source

lpi2c_host_request_polarity_t lpi2c_master_config_t::polarity

struct { ... } lpi2c_master_config_t::hostRequest

struct lpi2c_data_match_config_t

### Data Fields
lpi2c_data_match_config_mode_t | matchMode
| Data match configuration setting. More...
bool | rxDataMatchOnly
| When set to true, received data is ignored until a successful match. More...
uint32_t | match0
| Match value 0. More...
uint32_t | match1
| Match value 1. More...

#### Field Documentation

lpi2c_data_match_config_mode_t lpi2c_data_match_config_t::matchMode

bool lpi2c_data_match_config_t::rxDataMatchOnly

uint32_t lpi2c_data_match_config_t::match0

uint32_t lpi2c_data_match_config_t::match1

struct _lpi2c_master_transfer

This structure is used to pass transaction parameters to the LPI2C_MasterTransferNonBlocking() API.

### Data Fields
uint32_t | flags
| Bit mask of options for the transfer. More...
uint16_t | slaveAddress
| The 7-bit slave address. More...
lpi2c_direction_t | direction
| Either kLPI2C_Read or kLPI2C_Write. More...
uint32_t | subaddress
| Sub address. More...
size_t | subaddressSize
| Length of sub address to send in bytes. More...
void * | data
| Pointer to data to transfer. More...
size_t | dataSize
| Number of bytes to transfer. More...

#### Field Documentation

uint32_t lpi2c_master_transfer_t::flags

See enumeration _lpi2c_master_transfer_flags for available options. Set to 0 or kLPI2C_TransferDefaultFlag for normal transfers.

uint16_t lpi2c_master_transfer_t::slaveAddress

lpi2c_direction_t lpi2c_master_transfer_t::direction

uint32_t lpi2c_master_transfer_t::subaddress

Transferred MSB first.

size_t lpi2c_master_transfer_t::subaddressSize

Maximum size is 4 bytes.

void* lpi2c_master_transfer_t::data

size_t lpi2c_master_transfer_t::dataSize

struct _lpi2c_master_handle

Note
  The contents of this structure are private and subject to change.

### Data Fields
uint8_t | state
| Transfer state machine current state. More...
uint16_t | remainingBytes
| Remaining byte count in current state. More...
uint8_t * | buf
| Buffer pointer for current state. More...
uint16_t | commandBuffer [7]
| LPI2C command sequence. More...
lpi2c_master_transfer_t | transfer
| Copy of the current transfer info. More...
lpi2c_master_transfer_callback_t | completionCallback
| Callback function pointer. More...
void * | userData
| Application data passed to callback. More...

#### Field Documentation

uint8_t lpi2c_master_handle_t::state

uint16_t lpi2c_master_handle_t::remainingBytes

uint8_t* lpi2c_master_handle_t::buf

uint16_t lpi2c_master_handle_t::commandBuffer[7]

lpi2c_master_transfer_t lpi2c_master_handle_t::transfer

lpi2c_master_transfer_callback_t lpi2c_master_handle_t::completionCallback

void* lpi2c_master_handle_t::userData

## Typedef Documentation

typedef void(* lpi2c_master_transfer_callback_t)(LPI2C_Type *base, lpi2c_master_handle_t *handle, status_t completionStatus, void *userData)

This callback is used only for the non-blocking master transfer API. Specify the callback you wish to use in the call to LPI2C_MasterTransferCreateHandle().

Parameters

  base | The LPI2C peripheral base address.
  completionStatus | Either #kStatus_Success or an error code describing how the transfer completed.
  userData | Arbitrary pointer-sized value passed from the application.

## Enumeration Type Documentation

enum _lpi2c_master_flags

The following status register flags can be cleared:

- kLPI2C_MasterEndOfPacketFlag
- kLPI2C_MasterStopDetectFlag
- kLPI2C_MasterNackDetectFlag
- kLPI2C_MasterArbitrationLostFlag
- kLPI2C_MasterFifoErrFlag
- kLPI2C_MasterPinLowTimeoutFlag
- kLPI2C_MasterDataMatchFlag

All flags except kLPI2C_MasterBusyFlag and kLPI2C_MasterBusBusyFlag can be enabled as interrupts.

Note
  These enums are meant to be OR'd together to form a bit mask.

Enumerator
kLPI2C_MasterTxReadyFlag | Transmit data flag.
kLPI2C_MasterRxReadyFlag | Receive data flag.
kLPI2C_MasterEndOfPacketFlag | End Packet flag.
kLPI2C_MasterStopDetectFlag | Stop detect flag.
kLPI2C_MasterNackDetectFlag | NACK detect flag.
kLPI2C_MasterArbitrationLostFlag | Arbitration lost flag.
kLPI2C_MasterFifoErrFlag | FIFO error flag.
kLPI2C_MasterPinLowTimeoutFlag | Pin low timeout flag.
kLPI2C_MasterDataMatchFlag | Data match flag.
kLPI2C_MasterBusyFlag | Master busy flag.
kLPI2C_MasterBusBusyFlag | Bus busy flag.

enum lpi2c_direction_t

Enumerator
kLPI2C_Write | Master transmit.
kLPI2C_Read | Master receive.

enum lpi2c_master_pin_config_t

Enumerator
kLPI2C_2PinOpenDrain | LPI2C Configured for 2-pin open drain mode.
kLPI2C_2PinOutputOnly | LPI2C Configured for 2-pin output only mode (ultra-fast mode)
kLPI2C_2PinPushPull | LPI2C Configured for 2-pin push-pull mode.
kLPI2C_4PinPushPull | LPI2C Configured for 4-pin push-pull mode.
kLPI2C_2PinOpenDrainWithSeparateSlave | LPI2C Configured for 2-pin open drain mode with separate LPI2C slave.
kLPI2C_2PinOutputOnlyWithSeparateSlave | LPI2C Configured for 2-pin output only mode(ultra-fast mode) with separate LPI2C slave.
kLPI2C_2PinPushPullWithSeparateSlave | LPI2C Configured for 2-pin push-pull mode with separate LPI2C slave.
kLPI2C_4PinPushPullWithInvertedOutput | LPI2C Configured for 4-pin push-pull mode(inverted outputs)

enum lpi2c_host_request_source_t

Enumerator
kLPI2C_HostRequestExternalPin | Select the LPI2C_HREQ pin as the host request input.
kLPI2C_HostRequestInputTrigger | Select the input trigger as the host request input.

enum lpi2c_host_request_polarity_t

Enumerator
kLPI2C_HostRequestPinActiveLow | Configure the LPI2C_HREQ pin active low.
kLPI2C_HostRequestPinActiveHigh | Configure the LPI2C_HREQ pin active high.

enum lpi2c_data_match_config_mode_t

Enumerator
kLPI2C_MatchDisabled | LPI2C Match Disabled.
kLPI2C_1stWordEqualsM0OrM1 | LPI2C Match Enabled and 1st data word equals MATCH0 OR MATCH1.
kLPI2C_AnyWordEqualsM0OrM1 | LPI2C Match Enabled and any data word equals MATCH0 OR MATCH1.
kLPI2C_1stWordEqualsM0And2ndWordEqualsM1 | LPI2C Match Enabled and 1st data word equals MATCH0, 2nd data equals MATCH1.
kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1 | LPI2C Match Enabled and any data word equals MATCH0, next data equals MATCH1.
kLPI2C_1stWordAndM1EqualsM0AndM1 | LPI2C Match Enabled and 1st data word and MATCH0 equals MATCH0 and MATCH1.
kLPI2C_AnyWordAndM1EqualsM0AndM1 | LPI2C Match Enabled and any data word and MATCH0 equals MATCH0 and MATCH1.

enum _lpi2c_master_transfer_flags

Note
  These enumerations are intended to be OR'd together to form a bit mask of options for the _lpi2c_master_transfer::flags field.

Enumerator
kLPI2C_TransferDefaultFlag | Transfer starts with a start signal, stops with a stop signal.
kLPI2C_TransferNoStartFlag | Don't send a start condition, address, and sub address.
kLPI2C_TransferRepeatedStartFlag | Send a repeated start condition.
kLPI2C_TransferNoStopFlag | Don't send a stop condition.

## Function Documentation

void LPI2C_MasterGetDefaultConfig | ( | lpi2c_master_config_t * | masterConfig | ) |

This function provides the following default configuration for the LPI2C master peripheral:

masterConfig->enableMaster = true;
masterConfig->debugEnable = false;
masterConfig->ignoreAck = false;
masterConfig->pinConfig = kLPI2C_2PinOpenDrain;
masterConfig->baudRate_Hz = 100000U;
masterConfig->busIdleTimeout_ns = 0;
masterConfig->pinLowTimeout_ns = 0;
masterConfig->sdaGlitchFilterWidth_ns = 0;
masterConfig->sclGlitchFilterWidth_ns = 0;
masterConfig->hostRequest.enable = false;
masterConfig->hostRequest.source = kLPI2C_HostRequestExternalPin;
masterConfig->hostRequest.polarity = kLPI2C_HostRequestPinActiveHigh;

After calling this function, you can override any settings in order to customize the configuration, prior to initializing the master driver with LPI2C_MasterInit().

Parameters

  [out] | masterConfig | User provided configuration structure for default values. Refer to lpi2c_master_config_t.

void LPI2C_MasterInit | ( | LPI2C_Type * | base,
|  | const lpi2c_master_config_t * | masterConfig,
|  | uint32_t | sourceClock_Hz
| ) |  |

This function enables the peripheral clock and initializes the LPI2C master peripheral as described by the user provided configuration. A software reset is performed prior to configuration.

Parameters

  base | The LPI2C peripheral base address.
  masterConfig | User provided peripheral configuration. Use LPI2C_MasterGetDefaultConfig() to get a set of defaults that you can override.
  sourceClock_Hz | Frequency in Hertz of the LPI2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods.

void LPI2C_MasterDeinit | ( | LPI2C_Type * | base | ) |

This function disables the LPI2C master peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.

Parameters

  base | The LPI2C peripheral base address.

void LPI2C_MasterConfigureDataMatch | ( | LPI2C_Type * | base,
|  | const lpi2c_data_match_config_t * | config
| ) |  |

Parameters

  base | The LPI2C peripheral base address.
  config | Settings for the data match feature.

static void LPI2C_MasterReset | ( | LPI2C_Type * | base | ) |
| inline static

Restores the LPI2C master peripheral to reset conditions.

Parameters

  base | The LPI2C peripheral base address.

static void LPI2C_MasterEnable | ( | LPI2C_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | The LPI2C peripheral base address.
  enable | Pass true to enable or false to disable the specified LPI2C as master.

static uint32_t LPI2C_MasterGetStatusFlags | ( | LPI2C_Type * | base | ) |
| inline static

A bit mask with the state of all LPI2C master status flags is returned. For each flag, the corresponding bit in the return value is set if the flag is asserted.

Parameters

  base | The LPI2C peripheral base address.

Returns
  State of the status flags:
  - 1: related status flag is set.
  - 0: related status flag is not set.

See Also
  _lpi2c_master_flags

static void LPI2C_MasterClearStatusFlags | ( | LPI2C_Type * | base,
|  | uint32_t | statusMask
| ) |  |
| inline static

The following status register flags can be cleared:

- kLPI2C_MasterEndOfPacketFlag
- kLPI2C_MasterStopDetectFlag
- kLPI2C_MasterNackDetectFlag
- kLPI2C_MasterArbitrationLostFlag
- kLPI2C_MasterFifoErrFlag
- kLPI2C_MasterPinLowTimeoutFlag
- kLPI2C_MasterDataMatchFlag

Attempts to clear other flags has no effect.

Parameters

  base | The LPI2C peripheral base address.
  statusMask | A bitmask of status flags that are to be cleared. The mask is composed of _lpi2c_master_flags enumerators OR'd together. You may pass the result of a previous call to LPI2C_MasterGetStatusFlags().

See Also
  _lpi2c_master_flags.

static void LPI2C_MasterEnableInterrupts | ( | LPI2C_Type * | base,
|  | uint32_t | interruptMask
| ) |  |
| inline static

All flags except kLPI2C_MasterBusyFlag and kLPI2C_MasterBusBusyFlag can be enabled as interrupts.

Parameters

  base | The LPI2C peripheral base address.
  interruptMask | Bit mask of interrupts to enable. See _lpi2c_master_flags for the set of constants that should be OR'd together to form the bit mask.

static void LPI2C_MasterDisableInterrupts | ( | LPI2C_Type * | base,
|  | uint32_t | interruptMask
| ) |  |
| inline static

All flags except kLPI2C_MasterBusyFlag and kLPI2C_MasterBusBusyFlag can be enabled as interrupts.

Parameters

  base | The LPI2C peripheral base address.
  interruptMask | Bit mask of interrupts to disable. See _lpi2c_master_flags for the set of constants that should be OR'd together to form the bit mask.

static uint32_t LPI2C_MasterGetEnabledInterrupts | ( | LPI2C_Type * | base | ) |
| inline static

Parameters

  base | The LPI2C peripheral base address.

Returns
  A bitmask composed of _lpi2c_master_flags enumerators OR'd together to indicate the set of enabled interrupts.

static void LPI2C_MasterEnableDMA | ( | LPI2C_Type * | base,
|  | bool | enableTx,
|  | bool | enableRx
| ) |  |
| inline static

Parameters

  base | The LPI2C peripheral base address.
  enableTx | Enable flag for transmit DMA request. Pass true for enable, false for disable.
  enableRx | Enable flag for receive DMA request. Pass true for enable, false for disable.

static uint32_t LPI2C_MasterGetTxFifoAddress | ( | LPI2C_Type * | base | ) |
| inline static

Parameters

  base | The LPI2C peripheral base address.

Returns
  The LPI2C Master Transmit Data Register address.

static uint32_t LPI2C_MasterGetRxFifoAddress | ( | LPI2C_Type * | base | ) |
| inline static

Parameters

  base | The LPI2C peripheral base address.

Returns
  The LPI2C Master Receive Data Register address.

static void LPI2C_MasterSetWatermarks | ( | LPI2C_Type * | base,
|  | size_t | txWords,
|  | size_t | rxWords
| ) |  |
| inline static

Parameters

  base | The LPI2C peripheral base address.
  txWords | Transmit FIFO watermark value in words. The kLPI2C_MasterTxReadyFlag flag is set whenever the number of words in the transmit FIFO is equal or less than txWords. Writing a value equal or greater than the FIFO size is truncated.
  rxWords | Receive FIFO watermark value in words. The kLPI2C_MasterRxReadyFlag flag is set whenever the number of words in the receive FIFO is greater than rxWords. Writing a value equal or greater than the FIFO size is truncated.

static void LPI2C_MasterGetFifoCounts | ( | LPI2C_Type * | base,
|  | size_t * | rxCount,
|  | size_t * | txCount
| ) |  |
| inline static

Parameters

  | base | The LPI2C peripheral base address.
  [out] | txCount | Pointer through which the current number of words in the transmit FIFO is returned. Pass NULL if this value is not required.
  [out] | rxCount | Pointer through which the current number of words in the receive FIFO is returned. Pass NULL if this value is not required.

void LPI2C_MasterSetBaudRate | ( | LPI2C_Type * | base,
|  | uint32_t | sourceClock_Hz,
|  | uint32_t | baudRate_Hz
| ) |  |

The LPI2C master is automatically disabled and re-enabled as necessary to configure the baud rate. Do not call this function during a transfer, or the transfer is aborted.

Parameters

  base | The LPI2C peripheral base address.
  sourceClock_Hz | LPI2C functional clock frequency in Hertz.
  baudRate_Hz | Requested bus frequency in Hertz.

static bool LPI2C_MasterGetBusIdleState | ( | LPI2C_Type * | base | ) |
| inline static

Requires the master mode to be enabled.

Parameters

  base | The LPI2C peripheral base address.

Return values

  true | Bus is busy.
  false | Bus is idle.

status_t LPI2C_MasterStart | ( | LPI2C_Type * | base,
|  | uint8_t | address,
|  | lpi2c_direction_t | dir
| ) |  |

This function is used to initiate a new master mode transfer. First, the bus state is checked to ensure that another master is not occupying the bus. Then a START signal is transmitted, followed by the 7-bit address specified in the address parameter. Note that this function does not actually wait until the START and address are successfully sent on the bus before returning.

Parameters

  base | The LPI2C peripheral base address.
  address | 7-bit slave device address, in bits [6:0].
  dir | Master transfer direction, either kLPI2C_Read or kLPI2C_Write. This parameter is used to set the R/w bit (bit 0) in the transmitted slave address.

Return values

  #kStatus_Success | START signal and address were successfully enqueued in the transmit FIFO.
  kStatus_LPI2C_Busy | Another master is currently utilizing the bus.

static status_t LPI2C_MasterRepeatedStart | ( | LPI2C_Type * | base,
|  | uint8_t | address,
|  | lpi2c_direction_t | dir
| ) |  |
| inline static

This function is used to send a Repeated START signal when a transfer is already in progress. Like LPI2C_MasterStart(), it also sends the specified 7-bit address.

Note
  This function exists primarily to maintain compatible APIs between LPI2C and I2C drivers, as well as to better document the intent of code that uses these APIs.

Parameters

  base | The LPI2C peripheral base address.
  address | 7-bit slave device address, in bits [6:0].
  dir | Master transfer direction, either kLPI2C_Read or kLPI2C_Write. This parameter is used to set the R/w bit (bit 0) in the transmitted slave address.

Return values

  #kStatus_Success | Repeated START signal and address were successfully enqueued in the transmit FIFO.
  kStatus_LPI2C_Busy | Another master is currently utilizing the bus.

status_t LPI2C_MasterSend | ( | LPI2C_Type * | base,
|  | const void * | txBuff,
|  | size_t | txSize
| ) |  |

Sends up to txSize number of bytes to the previously addressed slave device. The slave may reply with a NAK to any byte in order to terminate the transfer early. If this happens, this function returns kStatus_LPI2C_Nak.

Parameters

  base | The LPI2C peripheral base address.
  txBuff | The pointer to the data to be transferred.
  txSize | The length in bytes of the data to be transferred.

Return values

  #kStatus_Success | Data was sent successfully.
  kStatus_LPI2C_Busy | Another master is currently utilizing the bus.
  kStatus_LPI2C_Nak | The slave device sent a NAK in response to a byte.
  kStatus_LPI2C_FifoError | FIFO under run or over run.
  kStatus_LPI2C_ArbitrationLost | Arbitration lost error.
  kStatus_LPI2C_PinLowTimeout | SCL or SDA were held low longer than the timeout.

status_t LPI2C_MasterReceive | ( | LPI2C_Type * | base,
|  | void * | rxBuff,
|  | size_t | rxSize
| ) |  |

Parameters

  base | The LPI2C peripheral base address.
  rxBuff | The pointer to the data to be transferred.
  rxSize | The length in bytes of the data to be transferred.

Return values

  #kStatus_Success | Data was received successfully.
  kStatus_LPI2C_Busy | Another master is currently utilizing the bus.
  kStatus_LPI2C_Nak | The slave device sent a NAK in response to a byte.
  kStatus_LPI2C_FifoError | FIFO under run or overrun.
  kStatus_LPI2C_ArbitrationLost | Arbitration lost error.
  kStatus_LPI2C_PinLowTimeout | SCL or SDA were held low longer than the timeout.

status_t LPI2C_MasterStop | ( | LPI2C_Type * | base | ) |

This function does not return until the STOP signal is seen on the bus, or an error occurs.

Parameters

  base | The LPI2C peripheral base address.

Return values

  #kStatus_Success | The STOP signal was successfully sent on the bus and the transaction terminated.
  kStatus_LPI2C_Busy | Another master is currently utilizing the bus.
  kStatus_LPI2C_Nak | The slave device sent a NAK in response to a byte.
  kStatus_LPI2C_FifoError | FIFO under run or overrun.
  kStatus_LPI2C_ArbitrationLost | Arbitration lost error.
  kStatus_LPI2C_PinLowTimeout | SCL or SDA were held low longer than the timeout.

void LPI2C_MasterTransferCreateHandle | ( | LPI2C_Type * | base,
|  | lpi2c_master_handle_t * | handle,
|  | lpi2c_master_transfer_callback_t | callback,
|  | void * | userData
| ) |  |

The creation of a handle is for use with the non-blocking APIs. Once a handle is created, there is not a corresponding destroy handle. If the user wants to terminate a transfer, the LPI2C_MasterTransferAbort() API shall be called.

Parameters

  | base | The LPI2C peripheral base address.
  [out] | handle | Pointer to the LPI2C master driver handle.
  | callback | User provided pointer to the asynchronous callback function.
  | userData | User provided pointer to the application callback data.

status_t LPI2C_MasterTransferNonBlocking | ( | LPI2C_Type * | base,
|  | lpi2c_master_handle_t * | handle,
|  | lpi2c_master_transfer_t * | transfer
| ) |  |

Parameters

  base | The LPI2C peripheral base address.
  handle | Pointer to the LPI2C master driver handle.
  transfer | The pointer to the transfer descriptor.

Return values

  #kStatus_Success | The transaction was started successfully.
  kStatus_LPI2C_Busy | Either another master is currently utilizing the bus, or a non-blocking transaction is already in progress.

status_t LPI2C_MasterTransferGetCount | ( | LPI2C_Type * | base,
|  | lpi2c_master_handle_t * | handle,
|  | size_t * | count
| ) |  |

Parameters

  | base | The LPI2C peripheral base address.
  | handle | Pointer to the LPI2C master driver handle.
  [out] | count | Number of bytes transferred so far by the non-blocking transaction.

Return values

  #kStatus_Success |
  #kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress.

void LPI2C_MasterTransferAbort | ( | LPI2C_Type * | base,
|  | lpi2c_master_handle_t * | handle
| ) |  |

Note
  It is not safe to call this function from an IRQ handler that has a higher priority than the LPI2C peripheral's IRQ priority.

Parameters

  base | The LPI2C peripheral base address.
  handle | Pointer to the LPI2C master driver handle.

Return values

  #kStatus_Success | A transaction was successfully aborted.
  kStatus_LPI2C_Idle | There is not a non-blocking transaction currently in progress.

void LPI2C_MasterTransferHandleIRQ | ( | LPI2C_Type * | base,
|  | lpi2c_master_handle_t * | handle
| ) |  |

Note
  This function does not need to be called unless you are reimplementing the nonblocking API's interrupt handler routines to add special functionality.

Parameters

  base | The LPI2C peripheral base address.
  handle | Pointer to the LPI2C master driver handle.