00001 /* 00002 * Modified for Waspmote by A. Bielsa, 2009 00003 * 00004 * Copyright (c) 2006 Nicholas Zambetti. All right reserved. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation, either version 2.1 of the License, or 00009 * (at your option) any later version. 00010 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 00021 #ifndef TwoWire_h 00022 #define TwoWire_h 00023 00024 #include <inttypes.h> 00025 00026 #define BUFFER_LENGTH 32 00027 00028 class TwoWire 00029 { 00030 private: 00031 static uint8_t* rxBuffer; 00032 static uint8_t rxBufferIndex; 00033 static uint8_t rxBufferLength; 00034 00035 static uint8_t txAddress; 00036 static uint8_t* txBuffer; 00037 static uint8_t txBufferIndex; 00038 static uint8_t txBufferLength; 00039 00040 static uint8_t transmitting; 00041 static void (*user_onRequest)(void); 00042 static void (*user_onReceive)(int); 00043 static void onRequestService(void); 00044 static void onReceiveService(uint8_t*, int); 00045 public: 00046 TwoWire(); 00047 void begin(); 00048 void begin(uint8_t); 00049 void begin(int); 00050 void beginTransmission(uint8_t); 00051 void beginTransmission(int); 00052 void endTransmission(void); 00053 void requestFrom(uint8_t, uint8_t); 00054 void requestFrom(int, int); 00055 void send(uint8_t); 00056 void send(uint8_t*, uint8_t); 00057 void send(int); 00058 void send(char*); 00059 uint8_t available(void); 00060 uint8_t receive(void); 00061 void onReceive( void (*)(int) ); 00062 void onRequest( void (*)(void) ); 00063 void close(); 00064 }; 00065 00066 extern TwoWire Wire; 00067 00068 #endif 00069
1.5.6