示例#1
0
文件: io.c 项目: sigvartmh/Xiaomi
int io_init()
{
	int i;
	int res;

	it_g = comedi_open("/dev/comedi0");

	if (it_g == NULL) return -1;

	// init 3 inputs and 3 outputs
	for(i=1; i<4; i++)
	{
		res = comedi_dio_config(it_g, IO_DEV, DI(i), COMEDI_INPUT);
		if (res<0) return res;
		res = comedi_dio_config(it_g, IO_DEV, DO(i), COMEDI_OUTPUT);
		if (res<0) return res;
		res = comedi_dio_write(it_g, IO_DEV, DO(i), 0);
		if (res<0) return res;
	}

	// set outputs to high
	for(i=1; i<4; i++)
	{
		comedi_dio_write(it_g, IO_DEV, DO(i), 1);
	}

	return 1;
}
示例#2
0
 void ComediSubDeviceDOut::setBit( unsigned int bit, bool value)
 {
     if (bit < channels)
         {
             if (value == true)
                 comedi_dio_write( myCard->getDevice()->it,subDevice,bit,1);
             else
                 comedi_dio_write( myCard->getDevice()->it,subDevice,bit,0);
         }
 }
示例#3
0
文件: io.c 项目: sigvartmh/Xiaomi
void io_write(int channel, int value)
{	
	if(channel >= 1 && channel <= 3)
	{
		if(value == 0) comedi_dio_write(it_g, IO_DEV, DO(channel), 0);
		else comedi_dio_write(it_g, IO_DEV, DO(channel), 1);
	}
	else
	{
		printf("Incorrect io channel\n");
	}
}
示例#4
0
void ComediDigitalOutput::write(double data)
{
	// Add the following lines if you need to change between input and output during the same simulation
	//comedi_dio_config(m_device, m_subdevice, m_channels[0],COMEDI_OUTPUT);
	//comedi_set_routing(m_device, m_subdevice, m_channels[0], NI_PFI_OUTPUT_PFI_DO);
	comedi_dio_write(m_device,m_subdevice,m_channels[0], (unsigned int) (data != 0));
}
示例#5
0
文件: comedi.c 项目: manu321/LSE64
static void dio_write( void )
{
	comedi_t *dev = lookup_dev( *sp++ );
	unsigned int subdev = *sp++;
	unsigned int chan = *sp++;
	unsigned int data = *sp++;
	int c = comedi_dio_write( dev, subdev, chan, data );
	if( c < 1 ) comedi_perror( "!dio " );
}
示例#6
0
void com_dio_write(const BYTE * value, unsigned int n, unsigned char bit)
{	//write bit to n output
    comedi_dio_write(it, Comedi_subdev_q, n, bit);
}
示例#7
0
 void ComediSubDeviceDOut::switchOff( unsigned int bit)
 {
     if (bit < channels)
         comedi_dio_write( myCard->getDevice()->it,subDevice,bit,0);
 }