comedi_fc.h revision a9f23e00c17567cc4b7ce50cd07226f7bfb70da6
1/* 2 comedi_fc.h 3 4 This is a place for code driver writers wish to share between 5 two or more drivers. These functions are meant to be used only 6 by drivers, they are NOT part of the kcomedilib API! 7 8 Author: Frank Mori Hess <fmhess@users.sourceforge.net> 9 Copyright (C) 2002 Frank Mori Hess 10 11 This program is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2 of the License, or 14 (at your option) any later version. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 25************************************************************************/ 26 27#ifndef _COMEDI_FC_H 28#define _COMEDI_FC_H 29 30#include "../comedidev.h" 31 32/* Writes an array of data points to comedi's buffer */ 33extern unsigned int cfc_write_array_to_buffer(comedi_subdevice * subd, 34 void *data, unsigned int num_bytes); 35 36static inline unsigned int cfc_write_to_buffer(comedi_subdevice * subd, 37 sampl_t data) 38{ 39 return cfc_write_array_to_buffer(subd, &data, sizeof(data)); 40}; 41 42static inline unsigned int cfc_write_long_to_buffer(comedi_subdevice * subd, 43 lsampl_t data) 44{ 45 return cfc_write_array_to_buffer(subd, &data, sizeof(data)); 46}; 47 48extern unsigned int cfc_read_array_from_buffer(comedi_subdevice * subd, 49 void *data, unsigned int num_bytes); 50 51extern unsigned int cfc_handle_events(comedi_device * dev, 52 comedi_subdevice * subd); 53 54static inline unsigned int cfc_bytes_per_scan(comedi_subdevice * subd) 55{ 56 int num_samples; 57 int bits_per_sample; 58 59 switch (subd->type) { 60 case COMEDI_SUBD_DI: 61 case COMEDI_SUBD_DO: 62 case COMEDI_SUBD_DIO: 63 bits_per_sample = 8 * bytes_per_sample(subd); 64 num_samples = 65 (subd->async->cmd.chanlist_len + bits_per_sample - 66 1) / bits_per_sample; 67 break; 68 default: 69 num_samples = subd->async->cmd.chanlist_len; 70 break; 71 } 72 return num_samples * bytes_per_sample(subd); 73} 74 75#endif /* _COMEDI_FC_H */ 76