RTXI 1.3
comedi/comedi/drivers/ni_labpc.h
Go to the documentation of this file.
00001 /*
00002     ni_labpc.h
00003 
00004     Header for ni_labpc.c and ni_labpc_cs.c
00005 
00006     Copyright (C) 2003 Frank Mori Hess <fmhess@users.sourceforge.net>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 
00022 */
00023 
00024 #ifndef _NI_LABPC_H
00025 #define _NI_LABPC_H
00026 
00027 #define EEPROM_SIZE     256     // 256 byte eeprom
00028 #define NUM_AO_CHAN     2       // boards have two analog output channels
00029 
00030 enum labpc_bustype { isa_bustype, pci_bustype, pcmcia_bustype };
00031 enum labpc_register_layout { labpc_plus_layout, labpc_1200_layout };
00032 enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer,
00033                 isa_dma_transfer };
00034 
00035 typedef struct labpc_board_struct {
00036         const char *name;
00037         int device_id;          // device id for pci and pcmcia boards
00038         int ai_speed;           // maximum input speed in nanoseconds
00039         enum labpc_bustype bustype;     // ISA/PCI/etc.
00040         enum labpc_register_layout register_layout;     // 1200 has extra registers compared to pc+
00041         int has_ao;             // has analog output true/false
00042         const comedi_lrange *ai_range_table;
00043         const int *ai_range_code;
00044         const int *ai_range_is_unipolar;
00045         unsigned ai_scan_up:1;  // board can auto scan up in ai channels, not just down
00046         unsigned memory_mapped_io:1;    /* uses memory mapped io instead of ioports */
00047 } labpc_board;
00048 
00049 typedef struct {
00050         struct mite_struct *mite;       // for mite chip on pci-1200
00051         volatile unsigned long long count;      /* number of data points left to be taken */
00052         unsigned int ao_value[NUM_AO_CHAN];     // software copy of analog output values
00053         // software copys of bits written to command registers
00054         volatile unsigned int command1_bits;
00055         volatile unsigned int command2_bits;
00056         volatile unsigned int command3_bits;
00057         volatile unsigned int command4_bits;
00058         volatile unsigned int command5_bits;
00059         volatile unsigned int command6_bits;
00060         // store last read of board status registers
00061         volatile unsigned int status1_bits;
00062         volatile unsigned int status2_bits;
00063         unsigned int divisor_a0;        /* value to load into board's counter a0 (conversion pacing) for timed conversions */
00064         unsigned int divisor_b0;        /* value to load into board's counter b0 (master) for timed conversions */
00065         unsigned int divisor_b1;        /* value to load into board's counter b1 (scan pacing) for timed conversions */
00066         unsigned int dma_chan;  // dma channel to use
00067         u16 *dma_buffer;        // buffer ai will dma into
00068         unsigned int dma_transfer_size; // transfer size in bytes for current transfer
00069         enum transfer_type current_transfer;    // we are using dma/fifo-half-full/etc.
00070         unsigned int eeprom_data[EEPROM_SIZE];  // stores contents of board's eeprom
00071         unsigned int caldac[16];        // stores settings of calibration dacs
00072         // function pointers so we can use inb/outb or readb/writeb as appropriate
00073         unsigned int (*read_byte) (unsigned long address);
00074         void (*write_byte) (unsigned int byte, unsigned long address);
00075 } labpc_private;
00076 
00077 int labpc_common_attach(comedi_device * dev, unsigned long iobase,
00078         unsigned int irq, unsigned int dma);
00079 int labpc_common_detach(comedi_device * dev);
00080 
00081 extern const int labpc_1200_is_unipolar[];
00082 extern const int labpc_1200_ai_gain_bits[];
00083 extern const comedi_lrange range_labpc_1200_ai;
00084 
00085 #endif /* _NI_LABPC_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines