# AVR32 - TWI Driver - Single-Master Mode Documentation

## Introduction

This is the documentation for the data structures, functions, variables, defines, enums, and typedefs for the TWI driver single-master mode example.

The given example uses one evaluation kit for TWI master (EVK1100, EVK1101 or STK1000) and another one for TWI slave (EVK1100 or EVK1101 to program with SLAVE_EXAMPLE).
The TWI master performs a few basic checks and prints the results (PASS/FAIL) on USART1. The checks are:

- the TWI master probes the TWI slave,
- the TWI master performs a write access to the TWI slave,
- the TWI master performs a read access of what it just wrote to the TWI slave,
- the read data are compared with the originally written data.

## Validation Procedure

- Connect a UART monitor on the UART_1 of the board with TWI master
- Connect the TWI master with TWI slave (VCC=VCC,SDA=SDA,SCL=SCL,GND=GND)
- Compile a master and a slave firmware with same configuration (addr mode,speed)
- Program the master and slave boards
- RESET Slave board (=reset TWI memory)
- Release RESET on MASTER board
- on UART, you see all tests PASS
- Release RESET on MASTER board
- on UART, you see always all tests PASS.

## Main Files

- twi.c: TWI driver;
- twi.h: TWI driver header file;
- twi_master_example.c: TWI single-master mode example application.

## Compilation Info

This software is written for GNU GCC for AVR32 and for IAR Embedded Workbench for Atmel AVR32. Other compilers may or may not work.

You can change the following defines but you should make sure that there are the same on the TWI slave side for the tests to pass:

- TWI slave (memory) address (EEPROM_ADDRESS)
- Address of the virtual mem in the EEPROM (VIRTUALMEM_ADDR_START)
- Address length of the EEPROM memory (EEPROM_ADDR_LGT)
- speed in Hz (TWI_SPEED).

## Device Info

All AVR32 devices with a TWI module can be used.

## Configuration Information

This example has been tested with the following configuration:

- EVK1100 or EVK1101 evaluation kit, or STK1000 starter kit;
- CPU clock: 12 MHz;
- USART1 connected to a PC serial port via a standard RS232 DB9 cable;
- PC terminal settings:
  - 57600 bps for EVK1100 or EVK1101, and 115200 bps for STK1000
  - 8 data bits,
  - no parity bit,
  - 1 stop bit,
  - no flow control.

## Contact Information

For further information, visit Atmel AVR32.
Support and FAQ: http://support.atmel.no/