D:/DRISSI/arduino-0022/arduino-0022/libraries/Wire/utility/twi.h
00001 /*
00002   twi.h - TWI/I2C library for Wiring & Arduino
00003   Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 */
00019 
00020 #ifndef twi_h
00021 #define twi_h
00022 
00023   #include <inttypes.h>
00024 
00025   //#define ATMEGA8
00026 
00027   #ifndef CPU_FREQ
00028   #define CPU_FREQ 16000000L
00029   #endif
00030 
00031   #ifndef TWI_FREQ
00032   #define TWI_FREQ 100000L
00033   #endif
00034 
00035   #ifndef TWI_BUFFER_LENGTH
00036   #define TWI_BUFFER_LENGTH 32
00037   #endif
00038 
00039   #define TWI_READY 0
00040   #define TWI_MRX   1
00041   #define TWI_MTX   2
00042   #define TWI_SRX   3
00043   #define TWI_STX   4
00044   
00045   void twi_init(void);
00046   void twi_setAddress(uint8_t);
00047   uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t);
00048   uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t);
00049   uint8_t twi_transmit(uint8_t*, uint8_t);
00050   void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
00051   void twi_attachSlaveTxEvent( void (*)(void) );
00052   void twi_reply(uint8_t);
00053   void twi_stop(void);
00054   void twi_releaseBus(void);
00055 
00056 #endif
00057