在OpenWrt上编写自己的硬件操作程序

上一篇文章中有写到如何使用OPENWRT的SDK,这里继续,写怎么在上面开发自己的应用程序。

我欲在OpenWrt上编写一个软件,它能够去读取某个AD芯片的多通道采样值。

在看这篇文章之前请看这官方的文章:http://wiki.openwrt.org/zh-cn/doc/devel/packages

 

我使用一个最简单的应用程序作为自己的模板,就是package/gpioctl这个应用程序,复制一份gpioctl文件夹然后把重命名为sensor-strain,然后修改一个里面的Makefile文件,变成这样子了(只是简单地把gpioctl换成自己的sensor-strain):

#
# Copyright (C) 2014 xxx.com
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=sensor-strain
PKG_RELEASE:=0
PKG_VERSION:=0.1

include $(INCLUDE_DIR)/package.mk

define Package/sensor-strain
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=SS - Tool for controlling gpio pins
  DEPENDS:=@GPIO_SUPPORT
endef

define Package/sensor-strain/description
    SS - Tool for controlling gpio pins
endef

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) \
        $(TARGET_CONFIGURE_OPTS) CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/include"
endef

define Package/sensor-strain/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/sensor-strain $(1)/usr/bin/
endef

$(eval $(call BuildPackage,sensor-strain))

之后在~/openwrt下执行:

make menuconfig

在Utilities中就可以找到sensor-strain菜单了

 

posted @ 2014-05-21 10:19  Merlin-magic  阅读(2449)  评论(0编辑  收藏  举报