00001 /*************************************************************************** 00002 di154.cpp - Linux driver for DI-154 series 00003 acquisition device manufactured by 00004 DATAQ Instruments, Inc. 00005 ------------------- 00006 begin : Mon Aug 2 2004 00007 author : Ioan S. Popescu 00008 00009 Copyright (C) 2004 DATAQ Instruments, Inc. <develop@dataq.com> 00010 00011 This program is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU General Public License 00013 as published by the Free Software Foundation; either 00014 version 2 of the License, or (at your option) any later 00015 version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 GNU General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with this program; if not, write to the Free Software 00024 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 ***************************************************************************/ 00026 00027 #include "di154.h" 00028 00042 di154_dsdk::di154_dsdk() 00043 { 00044 chan_order[0] = 0; 00045 m_ADChannelCount = 1; 00046 // create new lists 00047 m_ADChannelList = new int[m_ADChannelCount]; 00048 m_ADMethodList = new int[m_ADChannelCount]; 00049 for(int i=0; i<m_ADChannelCount; i++) 00050 { 00051 m_ADChannelList[i] = i; 00052 m_ADMethodList[i] = IOS_AVERAGE; 00053 chan_order[i] = i * DI194_CHAN_SIZE; 00054 } 00055 00056 digital_chan = false; 00057 00058 m_MaxBurstRate = 240.00; 00059 // set to default sample rate based on channels activated 00060 SampleRate(m_SampleRate); 00061 } 00062 00069 const short int di154_dsdk::convert(const u_int8_t *const di_data, 00070 const u_int8_t num_chan) 00071 { 00072 short int temp = 0; 00073 // extract and convert to counts 00074 // find out whether it's an analog or digital channel 00075 if(m_ADChannelList[num_chan] != -1) // analog channel 00076 { 00077 temp = static_cast<short int>(di_data[chan_order[m_ADChannelList[num_chan]]] 00078 & 0xF7) >> 3; 00079 temp |= (static_cast<short int>(di_data[chan_order[m_ADChannelList[num_chan]]+1] 00080 & 0xFE) << 4); 00081 temp <<= 4; // left justify the number 00082 temp ^= 0x8000; 00083 } 00084 else // digital bits 00085 temp = (di_data[0] & 0x06) >> 1; 00086 00087 return temp; 00088 } 00089