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

C++ GPIO函数代码示例

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

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



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

示例1: configure_3g

static void configure_3g(void)
{
	/* Force 3G modem off to avoid confusing the EHCI host and
	 * causing problems during enumeration/init */
	gpio_output(GPIO(5, C, 1), 1);	/* 3G_SHUTDOWN */
	gpio_output(GPIO(4, D, 2), 0);	/* 3G_ON_OFF */
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:7,代码来源:mainboard.c


示例2: set_external_breakpoint_pin_state

void set_external_breakpoint_pin_state(uint16_t bitmask, bool state)
{
    if (state)
        GPIO(PORT_CODEPOINT, OUT) |= bitmask << PIN_CODEPOINT_0;
    else
        GPIO(PORT_CODEPOINT, OUT) &= ~(bitmask << PIN_CODEPOINT_0);
}
开发者ID:CMUAbstract,项目名称:edb-firmware,代码行数:7,代码来源:codepoint.c


示例3: ambarella_init_filbert

/* ==========================================================================*/
static void __init ambarella_init_filbert(void)
{
	int					i;

	ambarella_init_machine("Filbert");

	platform_add_devices(ambarella_devices, ARRAY_SIZE(ambarella_devices));
	for (i = 0; i < ARRAY_SIZE(ambarella_devices); i++) {
		device_set_wakeup_capable(&ambarella_devices[i]->dev, 1);
		device_set_wakeup_enable(&ambarella_devices[i]->dev, 0);
	}

	/* Config Eth0*/
	ambarella_eth0_platform_info.mii_reset.gpio_id = GPIO(124);
	ambarella_eth0_platform_info.mii_reset.active_level = GPIO_LOW;
	ambarella_eth0_platform_info.mii_reset.active_delay = 20;

	/* Config Eth1*/
	ambarella_eth1_platform_info.mii_reset.gpio_id = GPIO(125);
	ambarella_eth1_platform_info.mii_reset.active_level = GPIO_LOW;
	ambarella_eth1_platform_info.mii_reset.active_delay = 20;

	/* Config SD*/
	fio_default_owner = SELECT_FIO_SDIO;
	ambarella_platform_sd_controller0.clk_limit = 48000000;
	ambarella_platform_sd_controller0.slot[0].cd_delay = HZ;
	ambarella_platform_sd_controller0.slot[0].use_bounce_buffer = 1;
	ambarella_platform_sd_controller0.slot[0].max_blk_sz = SD_BLK_SZ_128KB;
	ambarella_platform_sd_controller0.slot[1].cd_delay = HZ;
	ambarella_platform_sd_controller0.slot[1].gpio_cd.irq_gpio = GPIO(75);
	ambarella_platform_sd_controller0.slot[1].gpio_cd.irq_line = gpio_to_irq(75);
	ambarella_platform_sd_controller0.slot[1].gpio_cd.irq_type = IRQ_TYPE_EDGE_BOTH;
	ambarella_platform_sd_controller0.slot[1].gpio_wp.gpio_id = GPIO(76);
}
开发者ID:WayWingsDev,项目名称:gopro-linux,代码行数:35,代码来源:init-boss_a7.c


示例4: UART_teardown

void UART_teardown(unsigned interface)
{
    // Put pins into High-Z state
    switch(interface)
    {
#ifdef UART_HOST
        case UART_INTERFACE_USB:
            UART(UART_HOST, IE) &= ~UCRXIE;   // disable Tx + Rx interrupts
            UART(UART_HOST, CTL1) |= UCSWRST; // put state machine in reset
            GPIO(PORT_UART_USB, SEL) &=
                ~(BIT(PIN_UART_USB_TX) | BIT(PIN_UART_USB_RX));
            GPIO(PORT_UART_USB, DIR) &=
                ~(BIT(PIN_UART_USB_TX) | BIT(PIN_UART_USB_RX));
            break;
#endif // PORT_UART_USB
#ifdef UART_TARGET
        case UART_INTERFACE_WISP:
            UART(UART_TARGET, IE) &= ~UCRXIE;   // disable Tx + Rx interrupts
            UART(UART_TARGET, CTL1) |= UCSWRST; // put state machine in reset
            GPIO(PORT_UART_TARGET, SEL) &=
                ~(BIT(PIN_UART_TARGET_TX) | BIT(PIN_UART_TARGET_RX));
            GPIO(PORT_UART_TARGET, DIR) &=
                ~(BIT(PIN_UART_TARGET_TX) | BIT(PIN_UART_TARGET_RX));
            break;
#endif // PORT_UART_TARGET
    }
}
开发者ID:CMUAbstract,项目名称:edb-firmware,代码行数:27,代码来源:uart.c


示例5: init

void init() {
  initClocks();

  // Ensure right location of interrupt vectors
  // The bootloader leaves its own after flashing
  SYSCFG.MEMRMP()->setMEM_MODE(SYSCFG::MEMRMP::MemMode::MainFlashmemory);
  CM4.VTOR()->setVTOR((void*) 0);

  // Put all inputs as Analog Input, No pull-up nor pull-down
  // Except for the SWD port (PB3, PA13, PA14)
  GPIOA.MODER()->set(0xEBFFFFFF);
  GPIOA.PUPDR()->set(0x24000000);
  GPIOB.MODER()->set(0xFFFFFFBF);
  GPIOB.PUPDR()->set(0x00000000);
  for (int g=2; g<5; g++) {
    GPIO(g).MODER()->set(0xFFFFFFFF); // All to "Analog"
    GPIO(g).PUPDR()->set(0x00000000); // All to "None"
  }

#if EPSILON_DEVICE_BENCH
  bool consolePeerConnectedOnBoot = Ion::Console::Device::peerConnected();
#endif

  initPeripherals();

#if EPSILON_DEVICE_BENCH
  if (consolePeerConnectedOnBoot) {
    Ion::Device::Bench::run();
  }
#endif
}
开发者ID:Tilka,项目名称:epsilon,代码行数:31,代码来源:device.cpp


示例6: configure_vop

static void configure_vop(void)
{
	write32(&rk3288_grf->iomux_lcdc, IOMUX_LCDC);

	/* lcdc(vop) iodomain select 1.8V */
	write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 0));

	switch (board_id()) {
	case 0:
		rk808_configure_switch(2, 1);	/* VCC18_LCD */
		rk808_configure_ldo(7, 2500);	/* VCC10_LCD_PWREN_H */
		rk808_configure_switch(1, 1);	/* VCC33_LCD */
		break;
	default:
		gpio_output(GPIO(2, B, 5), 1);	/* AVDD_1V8_DISP_EN */
		rk808_configure_ldo(7, 2500);	/* VCC10_LCD_PWREN_H */
		gpio_output(GPIO(7, B, 6), 1);	/* LCD_EN */
		rk808_configure_switch(1, 1);	/* VCC33_LCD */

		/* enable edp HPD */
		gpio_input_pulldown(GPIO(7, B, 3));
		write32(&rk3288_grf->iomux_edp_hotplug, IOMUX_EDP_HOTPLUG);
		break;
	}
}
开发者ID:zamaudio,项目名称:coreboot,代码行数:25,代码来源:mainboard.c


