4.9.1 I2C

I2C (also known as Two-Wire Interface (TWI))

4.9.1.1 Introduction

MCC Melody I2C Driver with Host and Client Interfaces

The Inter-Integrated Circuit (I2C) bus is a multi-host serial data communication bus, supported by a Two Wire Interface (TWI) peripheral on AVR MCUs. Devices communicate in a host/client environment where the host devices initiate the communication. A client device is controlled through addressing.

4.9.1.2 Supported Device Families

ATtiny

4.9.1.3 Required header files:

For host mode, include the following files in your application to use the I2C abstract driver:

#include <stdbool.h>
#include <stdint.h>
#include "mcc_generated_files/i2c_host/i2c_host_interface.h"

For client mode, include the following files in your application to use the I2C abstract driver:

#include <stdbool.h>
#include <stdint.h>
#include "mcc_generated_files/i2c_client/i2c_client_interface.h"

4.9.1.5 Module Documentation

4.9.1.5.1 TWI0_CLIENT_TYPES

This header file provides APIs for the TWI0 driver.

Module description

This header file provides APIs for the TWI0 driver.

Version: TWI0 Driver Version 2.0.1
Enumerations

Enumeration Type Documentation

i2c_client_ack_status_t

enum i2c_client_ack_status_t

I2C Ack/Nack status enumeration.

I2C_CLIENT_ACK_STATUS_RECEIVED_ACK

I2C Host is send ACK to client

I2C_CLIENT_ACK_STATUS_RECEIVED_NACK

I2C Host is send NACK to client

i2c_client_error_t

enum i2c_client_error_t

I2C client error type indicator.

I2C_CLIENT_ERROR_NONE

I2C error none

I2C_CLIENT_ERROR_BUS_ERROR

I2C Bus Error occurred

I2C_CLIENT_ERROR_COLLISION

I2C Collision occurred

i2c_client_transfer_dir_t

enum i2c_client_transfer_dir_t

I2C_CLIENT_TRANSFER_DIR Enumeration.

I2C_CLIENT_TRANSFER_DIR_WRITE

I2C Host is writing to client

I2C_CLIENT_TRANSFER_DIR_READ

I2C Host is reading from client

i2c_client_transfer_event_t

enum i2c_client_transfer_event_t

I2C notification event type.

I2C_CLIENT_TRANSFER_EVENT_NONE

I2C Bus Idle state

I2C_CLIENT_TRANSFER_EVENT_ADDR_MATCH

Address match event

I2C_CLIENT_TRANSFER_EVENT_RX_READY

Data sent by I2C Host is available

I2C_CLIENT_TRANSFER_EVENT_TX_READY

I2C client can respond to data read request from I2C Host

I2C_CLIENT_TRANSFER_EVENT_STOP_BIT_RECEIVED

I2C stop bit received

I2C_CLIENT_TRANSFER_EVENT_ERROR

I2C Bus error occurred

4.9.1.5.2 TWI0_HOST_EVENT

This header file provides APIs for the TWI0 driver.

Module description

This header file provides APIs for the TWI0 driver.

Version: TWI0 Driver Version 2.0.1
Enumerations
  • enum i2c_event_states_t { I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET }

    Enumeration for I2C states.

4.9.1.5.3 TWI0

This header file provides APIs for the TWI0 driver.

Module description

This header file provides APIs for the TWI0 driver.

Version: TWI0 Driver Version 2.0.1
Data structures
Enumerations
  • enum i2c_host_error_t { I2C_ERROR_NONE, I2C_ERROR_ADDR_NACK, I2C_ERROR_DATA_NACK, I2C_ERROR_BUS_COLLISION }

    Enumeration for I2C_ERROR code.

4.9.1.5.4 TWI_CLIENT

This header file provides APIs for the TWI0 driver.

Module description

This header file provides APIs for the TWI0 driver.

Version: TWI0 Driver Version 1.1.0
Functions

Function Documentation

TWI0_CallbackRegister()

void TWI0_CallbackRegister (bool(*)(i2c_client_transfer_event_t clientEvent) callback)

This function sets the pointer to be called "back" when the given I2C transfer events, Bus collision and Write collision occur.

Parameters:
handler

- A pointer to a function.

Returns:

void

TWI0_Deinitialize()

