D:/DRISSI/arduino-0022/arduino-0022/libraries/Wire/Wire.h
00001 /*
00002   TwoWire.h - TWI/I2C library for Arduino & Wiring
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 TwoWire_h
00021 #define TwoWire_h
00022 
00023 #include <inttypes.h>
00024 
00025 #define BUFFER_LENGTH 32
00026 
00027 class TwoWire
00028 {
00029   private:
00030     static uint8_t rxBuffer[];
00031     static uint8_t rxBufferIndex;
00032     static uint8_t rxBufferLength;
00033 
00034     static uint8_t txAddress;
00035     static uint8_t txBuffer[];
00036     static uint8_t txBufferIndex;
00037     static uint8_t txBufferLength;
00038 
00039     static uint8_t transmitting;
00040     static void (*user_onRequest)(void);
00041     static void (*user_onReceive)(int);
00042     static void onRequestService(void);
00043     static void onReceiveService(uint8_t*, int);
00044   public:
00045     TwoWire();
00046     void begin();
00047     void begin(uint8_t);
00048     void begin(int);
00049     void beginTransmission(uint8_t);
00050     void beginTransmission(int);
00051     uint8_t endTransmission(void);
00052     uint8_t requestFrom(uint8_t, uint8_t);
00053     uint8_t requestFrom(int, int);
00054     void send(uint8_t);
00055     void send(uint8_t*, uint8_t);
00056     void send(int);
00057     void send(char*);
00058     uint8_t available(void);
00059     uint8_t receive(void);
00060     void onReceive( void (*)(int) );
00061     void onRequest( void (*)(void) );
00062 };
00063 
00064 extern TwoWire Wire;
00065 
00066 #endif
00067