WhyCan Forum

本站无需注册,无需积分,无需回复可下载所有资料,如果真的喜欢小站,请您注册之后请至少回复一个帖子激活Id,谢谢支持! 站长QQ: 516333132 (挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2019-05-17 18:18:23

上山打逗比
会员
注册时间: 2019-05-16
累计积分: 11

请问大神设备树文件怎么操作GPIO

现在的项目需要启动uboot就设置GPIOF1为高电平,怎么在设备树文件设置GPIO为上拉输出呢?

离线

#2 2019-05-17 20:47:45

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 7,389

Re: 请问大神设备树文件怎么操作GPIO

https://github.com/qq516333132/u-boot/blob/master/board/sunxi/board.c

	int led_r;
	led_r = sunxi_name_to_gpio("PB3");
	if (led_r < 0) {
		printf("Error invalid led_r pin: PB, err %d\n", led_r);
		return led_r;
	}
	ret = gpio_request(led_r, "led_r");
	if (ret) {
		printf("Error requesting soft led_r: PB, err %d\n",ret);
		return ret;
	}

	sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP); //上拉	
	gpio_direction_output(led_r, 1);

参考1: https://github.com/qq516333132/u-boot/blob/master/arch/arm/include/asm/arch-sunxi/gpio.h
参考2: https://github.com/qq516333132/u-boot/blob/master/arch/arm/mach-sunxi/pinmux.c
参考3: https://www.cnblogs.com/edan/p/9188131.html

离线

#3 2019-05-18 11:01:34

上山打逗比
会员
注册时间: 2019-05-16
累计积分: 11

Re: 请问大神设备树文件怎么操作GPIO

晕哥 说:

https://github.com/qq516333132/u-boot/blob/master/board/sunxi/board.c

	int led_r;
	led_r = sunxi_name_to_gpio("PB3");
	if (led_r < 0) {
		printf("Error invalid led_r pin: PB, err %d\n", led_r);
		return led_r;
	}
	ret = gpio_request(led_r, "led_r");
	if (ret) {
		printf("Error requesting soft led_r: PB, err %d\n",ret);
		return ret;
	}

	sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP); //上拉	
	gpio_direction_output(led_r, 1);


参考1: https://github.com/qq516333132/u-boot/blob/master/arch/arm/include/asm/arch-sunxi/gpio.h
参考2: https://github.com/qq516333132/u-boot/blob/master/arch/arm/mach-sunxi/pinmux.c
参考3: https://www.cnblogs.com/edan/p/9188131.html


谢谢晕哥

离线

页脚