dragino2 ar9331将LED管脚当做普通gpio使用
1、 将gpio13和gpio17也当作普通gpio使用,修改
target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c文件如下
/*
* DRAGINO V2 board support, based on Atheros AP121 board support
*
* Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2012 Elektra Wagenrad <elektra@villagetelco.org>
*
* 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/gpio.h>
#include <asm/mach-ath79/ath79.h>
#include <asm/mach-ath79/ar71xx_regs.h>
#include "common.h"
#include "dev-eth.h"
#include "dev-gpio-buttons.h"
#include "dev-leds-gpio.h"
#include "dev-m25p80.h"
#include "dev-spi-gpio.h" // add by merlin
#include "dev-spi.h"
#include "dev-usb.h"
#include "dev-wmac.h"
#include "machtypes.h" #define DRAGINO2_GPIO_LED_WLAN 0
//#define DRAGINO2_GPIO_LED_LAN 13
//#define DRAGINO2_GPIO_LED_WAN 17 /*
* The following GPIO is actually named "Router" on the board.
* However, since the "Router" feature is not supported as of yet
* we use it to display USB activity.
*/ #define DRAGINO2_GPIO_LED_USB 28
#define DRAGINO2_GPIO_BTN_JUMPSTART 11
#define DRAGINO2_GPIO_BTN_RESET 12 #define DRAGINO2_KEYS_POLL_INTERVAL 20 /* msecs */
#define DRAGINO2_KEYS_DEBOUNCE_INTERVAL (3 * DRAGINO2_KEYS_POLL_INTERVAL) #define DRAGINO2_MAC0_OFFSET 0x0000
#define DRAGINO2_MAC1_OFFSET 0x0006
#define DRAGINO2_CALDATA_OFFSET 0x1000
#define DRAGINO2_WMAC_MAC_OFFSET 0x1002 static struct gpio_led dragino2_leds_gpio[] __initdata = {
// {
// .name = "dragino2:red:lan",
// .gpio = DRAGINO2_GPIO_LED_LAN,
// .active_low = 0,
// },
{
.name = "dragino2:red:wlan",
.gpio = DRAGINO2_GPIO_LED_WLAN,
.active_low = ,
},
// {
// .name = "dragino2:red:wan",
// .gpio = DRAGINO2_GPIO_LED_WAN,
// .active_low = 0,
// },
{
.name = "dragino2:red:usb",
.gpio = DRAGINO2_GPIO_LED_USB,
.active_low = ,
},
}; static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
{
.desc = "jumpstart button",
.type = EV_KEY,
.code = KEY_WPS_BUTTON,
.debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
.gpio = DRAGINO2_GPIO_BTN_JUMPSTART,
.active_low = ,
},
{
.desc = "reset button",
.type = EV_KEY,
.code = KEY_RESTART,
.debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
.gpio = DRAGINO2_GPIO_BTN_RESET,
.active_low = ,
}
}; static void __init dragino2_common_setup(void)
{
u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); ath79_register_m25p80(NULL);
ath79_register_wmac(art + DRAGINO2_CALDATA_OFFSET,
art + DRAGINO2_WMAC_MAC_OFFSET); ath79_init_mac(ath79_eth0_data.mac_addr, art + DRAGINO2_MAC0_OFFSET, );
ath79_init_mac(ath79_eth1_data.mac_addr, art + DRAGINO2_MAC1_OFFSET, ); ath79_register_mdio(, 0x0); /* Enable GPIO15 and GPIO16 and possibly GPIO26 and GPIO27 */
//ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
// AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN);
ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN); /* LAN ports */
ath79_register_eth(); /* WAN port */
ath79_register_eth(); // add by merlin 2014-07-18
ath79_register_spi_gpio();
} static void __init dragino2_setup(void)
{
dragino2_common_setup(); ath79_register_leds_gpio(-, ARRAY_SIZE(dragino2_leds_gpio),
dragino2_leds_gpio);
ath79_register_gpio_keys_polled(-, DRAGINO2_KEYS_POLL_INTERVAL,
ARRAY_SIZE(dragino2_gpio_keys),
dragino2_gpio_keys);
ath79_register_usb();
} MIPS_MACHINE(ATH79_MACH_DRAGINO2, "DRAGINO2", "Dragino Dragino v2",
dragino2_setup);
注意两点,1,将DRAGINO2_GPIO_LED_LAN和DRAGINO2_GPIO_LED_WAN相关定义注释掉;2,将管脚当做普通gpio使用,要在ath79_gpio_function_disable函数中添加相关内容,按默认的即可。
2、测试