void TWI0_Deinitialize (void )

This routine Deinitializes the TWI0 module. This function disables the module.

This API Deinitializes the TWI0 module. This routine disables the TWI0 module.

Parameters:
void
Returns:

void

This routine Deinitializes the TWI0 module. This function disables the module.

This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

Parameters:
void
Returns:

void

Parameters:
none
Returns:

none

TWI0_ErrorGet()

i2c_client_error_t TWI0_ErrorGet (void )

This function the error occurred during I2C Transmit and Receive.

Parameters:
void
Return values:
I2C_CLIENT_ERROR_BUS_COLLISION

- I2C Bus Collision Error

I2C_CLIENT_ERROR_WRITE_COLLISION

- I2C Write Collision Error

I2C_CLIENT_ERROR_RECEIVE_OVERFLOW

- I2C Receive overflow

I2C_CLIENT_ERROR_NONE

- No Error

This function get the error occurred during I2C Transmit and Receive.

Parameters:
void
Return values:
I2C_CLIENT_ERROR_BUS_COLLISION

- I2C Bus Collision Error

I2C_CLIENT_ERROR_WRITE_COLLISION

- I2C Write Collision Error

I2C_CLIENT_ERROR_RECEIVE_OVERFLOW

- I2C Receive overflow

I2C_CLIENT_ERROR_NONE

- No Error

Parameters:
none
Return values:
I2C_ERROR_NONE

- No Error

I2C_ERROR_NACK

- Client returned NACK

I2C_ERROR_BUS_COLLISION

- Bus Collision Error

TWI0_Initialize()

void TWI0_Initialize (void )

This routine initializes the TWI0 module.

This API initializes the TWI0 module.

Parameters:
void
Returns:

void

This routine initializes the TWI0 module.

This API initializes the I2C_Host driver.

Section: Public functions

Parameters:
void
Returns:

void

Parameters:
none
Returns:

none

Section: Public functions

TWI0_LastByteAckStatusGet()

i2c_client_ack_status_t TWI0_LastByteAckStatusGet (void )

This function get the I2C Host ACK status.

Parameters:
void
Return values:
I2C_CLIENT_ACK_STATUS_RECEIVED_ACK

- I2C Host sent ACK to client

I2C_CLIENT_ACK_STATUS_RECEIVED_NACK

- I2C Host sent NACK to client

TWI0_ReadAddr()

uint16_t TWI0_ReadAddr (void )

This function read requested address from a host on the bus.

Parameters:
void
Returns:

address byte -TWI0 client read byte

TWI0_ReadByte()

uint8_t TWI0_ReadByte (void )

This function read data from a host on the bus.

Parameters:
void
Returns:

data byte -TWI0 client read byte

TWI0_Tasks()

void TWI0_Tasks (void )

This function is common Polling function for all TWI0 client.

Parameters:
void.
Returns:

void

TWI0_TransferDirGet()

i2c_client_transfer_dir_t TWI0_TransferDirGet (void )

This function get the I2C Transfer direction.

Parameters:
void
Return values:
I2C_CLIENT_TRANSFER_DIR_WRITE

- I2C Host is writing to client

I2C_CLIENT_TRANSFER_DIR_READ

- I2C Host is reading from client

TWI0_WriteByte()

void TWI0_WriteByte (uint8_t wrByte)

This function writes data to a host on the bus.

Parameters:
in wrByte

- TWI0 client write byte

Returns:

void

4.9.1.5.5 TWI_HOST

This header file provides APIs for the TWI0 driver.

Module description

This header file provides APIs for the TWI0 driver.

Version: TWI0 Driver Version 2.1.0
Functions
  • void TWI0_Initialize (void)

    This API initializes the I2C_Host driver.

  • void TWI0_Deinitialize (void)

    This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

  • bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)

    This API writes data to a Client on the bus.

  • bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)

    This API reads the data from a client on the bus.

  • bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)

    This API writes data from the writeData to the bus and then reads data from the Client and stores the received in the readData.

  • i2c_host_error_t TWI0_ErrorGet (void)

    This function get the error occurred during I2C Transmit and Receive.

  • bool TWI0_IsBusy (void)

    This API checks if I2C is busy.

  • void TWI0_CallbackRegister (void(*handler)(void))

    Setter function for I2C interrupt callback, This will be called when any error is generated.

  • void TWI0_ErrorCallbackRegister (void(*handler)(void))

    Setter function for I2C Error interrupt callback.

  • void TWI0_Tasks (void)

    This is polling function for non interrupt mode.

