Two-Wire Interface (TWI) driver

Name

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

Overview

The SAM9 processor HAL contains a driver for the Two-Wire Interface (TWI) controller on the SAM9. 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 SAM9's internal Two-Wire Interface (TWI) support. This is controlled within the SAM9 processor HAL (CYGPKG_HAL_SAM9). The CYGPKG_HAL_SAM9_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

Due to the characteristics of the SAM9'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 AT24C512 serial EEPROM fitted to the AT91SAM9260EK board is provided within the tests subdirectory of the CYGPKG_HAL_SAM9 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_SAM9_TEST_TWI_AT24C512 within the SAM9 processor HAL.