• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OUT_GPIO函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OUT_GPIO函数的典型用法代码示例。如果您正苦于以下问题:C++ OUT_GPIO函数的具体用法?C++ OUT_GPIO怎么用?C++ OUT_GPIO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OUT_GPIO函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
  int g,rep, i;
 
  // Set up gpi pointer for direct register access
  wiringPiSetupGpio ();
  setup_io();
  for (i = 0; i < 28; i++)
  {
	  INP_GPIO(i);
	  printf("%d", GET_GPIO(i));
  }
  printf("\n");
  //exit(0);
  OUT_GPIO(INT); GPIO_SET(INT);
  OUT_GPIO(NMI); GPIO_SET(NMI);
  OUT_GPIO(CLK); GPIO_SET(CLK);
  OUT_GPIO(WAIT); GPIO_SET(WAIT);
  OUT_GPIO(BUSRQ); GPIO_SET(BUSRQ);
  OUT_GPIO(RESET); GPIO_SET(RESET);
  OUT_GPIO(SI); GPIO_SET(SI);
  OUT_GPIO(CP); GPIO_SET(CP);
  OUT_GPIO(CS_16); GPIO_SET(CS_16);
  OUT_GPIO(M); 
  ResetSimulationVars();  
  WriteControlPins();
  DoReset();
  
  while(1)
	  loop();
}
开发者ID:meesokim,项目名称:spc1000,代码行数:31,代码来源:gpioex.c


示例2: initMotor

void initMotor(OUT_MOTOR* motor, char * n1, char* n2, char * file, int pinPWM, int pinIN1, int pinIN2, int pinSTBY, double vitesse){
	motor->cap = fopen(file,"r");

	motor->pinSTBY = pinSTBY;
	motor->pinIN1 = pinIN1;
	motor->pinIN2= pinIN2;
	motor->pinPWM=pinPWM;

	INP_GPIO(pinIN1);
	INP_GPIO(pinIN2);
	INP_GPIO(pinSTBY);
	INP_GPIO(pinPWM);

	OUT_GPIO(pinIN1);
	OUT_GPIO(pinIN2);
	OUT_GPIO(pinSTBY);
	OUT_GPIO(pinPWM); 
	GPIO_SET = 1 << pinSTBY;
	GPIO_CLR = 1 << pinIN1 | 1 << pinIN2 | 1<< pinPWM;

	motor->vitesse=vitesse;
	int err = rt_task_create(&(motor->task),n1, TASK_STKSZ, TASK_PRIO, TASK_MODE);
	err |= rt_alarm_create(&(motor->alarm),n2);
	err |= rt_task_set_periodic(&(motor->task), TM_NOW, PERIODE_MOTOR);
	if (!err) {
		rt_task_start(&(motor->task),&taskMotor,motor);
	}

}
开发者ID:ilai-deutel,项目名称:SLAMing-robot,代码行数:29,代码来源:motor.c


示例3: main

int main(int argc, char **argv) {
	//int rep;

	// Set up gpi pointer for direct register access
	setup_io();

	// GPIO23 - NTX2 enable
	INP_GPIO(23); // must use INP_GPIO before we can use OUT_GPIO
	OUT_GPIO(23);
	// GPIO18 - NTX2 Data	
	INP_GPIO(18); // must use INP_GPIO before we can use OUT_GPIO
	OUT_GPIO(18);


	GPIO_SET = 1<<23;

	char send[]="I'm growing a beard\n";

	//for (rep=0; rep<8; rep++) {
		int i;
		for (i=0; i<strlen(send); i++){
			domex_txbyte(send[i]);
		}
	//}
	GPIO_CLR = 1<<23;
	return 0;

}
开发者ID:MAkcanca,项目名称:Sandals,代码行数:28,代码来源:dom16.c


示例4: bcm2835gpio_init

