コード例 #1
0
int main(int argc, char **argv, char **envp)
{
	int i;
	int sts;
	
	if (argc < 2) {
		printf("Usage: gpio <pin>\n");
		printf("  pin as \"P1_17\"\n" );
		exit(-1);
	}

	GPIO::GPIOManager* gp = GPIO::GPIOManager::getInstance();
	int pin = GPIO::GPIOConst::getInstance()->getGpioByKey(argv[1]);
  
	printf("Pin is %d\n", pin );
	sts = gp->getDirection(pin );
	printf("Direction is %d\n", sts );
	sts = gp->getValue(pin );
	printf("Value is %d\n", sts );
	
	sts = gp->setDirection(pin, 1 );
	for ( i = 0 ; i < 100 ; i++ )
	{
		gp->setValue(pin, (i & 1 ));
		usleep(1000 );
	}

	
	gp->~GPIOManager();
  
	return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: romanix92/dasAuto
int main()
{
  GPIO::GPIOManager* gp = GPIO::GPIOManager::getInstance();
  int pin = GPIO::GPIOConst::getInstance()->getGpioByKey("P8_13");

  gp->exportPin(pin);
  gp->setDirection(pin, GPIO::OUTPUT);
  while(true)    
  {
      sleep(1);
      gp->setValue(pin, GPIO::HIGH);
      sleep(1);
      gp->setValue(pin, GPIO::LOW);
  }
  gp->~GPIOManager();

  return 0;
}