ZYNQ7000_Linux_EMIO_LED

一、设备树和bit

在设备树中PL下添加一个GPIO,这里使用标号56。

		ch_emio {
   
			compatible = "ch,emio_led";
			enable_pin {
    
				label = "enable";
				gpios = <&gpio0 56 0>;
			};
		};

vivado 工程打开GPIO,并约束好引脚到LED。编译生成新的.bit文件。
在这里插入图片描述

二、程序

/*
 * LEDs driver for GPIOs
 *
 * Copyright (C) 2007 8D Technologies inc.
 * Raphael Assenat <raph@8d.com>
 * Copyright (C) 2008 Freescale Semiconductor, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <asm/atomic.h>
#include <asm/unaligned.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/string.h>  
#include <linux/io.h>

#define DEVICE_NAME "emio_led"

struct gpio_emio{
   
	char name[10];
	struct gpio_desc *gpiod;
	struct device *gpio_dev;
}gpio_emio_dev;

static int gpio_emio_major;
static struct class* gpio_emio_class = NULL;
static 
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值