示例7: bootblock_mainboard_early_init

void bootblock_mainboard_early_init(void)
{
	/* Let gpio2ab io domains works at 1.8V.
	 *
	 * If io_vsel[0] == 0(default value), gpio2ab io domains is 3.0V
	 * powerd by APIO2_VDD, otherwise, 1.8V supplied by APIO2_VDDPST.
	 * But from the schematic of kevin rev0, the APIO2_VDD and
	 * APIO2_VDDPST both are 1.8V(intentionally?).
	 *
	 * So, by default, CPU1_SDIO_PWREN(GPIO2_A2) can't output 3.0V
	 * because the supply is 1.8V.
	 * Let ask GPIO2_A2 output 1.8V to make GPIO interal logic happy.
	 */
	write32(&rk3399_grf->io_vsel, RK_SETBITS(1 << 0));

	/*
	 * Let's enable these power rails here, we are already running the SPI
	 * Flash based code.
	 */
	gpio_output(GPIO(0, B, 2), 1);  /* PP1500_EN */
	gpio_output(GPIO(0, B, 4), 1);  /* PP3000_EN */

	if (IS_ENABLED(CONFIG_DRIVERS_UART)) {
		_Static_assert(CONFIG_CONSOLE_SERIAL_UART_ADDRESS == UART2_BASE,
			       "CONSOLE_SERIAL_UART should be UART2");

		/* iomux: select gpio4c[4:3] as uart2 dbg port */
		write32(&rk3399_grf->iomux_uart2c, IOMUX_UART2C);

		/* grf soc_con7[11:10] use for uart2 select */
		write32(&rk3399_grf->soc_con7, UART2C_SEL);
	}
}
开发者ID:kk1987,项目名称:coreboot,代码行数:33,代码来源:bootblock.c