Function Documentation

TWI0_CallbackRegister()

void TWI0_CallbackRegister (void(*)(void) handler)

Setter function for I2C interrupt callback, This will be called when any error is generated.

Parameters:
void

*handler - Pointer to custom Callback.

Returns:

none

Parameters:
void

*CallbackHandler - Pointer to custom Callback.

Returns:

none

TWI0_Deinitialize()

void TWI0_Deinitialize (void )

This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

Parameters:
none
Returns:

none

This routine Deinitializes the TWI0 module. This function disables the module.

This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

Parameters:
void
Returns:

void

Parameters:
none
Returns:

none

This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

This API Deinitializes the TWI0 module. This routine disables the TWI0 module.

Parameters:
void
Returns:

void

This routine Deinitializes the TWI0 module. This function disables the module.

This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

Parameters:
void
Returns:

void

Parameters:
none
Returns:

none

TWI0_ErrorCallbackRegister()

void TWI0_ErrorCallbackRegister (void(*)(void) handler)

Setter function for I2C Error interrupt callback.

Parameters:
void

*handler - Pointer to custom Callback.

Returns:

none

TWI0_ErrorGet()

i2c_host_error_t TWI0_ErrorGet (void )

This function get the error occurred during I2C Transmit and Receive.

Parameters:
none
Returns:

i2c_host_error_t - I2C error code staus.

Parameters:
none
Return values:
I2C_ERROR_NONE

- No Error

I2C_ERROR_NACK

- Client returned NACK

I2C_ERROR_BUS_COLLISION

- Bus Collision Error

This function get the error occurred during I2C Transmit and Receive.

Parameters:
void
Return values:
I2C_CLIENT_ERROR_BUS_COLLISION

- I2C Bus Collision Error

I2C_CLIENT_ERROR_WRITE_COLLISION

- I2C Write Collision Error

I2C_CLIENT_ERROR_RECEIVE_OVERFLOW

- I2C Receive overflow

I2C_CLIENT_ERROR_NONE

- No Error

Parameters:
none
Return values:
I2C_ERROR_NONE

- No Error

I2C_ERROR_NACK

- Client returned NACK

I2C_ERROR_BUS_COLLISION

- Bus Collision Error

This function get the error occurred during I2C Transmit and Receive.

Parameters:
void
Return values:
I2C_CLIENT_ERROR_BUS_COLLISION

- I2C Bus Collision Error

I2C_CLIENT_ERROR_WRITE_COLLISION

- I2C Write Collision Error

I2C_CLIENT_ERROR_RECEIVE_OVERFLOW

- I2C Receive overflow

I2C_CLIENT_ERROR_NONE

- No Error

This function get the error occurred during I2C Transmit and Receive.

Parameters:
void
Return values:
I2C_CLIENT_ERROR_BUS_COLLISION

- I2C Bus Collision Error

I2C_CLIENT_ERROR_WRITE_COLLISION

- I2C Write Collision Error

I2C_CLIENT_ERROR_RECEIVE_OVERFLOW

- I2C Receive overflow

I2C_CLIENT_ERROR_NONE

- No Error

Parameters:
none
Return values:
I2C_ERROR_NONE

- No Error

I2C_ERROR_NACK

- Client returned NACK

I2C_ERROR_BUS_COLLISION

- Bus Collision Error

TWI0_Initialize()

void TWI0_Initialize (void )

This API initializes the I2C_Host driver.

Parameters:
none
Returns:

none

This routine initializes the TWI0 module.

This API initializes the I2C_Host driver.

Section: Public functions

Parameters:
void
Returns:

void

Parameters:
none
Returns:

none

This API initializes the I2C_Host driver.

Section: Public functions

This API initializes the I2C_Host driver.

This API initializes the TWI0 module.

Parameters:
void
Returns:

void

This routine initializes the TWI0 module.

This API initializes the I2C_Host driver.

Section: Public functions

Parameters:
void
Returns:

void

Parameters:
none
Returns:

none

Section: Public functions

TWI0_IsBusy()

