twislave.c File Reference

I2C slave library. More...

#include <util/twi.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include "twislave.h"

Go to the source code of this file.

Defines

#define TWCR_ACK   TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWINT) | (1 << TWEA) | (0 << TWSTA) | (0 << TWSTO) | (0 << TWWC);
#define TWCR_NACK   TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWINT) | (0 << TWEA) | (0 << TWSTA) | (0 << TWSTO) | (0 << TWWC);
#define TWCR_RESET   TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWINT) | (1 << TWEA) | (0 << TWSTA) | (0 << TWSTO) | (0 << TWWC);

Functions

void init_twi_slave (uint8_t adr)
 Initalisierung des TWI-Interface.
 ISR (TWI_vect)
 ISR, die bei einem Ereignis auf dem Bus ausgeloest wird.

Variables

volatile uint8_t buffer_adr


Detailed Description

I2C slave library.

taken from http://www.roboternetz.de/wissen/index.php/TWI_Slave_mit_avr-gcc

Author:
Uwe Grosse-Wortmann (uwegw), reformatted by Ronald Schaten <ronald@schatenseite.de>
Version:
Id
twislave.c,v 1.1 2008/07/16 05:44:45 rschaten Exp

License: GNU GPL v2 (see License.txt)

Definition in file twislave.c.


Define Documentation

#define TWCR_ACK   TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWINT) | (1 << TWEA) | (0 << TWSTA) | (0 << TWSTO) | (0 << TWWC);

Definition at line 49 of file twislave.c.

Referenced by ISR().

#define TWCR_NACK   TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWINT) | (0 << TWEA) | (0 << TWSTA) | (0 << TWSTO) | (0 << TWWC);

Definition at line 51 of file twislave.c.

Referenced by ISR().

#define TWCR_RESET   TWCR = (1 << TWEN) | (1 << TWIE) | (1 << TWINT) | (1 << TWEA) | (0 << TWSTA) | (0 << TWSTO) | (0 << TWWC);

Definition at line 53 of file twislave.c.

Referenced by ISR().


Function Documentation

void init_twi_slave ( uint8_t  adr  ) 

Initalisierung des TWI-Interface.

Muss zu Beginn aufgerufen werden, sowie bei einem Wechsel der Slave Adresse.

Parameters:
adr gewuenschte Slave-Adresse

Definition at line 37 of file twislave.c.

References buffer_adr.

Referenced by main().

ISR ( TWI_vect   ) 

ISR, die bei einem Ereignis auf dem Bus ausgeloest wird.

Im Register TWSR befindet sich dann ein Statuscode, anhand dessen die Situation festgestellt werden kann.

Definition at line 63 of file twislave.c.

References buffer_adr, buffer_size, rxbuffer, TWCR_ACK, TWCR_NACK, TWCR_RESET, and txbuffer.


Variable Documentation

volatile uint8_t buffer_adr

Definition at line 30 of file twislave.c.

Referenced by init_twi_slave(), and ISR().


Generated on Wed May 6 20:07:40 2009 for I2C LED Matrix by  doxygen 1.5.7.1