示例8: append_watchpoint_event

static void append_watchpoint_event(unsigned index)
{
    if (watchpoint_events_count[watchpoint_events_buf_idx] <
            param_num_watchpoint_events_buffered) {

        watchpoint_event_t *watchpoint_event =
            &watchpoint_events_buf[watchpoint_events_count[watchpoint_events_buf_idx]++];

        watchpoint_event->timestamp = SYSTICK_CURRENT_TIME;
        watchpoint_event->index = index;
        if (watchpoints_vcap_snapshot & (1 << index))
            watchpoint_event->vcap = ADC_read(ADC_CHAN_INDEX_VCAP);
        else // TODO: don't stream vcap at all if snapshot is not enabled
            watchpoint_event->vcap = 0;

    }

    if (watchpoint_events_count[watchpoint_events_buf_idx] ==
            param_num_watchpoint_events_buffered) {// buffer full
        if (!(main_loop_flags & FLAG_WATCHPOINT_READY)) { // the other buffer is free
            swap_buffers();
            // clear error indicator
            GPIO(PORT_LED, OUT) &= ~BIT(PIN_LED_RED);
        } else { // both buffers are full
            // indicate error on LED
            GPIO(PORT_LED, OUT) |= BIT(PIN_LED_RED);

            // drop the watchpoints on the floor
        }
    } else {
        // clear error indicator
        GPIO(PORT_LED, OUT) &= ~BIT(PIN_LED_RED);
    }
}
开发者ID:CMUAbstract,项目名称:edb-firmware,代码行数:34,代码来源:codepoint.c


示例9: target_set_debug_led

void target_set_debug_led(unsigned int led, bool on)
{
	switch (led) {
		case 0: gpio_set(GPIO(GPIO_PORT_F, 1), on); break;
		case 1: gpio_set(GPIO(GPIO_PORT_F, 2), on); break;
		case 2: gpio_set(GPIO(GPIO_PORT_F, 3), on); break;
	}
}
开发者ID:DSKIM3,项目名称:lk,代码行数:8,代码来源:init.c


示例10: io_mcp_get_pin_info

irom io_error_t io_mcp_get_pin_info(string_t *dst, const struct io_info_entry_T *info, io_data_pin_entry_t *pin_data, const io_config_pin_entry_t *pin_config, int pin)
{
	int bank, bankpin, tv;
	int io, olat, cached;
	mcp_data_pin_t *mcp_pin_data;

	bank = (pin & 0x08) >> 3;
	bankpin = pin & 0x07;

	mcp_pin_data = &mcp_data_pin_table[info->instance][pin];

	switch(pin_config->llmode)
	{
		case(io_pin_ll_input_analog):
		{
			if(read_register(dst, info->address, GPIO(bank), &tv) != io_ok)
				return(io_error);

			string_format(dst, "current io: %s", onoff(tv & (1 << bankpin)));

			break;
		}

		case(io_pin_ll_counter):
		{
			if(read_register(dst, info->address, GPIO(bank), &tv) != io_ok)
				return(io_error);

			string_format(dst, "current io: %s, debounce: %d", onoff(tv & (1 << bankpin)), mcp_pin_data->debounce);

			break;
		}

		case(io_pin_ll_output_digital):
		{
			if(read_register(dst, info->address, GPIO(bank), &tv) != io_ok)
				return(io_error);

			io = tv & (1 << bankpin);

			if(read_register(dst, info->address, OLAT(bank), &tv) != io_ok)
				return(io_error);

			olat = tv & (1 << bankpin);
			cached = pin_output_cache[bank] & (1 << bankpin);

			string_format(dst, "current latch: %s, io: %s, cache: %s", onoff(io), onoff(olat), onoff(cached));

			break;
		}

		default:
		{
		}
	}

	return(io_ok);
}
开发者ID:ESP32DE,项目名称:esp8266-universal-io-bridge,代码行数:58,代码来源:io_mcp.c


示例11: board_id