如测试LED3 (GPIO_14)和LED6 (GPIO_17)
root@SC-M-BASE:/sys/class/gpio# echo > export
root@SC-M-BASE:/sys/class/gpio# echo out > gpio14/direction
root@SC-M-BASE:/sys/class/gpio# echo > gpio14/value
root@SC-M-BASE:/sys/class/gpio# echo > export
root@SC-M-BASE:/sys/class/gpio# echo out > gpio17/direction
root@SC-M-BASE:/sys/class/gpio# echo > gpio17/value
参考:
http://www.cnblogs.com/tfanalysis/p/4206513.html
dragino2 ar9331将LED管脚当做普通gpio使用的更多相关文章
- EC20模块(mdm9607)复用pin脚当作普通gpio的设置方法
修改pin37~40,当作普通gpio的方法如下: 下面代码截图需要确认是否一样,如不一样请修改: 修改pin41~42 ,当作普通gpio方法如下: Pin24~27,当作普通gpio方法如下: P ...
- led的驱动及测试程序
一.驱动源码 #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> # ...
- 【Windows 10 IoT - 2】LED闪烁及动画绘制(树莓派 Pi2)
在上一篇博文<Windows 10 IoT系统安装>中,我们实现了在树莓派2平台上运行Window 10 IoT,本篇文章将介绍在该平台上的程序开发. 在最初获得的资讯中,以为Window ...
- [SAM4N学习笔记]LED点灯程序
一.准备工作: 将上一节搭建的工程模板复制一份,命名为"1.blink",这作为我们开发的第一个程序. 二.程序编写: 板子上只有一个可控制的LED,就是LED ...
- K1 K2作为中断源控制红色LED灯,实现任意键按一下LED灯亮或者灭
#include "stm32f10x.h" // 相当于51单片机中的 #include <reg51.h> #include "stm32f10x_gpi ...
- 云中树莓派(4):利用声音传感器控制Led灯
云中树莓派(1):环境准备 云中树莓派(2):将传感器数据上传到AWS IoT 并利用Kibana进行展示 云中树莓派(3):通过 AWS IoT 控制树莓派上的Led 云中树莓派(4):利用声音传感 ...
- 驱动学习5: zynq实现点亮led
驱动代码: #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> #i ...
- fl2440 platform总线led字符设备驱动
首先需要知道的是,设备跟驱动是分开的.设备通过struct device来定义,也可以自己将结构体封装到自己定义的device结构体中: 例如:struct platform_device: 在inc ...
- 30个物联网传感器小实验:三行代码点亮LED灯
30个物联网传感器小实验:三行代码点亮LED灯 三行代码点亮LED灯 LED灯闪烁 LED灯调亮度 LED淡入淡出 不写一行代码点亮LED灯 全彩RGB灯 面包板 30个物联网传感器小实验:三行代码点 ...
随机推荐
- python socket 编程之三:长连接、短连接以及心跳(转药师Aric的文章)
长连接:开启一个socket连接,收发完数据后,不立刻关闭连接,可以多次收发数据包. 短连接:开启一个socket连接,收发完数据后,立刻关闭连接. 心跳:长连接在没有数据通信时,定时发送数据包(心跳 ...
- wx小程序修改swiper 点的样式
<swiper class="swiper-box" indicator-dots="{{ indicatordots }}" autoplay=&quo ...
- H5之localStorage,sessionStorage
在以前的时候也听说过一些h5缓存技术,具体也没有去使用过,就在前两三个礼拜我用了localStorage和sessionStorage这两个存储方式, 我使用这些存储技术,也是想减少访问服务器的请求, ...
- 【转载】 pytorch之添加BN
原文地址: https://blog.csdn.net/weixin_40123108/article/details/83509838 ------------------------------- ...
- Java 构造器Constructor 继承
Java默认构造方法 构造方法作用:初始化所定义的类的对象和属性. 构造方法没有返回类型. 2 继承中的构造器 子类是不继承父类的构造器(构造方法或者构造函数)的,它只是调用(隐式或显式). 如果父类 ...
- jQuery .each()方法与.data()方法
.each(callback): 每次执行传递进来的函数时,函数中的this关键字都指向一个不同的DOM元素(每次都是一个不同的匹配元素).而且,在每次执行函数时,都会给函数传递一个表示作为执行环境的 ...
- Maxscale-在第一个节点的配置
[maxscale]threads=4 ##### Write Service, need to set address[server1]type=serveraddress=172.16.50.36 ...
- 后台管理Models
1.后台的配置 登录地址 :http://localhost:8000/admin 创建后台管理员(超级用户): 在终端输入:./manage.py createsuperuser Username ...
- 田螺便利店—win10专业版激活码
win10专业版:VP4MG-CMX8Q-27THR-Y468R-HRVR7 开始——设置——更新和安全——激活——更改产品密钥 复制VP4MG-CMX8Q-27THR-Y468R-HRVR7即可激活 ...
- Vue.js学习使用心得(三)
一.计算属性 计算属性关键词: computed <body> <div id="app"> <p>原始字符串: {{ message }}&l ...