static int bcm2835gpio_init(void)
{
	bitbang_interface = &bcm2835gpio_bitbang;

	if (!is_gpio_valid(tdo_gpio) || !is_gpio_valid(tdi_gpio) ||
		!is_gpio_valid(tck_gpio) || !is_gpio_valid(tms_gpio) ||
		(trst_gpio != -1 && !is_gpio_valid(trst_gpio)) ||
		(srst_gpio != -1 && !is_gpio_valid(srst_gpio)))
		return ERROR_JTAG_INIT_FAILED;

	dev_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
	if (dev_mem_fd < 0) {
		perror("open");
		return ERROR_JTAG_INIT_FAILED;
	}

	pio_base = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE,
				MAP_SHARED, dev_mem_fd, BCM2835_GPIO_BASE);

	if (pio_base == MAP_FAILED) {
		perror("mmap");
		close(dev_mem_fd);
		return ERROR_JTAG_INIT_FAILED;
	}

	tdo_gpio_mode = MODE_GPIO(tdo_gpio);
	tdi_gpio_mode = MODE_GPIO(tdi_gpio);
	tck_gpio_mode = MODE_GPIO(tck_gpio);
	tms_gpio_mode = MODE_GPIO(tms_gpio);
	/*
	 * Configure TDO as an input, and TDI, TCK, TMS, TRST, SRST
	 * as outputs.  Drive TDI and TCK low, and TMS/TRST/SRST high.
	 */
	INP_GPIO(tdo_gpio);

	GPIO_CLR = 1<<tdi_gpio | 1<<tck_gpio;
	GPIO_SET = 1<<tms_gpio;

	OUT_GPIO(tdi_gpio);
	OUT_GPIO(tck_gpio);
	OUT_GPIO(tms_gpio);
	if (trst_gpio != -1) {
		trst_gpio_mode = MODE_GPIO(trst_gpio);
		GPIO_SET = 1 << trst_gpio;
		OUT_GPIO(trst_gpio);
	}
	if (srst_gpio != -1) {
		srst_gpio_mode = MODE_GPIO(srst_gpio);
		GPIO_SET = 1 << srst_gpio;
		OUT_GPIO(srst_gpio);
	}

	LOG_DEBUG("saved pinmux settings: tck %d tms %d tdi %d "
		  "tdo %d trst %d srst %d", tck_gpio_mode, tms_gpio_mode,
		  tdi_gpio_mode, tdo_gpio_mode, trst_gpio_mode, srst_gpio_mode);

	return ERROR_OK;
}
开发者ID:Oridorichard,项目名称:openocd_osbdm,代码行数:58,代码来源:bcm2835gpio.c


示例5: printf

