00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2012, Robert Bosch LLC. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the Robert Bosch nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 *********************************************************************/ 00036 00037 /********************************************************************* 00038 * 00039 * Disclaimer 00040 * 00041 * This source code is not officially released or supported by Bosch Sensortec. 00042 * Please contact the listed authors with bugs or other modifications. 00043 * If you would like the official Bosch Sensortec drivers, please contact: 00044 * contact@bosch-sensortec.com 00045 * 00046 *********************************************************************/ 00047 00048 //\Author Joshua Vasquez and Philip Roan, Robert Bosch LLC 00049 00050 #include "bmp085_driver/bmp085_parameters.hpp" 00051 00052 00053 /**********************************************************************/ 00054 // Constructor 00055 /**********************************************************************/ 00056 BMP085Parameters::BMP085Parameters() 00057 { 00058 // set defaults: 00059 this->setFrequency( 400000 ); 00060 this->setProtocol( I2C ); 00061 this->setSamplingMode( STANDARD ); 00062 flags_ = 0; // unused for this sensor since it does not support SPI. 00063 } 00064 00065 00066 /**********************************************************************/ 00067 // Destructor 00068 /**********************************************************************/ 00069 BMP085Parameters::~BMP085Parameters() 00070 { 00071 } 00072 00073 00074 /**********************************************************************/ 00075 /**********************************************************************/ 00076 bool BMP085Parameters::setSamplingMode( sampling_mode mode ) 00077 { 00078 oss_ = mode; 00079 return true; 00080 } 00081 00082 00083 /**********************************************************************/ 00084 /**********************************************************************/ 00085 bool BMP085Parameters::setProtocol( interface_protocol protocol ) 00086 { 00087 // This function must exist since it is an inherited virtual function. 00088 if( protocol != I2C ) 00089 { 00090 ROS_ERROR( "Cannot change protocol from default: I2C. No other protocols are supported."); 00091 return false; 00092 } 00093 else 00094 protocol_ = protocol; 00095 00096 return true; 00097 } 00098 00099 00100 /**********************************************************************/ 00101 /**********************************************************************/ 00102 bool BMP085Parameters::setFrequency( int frequency ) 00103 { 00104 frequency_ = frequency; 00105 return true; 00106 } 00107 00108 00109 /**********************************************************************/ 00110 /**********************************************************************/ 00111 interface_protocol BMP085Parameters::getProtocol() 00112 { 00113 return protocol_; 00114 } 00115 00116 00117 /**********************************************************************/ 00118 /**********************************************************************/ 00119 int BMP085Parameters::getFrequency() 00120 { 00121 return frequency_; 00122 } 00123 00124 00125 /**********************************************************************/ 00126 /**********************************************************************/ 00127 bool BMP085Parameters::setPin( uint8_t pin) 00128 { 00129 pin_ = pin; 00130 return true; 00131 } 00132 00133 00134 /**********************************************************************/ 00135 /**********************************************************************/ 00136 int BMP085Parameters::getPin() 00137 { 00138 return pin_; 00139 } 00140 00141 00142 /**********************************************************************/ 00143 /**********************************************************************/ 00144 int* BMP085Parameters::getFlags() 00145 { 00146 return &flags_; 00147 } 00148 00149 00150 /**********************************************************************/ 00151 /**********************************************************************/ 00152 BMP085Parameters::sampling_mode BMP085Parameters::getSamplingMode() 00153 { 00154 return oss_; 00155 }