Synergia AVR 0.1
|
00001 /* 00002 Copyright (c) 2010 Tymon Tobolski 00003 00004 Permission is hereby granted, free of charge, to any person obtaining 00005 a copy of this software and associated documentation files (the 00006 "Software"), to deal in the Software without restriction, including 00007 without limitation the rights to use, copy, modify, merge, publish, 00008 distribute, sublicense, and/or sell copies of the Software, and to 00009 permit persons to whom the Software is furnished to do so, subject to 00010 the following conditions: 00011 00012 The above copyright notice and this permission notice shall be 00013 included in all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00016 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00018 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00019 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00020 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00021 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00022 */ 00023 00024 #include "rfm12b.h" 00025 00026 void RFM12B_Base::writeCmd(unsigned int cmd); 00027 00028 void RFM12B_Base::portInit(); 00029 00030 void RFM12B_Base::init(); 00031 00032 void RFM12B_Base::sendByte(unsigned char data); 00033 00034 void RFM12B_Base::sendPackage(); 00035 00036 unsigned char RFM12B_Base::receive(); 00037 00038 void RFM12B_Base::operator<<(unsigned char c){ 00039 buffer[buffer_pos] = c; // add to buffer 00040 buffer_pos++; 00041 00042 // send package if buffer is full 00043 if(buffer_pos >= 16) { 00044 sendPackage(); 00045 buffer_pos = 0; 00046 } 00047 return *this; 00048 } 00049 00050 00051 void RFM12B_Base::operator<<(char* string){ 00052 while (*string != '\0') sendByte(*string++); 00053 return *this; 00054 } 00055 00056 00057 void RFM12B_Base::flush(){ 00058 // fill buffer with zeros 00059 for(int i = buffer_pos; i < 16; i++){ 00060 buffer[i] = 0; 00061 } 00062 00063 sendPackage(); 00064 buffer_pos = 0; 00065 }