uint32_t board_id(void)
{
	const gpio_t pins[] = {[2] = GPIO(51), [1] = GPIO(62), [0] = GPIO(38)};
	static uint32_t id = UNDEFINED_STRAPPING_ID;

	if (id == UNDEFINED_STRAPPING_ID)
		id = gpio_base2_value(pins, ARRAY_SIZE(pins));

	return id;
}
开发者ID:canistation,项目名称:coreboot,代码行数:10,代码来源:boardid.c


示例12: rush_backlight_update

/* Turn on or turn off the backlight */
static int rush_backlight_update(DisplayOps *me, uint8_t enable)
{
	TegraGpio *backlight_vdd_enable = new_tegra_gpio_output(GPIO(P, 2));
	TegraGpio *backlight_enable = new_tegra_gpio_output(GPIO(H, 2));

	gpio_set(&backlight_vdd_enable->ops, enable);
	mdelay(10);
	gpio_set(&backlight_enable->ops, enable);

	return 0;
}
开发者ID:rockchip-linux,项目名称:depthcharge,代码行数:12,代码来源:board.c


示例13: ram_code

uint32_t ram_code(void)
{
	uint32_t code;
	static gpio_t pins[] = {[3] = GPIO(8, A, 3), [2] = GPIO(8, A, 2),
		[1] = GPIO(8, A, 1), [0] = GPIO(8, A, 0)}; /* GPIO8_A0 is LSB */

	code = gpio_base2_value(pins, ARRAY_SIZE(pins));
	printk(BIOS_SPEW, "RAM Config: %u.\n", code);

	return code;
}
开发者ID:tidatida,项目名称:coreboot,代码行数:11,代码来源:boardid.c


示例14: UART_Init

void UART_Init(int id, UINT32 baud)
{
    if (id == 0) {
	GPIO_SetP0Function(GPIO(0,0), 1);  // P0.0 Function TxD UART0
	GPIO_SetP0Function(GPIO(0,1), 1); //  P0.1 Function RxD UART0
    }
    else if (id == 1) {
	GPIO_SetP0Function(GPIO(0,8), 1);  // P0.8 Function TxD UART0
	GPIO_SetP0Function(GPIO(0,9), 1); //  P0.9 Function RxD UART0
    }
    UART_SetBaud(id, baud);
}
开发者ID:toxicgumbo,项目名称:m1,代码行数:12,代码来源:uart.c


示例15: mainboard_keyboard_init

void mainboard_keyboard_init(struct pk_sm_desc *desc)
{
	pwr_btn_gpio = sysinfo_lookup_gpio("power", 1,
					   new_tegra_gpio_input_from_coreboot);
	die_if(!pwr_btn_gpio, "No GPIO for power!!\n");

	/* Inputs volup and voldown are active low. */
	vol_down_gpio = new_gpio_not(&new_tegra_gpio_input(GPIO(X, 7))->ops);
	vol_up_gpio = new_gpio_not(&new_tegra_gpio_input(GPIO(X, 6))->ops);

	foster_sm_init(desc);
}
开发者ID:coreboot,项目名称:depthcharge,代码行数:12,代码来源:keyboard.c


示例16: board_id

uint8_t board_id(void)
{
	static int id = -1;
	static gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2),
		[1] = GPIO(2, A, 1), [0] = GPIO(2, A, 0)}; /* GPIO2_A0 is LSB */

	if (id < 0) {
		id = gpio_base2_value(pins, ARRAY_SIZE(pins));
		printk(BIOS_SPEW, "Board ID: %d.\n", id);
	}

	return id;
}
开发者ID:tidatida,项目名称:coreboot,代码行数:13,代码来源:boardid.c


示例17: enable_watchpoints

void enable_watchpoints()
{
    // enable rising-edge interrupt on enabled codepoint pins (harmless to do every time)
    uint8_t enabled_pins = 0;
    for (int i = 0; i < NUM_CODEPOINT_PINS; ++i) {
        enabled_pins |= (watchpoints & (1 << i)) ? ((1 << i) << PIN_CODEPOINT_0) : 0;
    }

    GPIO(PORT_CODEPOINT, DIR) &= ~BITS_CODEPOINT;
    GPIO(PORT_CODEPOINT, IES) &= ~BITS_CODEPOINT;
    GPIO(PORT_CODEPOINT, IFG) &= ~BITS_CODEPOINT;

    GPIO(PORT_CODEPOINT, IE) |= enabled_pins;
}
开发者ID:CMUAbstract,项目名称:edb-firmware,代码行数:14,代码来源:codepoint.c


示例18: configure_hdmi

static void configure_hdmi(void)
{
	rk808_configure_switch(2, 1);	/* VCC18_LCD (HDMI_AVDD_1V8) */
	rk808_configure_ldo(7, 1000);	/* VDD10_LCD (HDMI_AVDD_1V0) */

	/* set POWER_HDMI_EN */
	switch (board_id()) {
	case 0:
		gpio_output(GPIO(7, A, 2), 1);
		break;
	default:
		gpio_output(GPIO(5, C, 3), 1);
		break;
	}
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:15,代码来源:mainboard.c


示例19: fill_lb_gpios

void fill_lb_gpios(struct lb_gpios *gpios)
{
	int count = 0;

	/* Write Protect: active low */
	gpios->gpios[count].port = GPIO_R1_INDEX;
	gpios->gpios[count].polarity = ACTIVE_LOW;
	gpios->gpios[count].value = gpio_get_in_value(GPIO(R1));
	strncpy((char *)gpios->gpios[count].name, "write protect",
		GPIO_MAX_NAME_LENGTH);
	count++;

	/* Recovery: active high */
	gpios->gpios[count].port = -1;
	gpios->gpios[count].polarity = ACTIVE_HIGH;
	gpios->gpios[count].value = get_recovery_mode_switch();
	strncpy((char *)gpios->gpios[count].name, "recovery",
		GPIO_MAX_NAME_LENGTH);
	count++;

	/* Lid: active high */
	gpios->gpios[count].port = GPIO_R4_INDEX;
	gpios->gpios[count].polarity = ACTIVE_HIGH;
	gpios->gpios[count].value = gpio_get_in_value(GPIO(R4));
	strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH);
	count++;

	/* Power: active low */
	gpios->gpios[count].port = GPIO_Q0_INDEX;
	gpios->gpios[count].polarity = ACTIVE_LOW;
	gpios->gpios[count].value = gpio_get_in_value(GPIO(Q0));
	strncpy((char *)gpios->gpios[count].name, "power",
		GPIO_MAX_NAME_LENGTH);
	count++;

	/* Developer: virtual GPIO active high */
	gpios->gpios[count].port = -1;
	gpios->gpios[count].polarity = ACTIVE_HIGH;
	gpios->gpios[count].value = get_developer_mode_switch();
	strncpy((char *)gpios->gpios[count].name, "developer",
		GPIO_MAX_NAME_LENGTH);
	count++;

	gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio));
	gpios->count = count;

	printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size);
}
开发者ID:kmalkki,项目名称:coreboot,代码行数:48,代码来源:chromeos.c


示例20: bootblock_mainboard_init

void bootblock_mainboard_init(void)
{
	if (rkclk_was_watchdog_reset())
		reboot_from_watchdog();

	gpio_output(GPIO(0, B, 3), 1);	/* Power LED */

	/* Up VDD_CPU (BUCK1) to 1.4V to support max CPU frequency (1.8GHz). */
	setbits_le32(&rk3288_pmu->iomux_i2c0scl, IOMUX_I2C0SCL);
	setbits_le32(&rk3288_pmu->iomux_i2c0sda, IOMUX_I2C0SDA);
	assert(CONFIG_PMIC_BUS == 0);	/* must correspond with IOMUX */
	i2c_init(CONFIG_PMIC_BUS, 400*KHz);

	/* Slowly raise to max CPU voltage to prevent overshoot */
	rk808_configure_buck(1, 1200);
	udelay(175);/* Must wait for voltage to stabilize,2mV/us */
	rk808_configure_buck(1, 1400);
	udelay(100);/* Must wait for voltage to stabilize,2mV/us */
	rkclk_configure_cpu(APLL_1800_MHZ);

	/* i2c1 for tpm */
	write32(&rk3288_grf->iomux_i2c1, IOMUX_I2C1);
	i2c_init(1, 400*KHz);

	/* spi2 for firmware ROM */
	write32(&rk3288_grf->iomux_spi2csclk, IOMUX_SPI2_CSCLK);
	write32(&rk3288_grf->iomux_spi2txrx, IOMUX_SPI2_TXRX);
	rockchip_spi_init(CONFIG_BOOT_MEDIA_SPI_BUS, 24750*KHz);

	setup_chromeos_gpios();
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:31,代码来源:bootblock.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GPIODirModeSet函数代码示例发布时间:2022-05-30
下一篇:
C++ GOTO函数代码示例发布时间: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