bool TWI0_IsBusy (void )

This API checks if I2C is busy.

Parameters:
none
Return values:
true

- I2C is busy

false

- I2C is free

TWI0_Read()

bool TWI0_Read (uint16_t address, uint8_t * data, size_t dataLength)

This API reads the data from a client on the bus.

Parameters:
in uint16_t

address - 7-bit / 10-bit Client address.

out uint8_t

*data - pointer to destination data buffer that contains the data to be received

in size_t

dataLength - length of data buffer in number of bytes. Also the number of bytes to be read.

Return values:
true

- The request was placed successfully and the bus activity was initiated

False

- The request fails,if there was already a transfer in progress when this function was called

TWI0_Tasks()

void TWI0_Tasks (void )

This is polling function for non interrupt mode.

Parameters:
none
Returns:

none

This is polling function for non interrupt mode.

Parameters:
void.
Returns:

void

TWI0_Write()

bool TWI0_Write (uint16_t address, uint8_t * data, size_t dataLength)

This API writes data to a Client on the bus.

Parameters:
in uint16_t

address - 7-bit / 10-bit Client address.

in uint8_t

*data - pointer to source data buffer that contains the data to be transmitted.

in size_t

dataLength - length of data buffer in number of bytes. Also the number of bytes to be written.

Return values:
true

- The request was placed successfully and the bus activity was initiated

False

- The request fails,if there was already a transfer in progress when this function was called

TWI0_WriteRead()

bool TWI0_WriteRead (uint16_t address, uint8_t * writeData, size_t writeLength, uint8_t * readData, size_t readLength)

This API writes data from the writeData to the bus and then reads data from the Client and stores the received in the readData.

Parameters:
in uint16_t

address - 7-bit / 10-bit Client address.

out uint8_t

*writeData - pointer to write data buffer.

in size_t

writeLength - write data length in bytes.

in uint8_t

*readData - pointer to read data buffer.

in size_t

readLength - read data length in bytes.

Return values:
true

- The request was placed successfully and the bus activity was initiated

False

- The request fails,if there was already a transfer in progress when this function was called

4.9.1.6 Class Documentation

4.9.1.6.1 i2c_event_status_t Struct Reference

The documentation for this struct was generated from the following file:

source/

i2c_host_event_types.h

Public Attributes

  • bool busy

  • uint16_t address

  • uint8_t * writePtr

  • size_t writeLength

  • uint8_t * readPtr

  • size_t readLength

  • bool switchToRead

  • i2c_host_error_t errorState

  • i2c_event_states_t state

4.9.1.6.2 I2C_TRANSFER_SETUP Struct Reference

Structure for I2C Clock Speed (100KHZ to 1MHZ)

Detailed Description

Structure for I2C Clock Speed (100KHZ to 1MHZ)

The documentation for this struct was generated from the following file:

source/i2c_host_types.h

Public Attributes
  • uint32_t clkSpeed

4.9.1.7 File Documentation

4.9.1.7.1 source/i2c_client_types.h File Reference

Enumerations

Detailed Description

TWI0 Generated Driver API Header File

4.9.1.7.2 source/i2c_host_event_types.h File Reference

#include "i2c_host_types.h"

Enumerations

  • enum i2c_event_states_t { I2C_STATE_IDLE = 0, I2C_STATE_SEND_RD_ADDR, I2C_STATE_SEND_WR_ADDR, I2C_STATE_TX, I2C_STATE_RX, I2C_STATE_NACK, I2C_STATE_ERROR, I2C_STATE_STOP, I2C_STATE_RESET }

    Enumeration for I2C states.

Detailed Description

TWI0 Generated Driver API Header File

4.9.1.7.3 source/twi_client_interrupt.c File Reference

This file contains the driver code for TWI0 module.

#include "../twi0.h"
#include <stdbool.h>
#include "../../system/utils/compiler.h"

Functions

Detailed Description

This file contains the driver code for TWI0 module.

TWI0 Generated Driver File

Version: TWI0 Driver Version 1.1.0

Function Documentation

TWI0_EventHandler()

static void TWI0_EventHandler (void )[static]

Section: Private functions declaration

Variable Documentation

twi0Addr

volatile uint16_t twi0Addr[static]

Section: Private Variable Definitions

