Two-Wire Interface (TWI) driver

Name

Two-Wire Interface (TWI) driver -- Configuration and implementation details of TWI (I²C®) driver

Overview

The AT91RM9200 processor HAL contains a driver for the Two-Wire Interface (TWI) controller on the AT91RM9200. This type of bus is also known as I²C®. The API for this may be found within the CYGPKG_IO_I2C package.

I²C®/TWI driver configuration

The I²C® driver uses the AT91RM9200's internal Two-Wire Interface (TWI) support. This is controlled within the AT91RM9200 processor HAL (CYGPKG_HAL_AT91RM9200). The CYGPKG_HAL_AT91RM9200_TWI CDL component controls whether the TWI driver is enabled. Within that component, there are two sub-options:

To use the I²C/TWI driver, the generic I²C driver package CYGPKG_IO_I2C must be used. Documentation for its API may be found elsewhere.

Usage notes

This driver only operates in interrupt mode. It does not operate in polled mode, and thus does not operate when interrupts are disabled. It cannot therefore be used in an initialization context, before the eCos kernel thread scheduler starts. And it cannot be used with RedBoot.

Due to the characteristics of the AT91RM9200's operation, it is not possible to provide support for repeated starts with the I²C package API. Similarly indicating a NACK when performing a receive is equivalent to also sending a STOP.

A test application for use with the Aardvark I²C/SPI Activity Board is provided within the tests subdirectory of the CYGPKG_HAL_AT91RM9200 package. This test communicates with the I²C EEPROM on the board to perform read and write operations using I²C. This test is not built by default. It may be built by enabling the configuration option CYGBLD_HAL_ARM_ARM9_AT91RM9200_TEST_TWI_AT24C02A within the AT91RM9200 processor HAL.