// Initialize pins/SPI for output
static PyObject *begin(DotStarObject *self) {
	if(self->dataPin == 0xFF) { // Use hardware SPI
		if((self->fd = open("/dev/spidev0.0", O_RDWR)) < 0) {
			printf("Can't open /dev/spidev0.0 (try 'sudo')\n");
			return NULL;
		}
		uint8_t mode = SPI_MODE_0 | SPI_NO_CS;
		ioctl(self->fd, SPI_IOC_WR_MODE, &mode);
		// The actual data rate may be less than requested.
		// Hardware SPI speed is a function of the system core
		// frequency and the smallest power-of-two prescaler
		// that will not exceed the requested rate.
		// e.g. 8 MHz request: 250 MHz / 32 = 7.8125 MHz.
		ioctl(self->fd, SPI_IOC_WR_MAX_SPEED_HZ, self->bitrate);
		xfer[0].tx_buf = (unsigned long)header;
		xfer[2].tx_buf = (unsigned long)footer;
		xfer[0].speed_hz = xfer[1].speed_hz = xfer[2].speed_hz =
		  self->bitrate;
	} else { // Use bitbang "soft" SPI (any 2 pins)
		if(gpio == NULL) { // First time accessing GPIO?
			int fd;

			if((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) {
				printf("Can't open /dev/mem (try 'sudo')\n");
				return NULL;
			}
			isPi2 = (boardType() == 2);
			gpio  = (volatile unsigned *)mmap( // Memory-map I/O
			  NULL,                 // Any adddress will do
			  BLOCK_SIZE,           // Mapped block length
			  PROT_READ|PROT_WRITE, // Enable read+write
			  MAP_SHARED,           // Shared w/other processes
			  fd,                   // File to map
			  isPi2 ?
			   PI2_GPIO_BASE :      // -> GPIO registers
			   PI1_GPIO_BASE);
			close(fd);              // Not needed after mmap()
			if(gpio == MAP_FAILED) {
				err("Can't mmap()");
				return NULL;
			}
			gpioSet = &gpio[7];
			gpioClr = &gpio[10];
		}

		self->dataMask  = 1 << self->dataPin;
		self->clockMask = 1 << self->clockPin;

		// Set 2 pins as outputs.  Must use INP before OUT.
		INP_GPIO(self->dataPin);  OUT_GPIO(self->dataPin);
		INP_GPIO(self->clockPin); OUT_GPIO(self->clockPin);

		*gpioClr = self->dataMask | self->clockMask; // data+clock LOW
	}

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:TobiBu,项目名称:POV,代码行数:59,代码来源:dotstar.c


示例6: init

void init(uint8_t dataPin, uint8_t clockPin) {
    setup_io();

    INP_GPIO(dataPin); // must use INP_GPIO before we can use OUT_GPIO
    OUT_GPIO(dataPin);

    INP_GPIO(clockPin); // must use INP_GPIO before we can use OUT_GPIO
    OUT_GPIO(clockPin);
}
开发者ID:PedalPi,项目名称:Physical,代码行数:9,代码来源:native_bitbang.c


示例7: userApp1

void userApp1(void * args)
{
    int n_pin;
    // set all the seg not to illume
    for (n_pin = 0; n_pin < 8; ++n_pin){
        INP_GPIO(pin[n_pin]);
        OUT_GPIO(pin[n_pin]);
        digitalWrite(pin[n_pin], HIGH);
    }

    // set all the node not to off 
    for(n_pin = 0; n_pin < 4; ++n_pin){
        INP_GPIO(node[n_pin]);
        OUT_GPIO(node[n_pin]);
        digitalWrite(node[n_pin], LOW);
    }

    INP_GPIO(16);
    OUT_GPIO(16);

    int i_node = 0;
    int disp_buffer[4] = {5, 0, 5, 0};
    int disp_num = 0;
    int last_dht11_dat0 = dht11_dat[0], last_dht11_dat2 = dht11_dat[2];

    int i, update_flag;

	while(1)
	{
        if(last_dht11_dat0 != dht11_dat[0] || last_dht11_dat2 != dht11_dat[2]){
            disp_buffer[1] = dht11_dat[0]%10;
            disp_buffer[0] = dht11_dat[0]/10;
            disp_buffer[3] = dht11_dat[2]%10;
            disp_buffer[2] = dht11_dat[2]/10;
        }

        last_dht11_dat0 = dht11_dat[0];
        last_dht11_dat2 = dht11_dat[2];

        digitalWrite(node[i_node], LOW);
        i_node = (i_node+1) % 4; 
        disp_num = disp_buffer[i_node];

        for(n_pin = 0; n_pin < 8; ++n_pin){
            digitalWrite(pin[n_pin], digit[disp_num][n_pin]);
        } 

        digitalWrite(node[i_node], HIGH);

        //wtf_delay(100);
        OSTimeDly(1);
	}
}
开发者ID:manfred-exz,项目名称:ucos_dht11_disp,代码行数:53,代码来源:userApp.c


示例8: setup_shiftreg

void setup_shiftreg()
{
  // set SER to output
  INP_GPIO(SER);
  OUT_GPIO(SER);
  // set SCLK to output
  INP_GPIO(SCLK);
  OUT_GPIO(SCLK);
  // set RCLK to output
  INP_GPIO(RCLK);
  OUT_GPIO(RCLK);
}
开发者ID:tvitti-cbtn,项目名称:rpi-stoplight,代码行数:12,代码来源:stoplight.c


示例9: main

int main(int argc, char **argv)
{
#ifdef DEMO_ENABLED
  int g,rep;
#endif

  /* Set up gpi pointer for direct register access */
  setup_io();
#ifndef DEMO_ENABLED  
  /* Set GPIO pin 4 to output */
  INP_GPIO(pin); 
  OUT_GPIO(pin);
#else
  /* Set all exposed GPIO pins to output */
  for (g = 0; g <= 32; g++)
  {
    if( ((1<<g) & 0x3e6cf93) != 0)
    {
      INP_GPIO(g);
      OUT_GPIO(g);
    }
  }
  GPIO_CLR = 0x3e6cf93; //clear all output pins
#endif

#ifdef DEMO_ENABLED
  while (1)
  {
    for (rep = 0; rep < 14; rep++)
    { 
      GPIO_SET = 1<<pins[rep];
      printf("Set pin: %d\n", pins[rep]);
      sleep(1);
      GPIO_CLR = 1<<pins[rep];
      printf("Clear pin: %d\n", pins[rep]);
      sleep(1);
    }
  }
#else
  while (1)
  {
    GPIO_SET = 1<<pin;
    printf("Set pin: %d\n", pin);
    sleep(1);
    GPIO_CLR = 1<<pin;
    printf("Clear pin: %d\n", pin);
    sleep(1);
  }
#endif

  return 0;
}
开发者ID:VaduvaAlexandru,项目名称:daisypi,代码行数:52,代码来源:led.c


示例10: main

int main()
{

int g,rep;
setup_io(); /*Direct Register access*/

#if 0
/*Set gpio 7..11 to outpu mode*/
for(g=7; g <= 18; g++)
{
 INP_GPIO(g);
 OUT_GPIO(g);

} 
#endif

INP_GPIO(17);
OUT_GPIO(17);

while(1)
{
 GPIO_SET = 1 << 17;
 //delay(500);
 sleep(1);
 GPIO_CLR = 1 << 17;
 //delay(500);
 sleep(1);

}

#if 0
for (rep=0; rep=10; rep++)
{  
  for(g=7; g <= 11; g++)
   {
      GPIO_SET = 1 << g;
      sleep(1);
   }
  for(g=7; g<= 11; g++)
  {
      GPIO_CLR = 1 << g;
      sleep(1); 
  } 
}


#endif

}
开发者ID:malleshkoujalagi,项目名称:gpio,代码行数:49,代码来源:RPi_gpio.c


示例11: rpi_gpio_open

int rpi_gpio_open(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int oflags)
{
  struct rpi_gpio_context *ctx;
  
  ctx = (struct rpi_gpio_context *) context->dev_private;
  ctx->gpio_addr = virt_addr;
  ctx->gpio_rt = gpio_rt;
  ctx->gpio_nrt = gpio_nrt;


  OUT_GPIO(ctx->gpio_addr, ctx->gpio_rt);
  OUT_GPIO(ctx->gpio_addr, ctx->gpio_nrt);

  return 0;
}
开发者ID:pficheux,项目名称:raspberry_pi,代码行数:15,代码来源:rpi_gpio_rtdm.c


示例12: init_module

/** 
 * init_module() - This function is called when the module is loaded
 * 
 * Return: On succes the function retuns a 0 (SUCCES). Otherwise a 
 * negative number is returned.
 */
int init_module(void)
{
	Major = register_chrdev(0, DEVICE_NAME, &fops);
	if (Major < 0) 
	{
		printk(KERN_ALERT "Registering char device failed with %d\n", Major);
		return Major;
	}
    
	printk(KERN_INFO "I was assigned major number %d. To talk to\n", Major);
	printk(KERN_INFO "the driver, create a device file with\n");
        
	printk(KERN_INFO "'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major);
	printk(KERN_INFO "Try various minor numbers. Try to cat and echo to\n");
	printk(KERN_INFO "the device file.\n");
	printk(KERN_INFO "Remove the device file and module when done.\n");
    
    // Map GPIO
    gpio.map = ioremap(GPIO_BASE, 1); //Gives a pointer to the first GPIO register
	gpio.addr = (volatile unsigned int *)gpio.map;

	// Set pin directions for the LED
    INP_GPIO(GPIO_LED);
	OUT_GPIO(GPIO_LED);
    
	return SUCCESS;
}
开发者ID:bartjanisse,项目名称:BeerTender,代码行数:33,代码来源:helloled2.c


示例13: gpioSetPin

//
// Configure GPIOs as input or output
//
void gpioSetPin(uint8_t pin, uint8_t dir) {

  // Set pin number to given direction
  INP_GPIO(pin);  // Must make pin an input first, even for output
  if (dir == GPIO_OUTPUT)
    OUT_GPIO(pin);
}
开发者ID:stantheman286,项目名称:scraptcha,代码行数:10,代码来源:led.c


示例14: main

int 
main()
{
	if(init_gpio() == -1) 
	{
		printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
        return (-1);
    }
	
	printf("Helloblink is started with GIOP%d at pin number 8.\n", LED_PIN);
	
	// Define gpio 4 (LED) as output
	INP_GPIO(LED_PIN);
	OUT_GPIO(LED_PIN);

	while(1)
	{
		GPIO_SET(LED_PIN);
		usleep(100 * 1000);
	
		GPIO_CLR(LED_PIN);
		usleep(100 * 1000);
	}

	return 0;	
}
开发者ID:bartjanisse,项目名称:BeerTender,代码行数:26,代码来源:helloled.c


示例15: printf

bool HWAbstraction::setupIO() {
    int memFd;
    /* open /dev/mem */
    if ((memFd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
        printf("can't open /dev/mem \n");
        return false;
    }

    /* mmap GPIO */
    m_gpioMap = mmap(
                    NULL,             //Any adddress in our space will do
                    BLOCK_SIZE,       //Map length
                    PROT_READ|PROT_WRITE,// Enable reading & writting to mapped memory
                    MAP_SHARED,       //Shared with other processes
                    memFd,           //File to map
                    GPIO_BASE         //Offset to GPIO peripheral
                );

    close(memFd); //No need to keep mem_fd open after mmap

    if (m_gpioMap == MAP_FAILED) {
        printf("mmap error %p\n", m_gpioMap);//errno also set!
        return false;
    }

    // Always use volatile pointer!
    m_gpio = (volatile unsigned *)m_gpioMap;
    INP_GPIO(25);
    OUT_GPIO(25);

    return true;
} // setup_io
开发者ID:vitorboschi,项目名称:libNRF24L01p,代码行数:32,代码来源:HWAbstraction.cpp


示例16: main

int main()
{
	int ch;
	if (map_peripheral(&gpio) == -1) {
		printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
		return -1;
	}

	// Define pin as output
	INP_GPIO(PIN);
	OUT_GPIO(PIN);

	BIT1();
	while((ch = getchar()) != EOF) {
		short bit;
		usleep(4000);
		BIT0(); // start
		usleep(BITLEN);
		for (bit = 1; bit != 0x100; bit <<= 1) {
			if (bit & ch) BIT1(); else BIT0();
			usleep(BITLEN);
		}
		BIT1(); // stop
		usleep(BITLEN);
	}

	return 0;
}
开发者ID:hsbp,项目名称:seg7tiny,代码行数:28,代码来源:rpi.c


示例17: pinMode

inline void pinMode(int g, int dir)
{
	if (dir == OUTPUT)
		OUT_GPIO(g);
	else
		INP_GPIO(g);
}
开发者ID:meesokim,项目名称:spc1000,代码行数:7,代码来源:gpioex.c


示例18: WriteByte

void WriteByte(unsigned char value)
{
  unsigned char Mask=1;
  int loop;

   for(loop=0;loop<8;loop++)
     {
       INP_GPIO(DS_PIN);
       OUT_GPIO(DS_PIN);
       GPIO_CLR= 1 <<DS_PIN;

       if((value & Mask)!=0)
        {
           DELAY1US
            INP_GPIO(DS_PIN);
           DelayMicrosecondsNoSleep(60);

        }
        else
        {
           DelayMicrosecondsNoSleep(60);
           INP_GPIO(DS_PIN);
           DelayMicrosecondsNoSleep(1);
        }
      Mask*=2;
      DelayMicrosecondsNoSleep(60);
    }


   usleep(100);
}
开发者ID:SimplyAutomationized,项目名称:BitBangingDS18B20,代码行数:31,代码来源:DS18B20Scan.c


示例19: ReadByte

unsigned char ReadByte(void)
{

   unsigned char Mask=1;
   int loop;
   unsigned  char data=0;

  int loop2;


   for(loop=0;loop<8;loop++)
     {
       //  set output
       INP_GPIO(DS_PIN);
       OUT_GPIO(DS_PIN);
       //  PIN LOW
       GPIO_CLR= 1<<DS_PIN;
       DELAY1US
       //  set input
       INP_GPIO(DS_PIN);
       // Wait  2 us
       DelayMicrosecondsNoSleep(2);
       if(GPIO_READ(DS_PIN)!=0)
       data |= Mask;
       Mask*=2;
       DelayMicrosecondsNoSleep(60);
      }

    return data;
}
开发者ID:SimplyAutomationized,项目名称:BitBangingDS18B20,代码行数:30,代码来源:DS18B20Scan.c


示例20: buzzer_main

int buzzer_main(int argc, const char* argv[]) {
    if(map_peripheral(&g_gpio) == -1) {
        printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
        return -1;
    }
    s_pin = 4;
    INP_GPIO(s_pin);
    OUT_GPIO(s_pin);
 
    size_t len = 64;
    char* line = (char*)malloc(len);
    int fre = 0;
    int elapsed = 0;
 
    while (getline(&line, &len, stdin) != -1) {
        int r = sscanf(line, "%d %d\n", &fre, &elapsed);
        if (r == 2) {
            if (fre < 20) {
                // no sound
                usleep(elapsed*1000);
            } else {
                playSound(fre, elapsed);
            }
        } else {
            fprintf(stderr, "skip, invalid line: %s", line);
        }
    }
 
    printf("sound count = %lld, high = %lld, low = %lld\n", s_count, s_high, s_low);
    free(line);
    return 0;
}
开发者ID:XuJiandong,项目名称:raspberrypi-toolbox,代码行数:32,代码来源:buzzer.c



注:本文中的OUT_GPIO函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OUT_LOAD_INST_DATA函数代码示例发布时间:2022-05-30
下一篇:
C++ OUT_DEBUG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap