您尚未登录。

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

上山打逗比
会员
注册时间: 2019-05-16
已发帖子: 13
积分: 13

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

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

离线

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

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,245
积分: 9197

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
已发帖子: 13
积分: 13

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


谢谢晕哥

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn