/* * Digital I/O example * Part of Comedilib * * Copyright (c) 1999,2000 David A. Schleef * * This file may be freely modified, distributed, and combined with * other software, as long as proper attribution is given in the * source code. */ /* * Requirements: A board with a digital I/O subdevice. Not just * a 'digital input' or 'digital output' subdevice, but one in * which the channels can be configured between input and output. */ #include #include #include #include #include #include #include "examples.h" int chan_dat = 1; int chan_clk = 0; int wait1 = usec_to_nsec(0); int wait2 = usec_to_nsec(0); comedi_t *device; void write_bits(int bits); int main(int argc, char *argv[]) { int ret; int stype; int i; parse_options(argc,argv); device=comedi_open(filename); if(!device){ comedi_perror(filename); exit(0); } subdevice = 2; stype = comedi_get_subdevice_type(device,subdevice); if(stype!=COMEDI_SUBD_DIO){ printf("%d is not a digital I/O subdevice\n",subdevice); exit(0); } printf("configuring pin %d for output...\n",chan_dat); ret=comedi_dio_config(device,subdevice,chan_dat,COMEDI_OUTPUT); printf("configuring pin %d for output...\n",chan_clk); ret=comedi_dio_config(device,subdevice,chan_clk,COMEDI_OUTPUT); for(i=0;i<0x100;i++){ write_bits(i); } //write_bits(0xa5); return 0; } void write_bits(int bits) { comedi_insnlist il; comedi_insn insn[5]; lsampl_t data[10]; int mask = (1<