4.9.1.7.4 source/twi_client_interrupt.h File Reference

#include <stdbool.h>
#include <stdint.h>
#include "i2c_client_types.h"
#include "i2c_client_interface.h"

Functions

Variables

Detailed Description

TWI0 Generated Driver API Header File

Macro Definition Documentation

i2c_client_client_interface

#define i2c_client_client_interface I2C_Client

Section: Data Type Definitions

Variable Documentation

I2C_Client

const struct I2C_CLIENT_INTERFACE I2C_Client

Section: Driver Interface

4.9.1.7.5 source/twi_client_polling.c File Reference

This file contains the driver code for TWI0 module.

#include "../twi0.h"
#include <stdbool.h>
#include "../../system/utils/compiler.h"

Functions

Detailed Description

This file contains the driver code for TWI0 module.

TWI0 Generated Driver File

Version: TWI0 Driver Version 1.1.0

Function Documentation

TWI0_EventHandler()

static void TWI0_EventHandler (void )[static]

Section: Private functions declaration

Variable Documentation

twi0Addr

volatile uint16_t twi0Addr[static]

Section: Private Variable Definitions

4.9.1.7.6 source/twi_client_polling.h File Reference

#include <stdbool.h>
#include <stdint.h>
#include "i2c_client_types.h"
#include "i2c_client_interface.h"

Functions

Macros

Variables

Detailed Description

TWI0 Generated Driver API Header File

Macro Definition Documentation

i2c_client_client_interface

#define i2c_client_client_interface I2C_Client

Section: Data Type Definitions

Variable Documentation

I2C_Client

const struct I2C_CLIENT_INTERFACE I2C_Client

Section: Driver Interface

4.9.1.7.7 source/twi_host_interrupt.h File Reference

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "i2c_host_types.h"
#include "i2c_host_interface.h"
#include "i2c_host_event_types.h"

Functions

  • void TWI0_Initialize (void)

    This API initializes the I2C_Host driver.

  • void TWI0_Deinitialize (void)

    This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

  • bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)

    This API writes data to a Client on the bus.

  • bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)

    This API reads the data from a client on the bus.

  • bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)

    This API writes data from the writeData to the bus and then reads data from the Client and stores the received in the readData.

  • i2c_host_error_t TWI0_ErrorGet (void)

    This function get the error occurred during I2C Transmit and Receive.

  • bool TWI0_IsBusy (void)

    This API checks if I2C is busy.

  • void TWI0_CallbackRegister (void(*handler)(void))

    Setter function for I2C interrupt callback, This will be called when any error is generated.

  • void TWI0_ErrorCallbackRegister (void(*handler)(void))

    Setter function for I2C Error interrupt callback.

Variables

Detailed Description

TWI0 Generated Driver API Header File

Macro Definition Documentation

i2c_host_host_interface

#define i2c_host_host_interface I2C_Host

Section: Included FilesSection: Data Type Definitions

Variable Documentation

I2C_Host

const i2c_host_interface_t I2C_Host

Section: Driver Interface

4.9.1.7.8 source/twi_host_polling.c File Reference

This file contains the driver code for TWI0 module.

#include "../twi0.h"
#include <stdbool.h>
#include <stdlib.h>
#include "../../system/utils/compiler.h"

