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使用的更多相关文章

  1. EC20模块(mdm9607)复用pin脚当作普通gpio的设置方法

    修改pin37~40,当作普通gpio的方法如下: 下面代码截图需要确认是否一样,如不一样请修改: 修改pin41~42 ,当作普通gpio方法如下: Pin24~27,当作普通gpio方法如下: P ...

  2. led的驱动及测试程序

    一.驱动源码 #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> # ...

  3. 【Windows 10 IoT - 2】LED闪烁及动画绘制(树莓派 Pi2)

    在上一篇博文<Windows 10 IoT系统安装>中,我们实现了在树莓派2平台上运行Window 10 IoT,本篇文章将介绍在该平台上的程序开发. 在最初获得的资讯中,以为Window ...

  4. [SAM4N学习笔记]LED点灯程序

    一.准备工作:      将上一节搭建的工程模板复制一份,命名为"1.blink",这作为我们开发的第一个程序. 二.程序编写:      板子上只有一个可控制的LED,就是LED ...

  5. K1 K2作为中断源控制红色LED灯,实现任意键按一下LED灯亮或者灭

    #include "stm32f10x.h" // 相当于51单片机中的 #include <reg51.h> #include "stm32f10x_gpi ...

  6. 云中树莓派(4):利用声音传感器控制Led灯

    云中树莓派(1):环境准备 云中树莓派(2):将传感器数据上传到AWS IoT 并利用Kibana进行展示 云中树莓派(3):通过 AWS IoT 控制树莓派上的Led 云中树莓派(4):利用声音传感 ...

  7. 驱动学习5: zynq实现点亮led

    驱动代码: #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> #i ...

  8. fl2440 platform总线led字符设备驱动

    首先需要知道的是,设备跟驱动是分开的.设备通过struct device来定义,也可以自己将结构体封装到自己定义的device结构体中: 例如:struct platform_device: 在inc ...

  9. 30个物联网传感器小实验:三行代码点亮LED灯

    30个物联网传感器小实验:三行代码点亮LED灯 三行代码点亮LED灯 LED灯闪烁 LED灯调亮度 LED淡入淡出 不写一行代码点亮LED灯 全彩RGB灯 面包板 30个物联网传感器小实验:三行代码点 ...

随机推荐

  1. git命令学习

    git init:把当前目录变成Git可以管理的仓库git add file:把文件添加到仓库git commit -m "描述语句":把文件提交到仓库git status:该命令 ...

  2. HDU 6106 17多校6 Classes(容斥简单题)

    Problem Description The school set up three elective courses, assuming that these courses are A, B, ...

  3. js--call( )/apply()/bind()--应用

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call funct ...

  4. mysql 数据查询全讲

    数据查询 涉及到DQL(Data Query Language)是sql语句的一类 本文全面介绍了mysql下 select 语句的各种查询方式:普通查询,模糊查询,查询排序,分页查询,聚合函数查询  ...

  5. NOI-1.1-04输出保留3位小数的浮点数

    04:输出保留3位小数的浮点数 总时间限制:  1000ms 内存限制:  65536kB 描述 读入一个单精度浮点数,保留3位小数输出这个浮点数. 输入 只有一行,一个单精度浮点数. 输出 也只有一 ...

  6. 关于PHP程序员技术职业生涯规划[转]

    看到很多PHP程序员职业规划的文章,都是直接上来就提Linux.PHP.MySQL.Nginx.Redis.Memcache.jQuery这些,然后就直接上手搭环境.做项目,中级就是学习各种PHP框架 ...

  7. http解析过程

    HTTP协议定义Web客户端如何从Web服务器请求Web页面,以及服务器如何把Web页面传送给客户端.HTTP协议采用了请求/响应模型.客户端向服务器发送一个请求报文,请求报文包含请求的方法.URL. ...

  8. lamp 相关

    1.LAMP = linux + apache + mysql(mariadb/mongodb) + php 2.mysql 安装:先下载安装包: wget -c http://mirrors.soh ...

  9. HDU 2206

    Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU ...

  10. opencv学习记录

    #include<iostream> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui ...