Back to DRIVERS page

AVR UC3 Series Software Framework: Two-wire Interface (TWI) Driver

Copyright © 2006-2008 Atmel Corporation

Introduction

The Two-wire Interface (TWI) interconnects components on a unique two-wire bus. The TWI is programmable as a master or a slave with sequential or single-byte access. Multiple master capability is supported.

 

TWI Software Driver

This driver provides an API to get access to the main features of the TWI controller.

 

Its "philosophy" of usage in single-master mode is:

  • Initialize the TWI controller [twi_master_init()]
  • Test if a chip answers on a given TWI address [twi_probe()]
  • Eventually disable all TWI interrupts [twi_disable_interrupt()]
  • Read multiple bytes from a TWI compatible slave device [twi_master_read()]
  • Write multiple bytes to a TWI compatible slave device [twi_master_write()]

     

    Its "philosophy" of usage in slave mode is:

  • Initialize the TWI controller [twi_slave_init()]
  • The driver will invoke the callback functions specified at initialization for Rx, Tx and Stop events.

     

    The driver is composed of twi.c and twi.h (for accurate API description, read this header file).

     

    TWI Software Driver Examples

    Two examples are currently available:

  • writes then reads bytes to/from an EVK110x emulating an EEPROM thanks to the slave mode example;
  • emulates a TWI EEPROM.
  •  


    AVR is a registered trademark of Atmel Corporation.