Functions

  • static void TWI0_Close (void)

  • static void TWI0_ReadStart (void)

  • static void TWI0_WriteStart (void)

  • static void TWI0_EventHandler (void)

  • static void TWI0_ErrorEventHandler (void)

  • static void TWI0_DefaultCallback (void)

  • static uint8_t TWI0_GetRxData (void)

  • static void TWI0_SendTxData (uint8_t data)

  • static void TWI0_SendTxAddr (uint8_t data)

  • static void TWI0_ClearInterruptFlag (void)

  • static void TWI0_ResetBus (void)

  • static void TWI0_EnableRestart (void)

  • static void TWI0_DisableRestart (void)

  • static void TWI0_SendStop (void)

  • static bool TWI0_IsNack (void)

  • static bool TWI0_IsBusError (void)

  • static bool TWI0_IsData (void)

  • static bool TWI0_IsAddr (void)

  • static void TWI0_ClearErrorFlags (void)

  • static void TWI0_EnableInterrupts (void)

  • static void TWI0_DisableInterrupts (void)

  • static void TWI0_ClearInterrupts (void)

  • static void TWI0_HostSendAck (void)

  • static void TWI0_HostSendNack (void)

  • static bool TWI0_IsArbitrationlostOverride (void)

  • static i2c_event_states_tI2C_EVENT_IDLE (void)

  • static i2c_event_states_tI2C_EVENT_SEND_RD_ADDR (void)

  • static i2c_event_states_tI2C_EVENT_SEND_WR_ADDR (void)

  • static i2c_event_states_tI2C_EVENT_TX (void)

  • static i2c_event_states_tI2C_EVENT_RX (void)

  • static i2c_event_states_tI2C_EVENT_NACK (void)

  • static i2c_event_states_tI2C_EVENT_ERROR (void)

  • static i2c_event_states_tI2C_EVENT_STOP (void)

  • static i2c_event_states_tI2C_EVENT_RESET (void)

  • void TWI0_Initialize (void)

    This routine initializes the TWI0 module.

  • void TWI0_Deinitialize (void)

    This routine Deinitializes the TWI0 module. This function disables the module.

  • bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)

    This API writes data to a Client on the bus.

  • bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)

    This API reads the data from a client on the bus.

  • bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)

    This API writes data from the writeData to the bus and then reads data from the Client and stores the received in the readData.

  • i2c_host_error_t TWI0_ErrorGet (void)

    This function the error occurred during I2C Transmit and Receive.

  • bool TWI0_IsBusy (void)

    This API checks if I2C is busy.

  • void TWI0_CallbackRegister (void(*callbackHandler)(void))

    Setter function for I2C interrupt callback, This will be called when any error is generated.

  • void TWI0_Tasks (void)

    This function is common Polling function for all TWI0 client.

Detailed Description

This file contains the driver code for TWI0 module.

TWI0 Generated Driver File

Version: TWI0 Driver Version 2.1.0

Function Documentation

TWI0_GetRxData()

static uint8_t TWI0_GetRxData (void )[static]

Section: Register Level Interfaces

TWI0_ReadStart()

static void TWI0_ReadStart (void )[static]

Section: Private Interfaces

Variable Documentation

TWI0_Callback

void(* TWI0_Callback) (void) = NULL[static]

Section: Private Variable Definitions

twi0_eventTable

const twi0eventHandler twi0_eventTable[]

Initial value:

= {
    I2C_EVENT_IDLE,
    I2C_EVENT_SEND_RD_ADDR,
    I2C_EVENT_SEND_WR_ADDR,
    I2C_EVENT_TX,
    I2C_EVENT_RX,
    I2C_EVENT_NACK,
    I2C_EVENT_ERROR,
    I2C_EVENT_STOP,
    I2C_EVENT_RESET
}

4.9.1.7.9 source/twi_host_polling.h File Reference

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "i2c_host_types.h"
#include "i2c_host_interface.h"
#include "i2c_host_event_types.h"

Functions

  • void TWI0_Initialize (void)

    This API initializes the I2C_Host driver.

  • void TWI0_Deinitialize (void)

    This API Deinitializes the I2C_Host driver. This routine disables the I2C_Host module.

  • bool TWI0_Write (uint16_t address, uint8_t *data, size_t dataLength)

    This API writes data to a Client on the bus.

  • bool TWI0_Read (uint16_t address, uint8_t *data, size_t dataLength)

    This API reads the data from a client on the bus.

  • bool TWI0_WriteRead (uint16_t address, uint8_t *writeData, size_t writeLength, uint8_t *readData, size_t readLength)

    This API writes data from the writeData to the bus and then reads data from the Client and stores the received in the readData.

  • i2c_host_error_t TWI0_ErrorGet (void)

    This function get the error occurred during I2C Transmit and Receive.

  • bool TWI0_IsBusy (void)

    This API checks if I2C is busy.

  • void TWI0_Tasks (void)

    This is polling function for non interrupt mode.

  • void TWI0_CallbackRegister (void(*handler)(void))

    Setter function for I2C interrupt callback, This will be called when any error is generated.

Macros

Variables

Detailed Description

TWI0 Generated Driver API Header File

Variable Documentation

I2C_Host

const i2c_host_interface_t I2C_Host

Section: Data Type Definitions

Section: Driver Interface