Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
greatcattw authored May 11, 2022
1 parent fdeda7a commit 2c3183a
Show file tree
Hide file tree
Showing 14 changed files with 554 additions and 0 deletions.
37 changes: 37 additions & 0 deletions clock_gcat/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=clock_gcat
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk


define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Utilities
TITLE:=clock_gcat
endef

define Package/$(PKG_NAME)/description
clock_gcat is for I2C LCD 1602
endef

define Build/Compile
$(MAKE) -v
endef


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


define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) ./files/clock_gcat1.sh $(1)/usr/bin/
endef


$(eval $(call BuildPackage,$(PKG_NAME)))
9 changes: 9 additions & 0 deletions clock_gcat/files/clock_gcat1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
echo -e -n "\r" > /proc/LCDI2C
while [ 1 ];
do
echo -e -n "\t" > /proc/LCDI2C
date | awk '{print $4}' > /proc/LCDI2C
sleep 1
done

64 changes: 64 additions & 0 deletions clock_gcat_set_autorun/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=clock_gcat_set_autorun
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk


define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Utilities
TITLE:=clock_gcat
endef

define Package/$(PKG_NAME)/description
clock_gcat is for I2C LCD 1602
endef

define Build/Compile
$(MAKE) -v
endef


define Package/$(PKG_NAME)/preinst
#!/bin/sh
echo "ready to install $(PKG_NAME)"
endef

define Package/$(PKG_NAME)/postinst
#!/bin/sh
echo "ok to install $(PKG_NAME)"
if [ -z "$${IPKG_INSTROOT}" ]; then
/etc/init.d/clock_gcat enable
fi

endef

define Package/$(PKG_NAME)/prerm
#!/bin/sh
echo "ready to remove $(PKG_NAME)"
if [ -z "$${IPKG_INSTROOT}" ]; then
/etc/init.d/clock_gcat disable
fi
endef

define Package/$(PKG_NAME)/postrm
#!/bin/sh
echo "ok to remove $(PKG_NAME)"
endef

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


define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/clock_gcat.autorun $(1)/etc/init.d/clock_gcat
endef


$(eval $(call BuildPackage,$(PKG_NAME)))
18 changes: 18 additions & 0 deletions clock_gcat_set_autorun/files/clock_gcat.autorun
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh /etc/rc.common
START=90
STOP=10
USE_PROCD=1
start_service()
{
echo "##################################################"
procd_open_instance
procd_set_param command /bin/sh "/usr/bin/clock_gcat1.sh"
procd_set_param respawn
procd_close_instance
}

stop_service()
{
echo "**************************************************"
}

40 changes: 40 additions & 0 deletions lcd1602i2c2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#gcat 2022.0426.2

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

PKG_NAME:=lcd1602i2c2
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define KernelPackage/$(PKG_NAME)
SUBMENU:=Other modules
TITLE:=kernel lcd1602 i2c 2
VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)
FILES:= $(PKG_BUILD_DIR)/$(PKG_NAME).$(LINUX_KMOD_SUFFIX)
DEPENDS:=+kmod-i2c-core
AUTOLOAD:=$(call AutoLoad,60,$(PKG_NAME))
endef

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

define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(BUILDFLAGS)" \
modules
endef

#define KernelPackage/demo/install
# $(INSTALL_DIR) $(1)/lib/network/
#endef

$(eval $(call KernelPackage,$(PKG_NAME)))
4 changes: 4 additions & 0 deletions lcd1602i2c2/src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
obj-m += lcd1602i2c2.o

lcd1602i2c2-objs := interface_proc.o io_i2c.o io_lcd1602.o

9 changes: 9 additions & 0 deletions lcd1602i2c2/src/clock1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
echo -e -n "\r" > /proc/LCDI2C
while [ 1 ];
do
echo -e -n "\t" > /proc/LCDI2C
date | awk '{print $4}' > /proc/LCDI2C
sleep 1
done

4 changes: 4 additions & 0 deletions lcd1602i2c2/src/gcat.note
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PATH=$PATH:/home/ai7688/1208/AI7688H_OpenWRT_Build_FW_Setting_Tool_V1.0/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin
export CROSS_COMPILE="mipsel-openwrt-linux-uclibc-"
export ARCH=mips
make
98 changes: 98 additions & 0 deletions lcd1602i2c2/src/interface_proc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/uaccess.h>
#include <linux/of_gpio.h>
#include <linux/i2c.h>
#include <linux/unistd.h>
#include "io_i2c.h"
#include "io_lcd1602.h"
#define NAME_OF_PROC ("LCDI2C")

static int hello_val=0;






//-----------------------------------------------------
static int test_proc_open(struct inode *inode, struct file *file)
{
return 0;
}



static ssize_t test_proc_read(struct file *file, char __user *buffer,size_t count, loff_t *f_pos)
{

int len1;
if(*f_pos > 0)
return 0;
len1 = sprintf(buffer, "%d\n", hello_val);
*f_pos = *f_pos + len1;
return len1;
}



static ssize_t test_proc_write(struct file *file, const char __user *buffer,size_t count, loff_t *f_pos)
{
unsigned char tmpbuf[64];

if(count <= 0)
return -EFAULT;
if(count > sizeof(tmpbuf))
count = (16*2+1); // "\n01234567890012345678900123456789012"

if (buffer && !copy_from_user(tmpbuf, buffer, count)) {
LCD_parse_string (tmpbuf,count);
}
return count;
}



static struct file_operations test_fops = {
.owner = THIS_MODULE,
.open = test_proc_open,
.read = test_proc_read,
.write = test_proc_write,
// .release = single_release,
// .llseek = seq_lseek,
};


static int __init func_module_init(void)
{
struct proc_dir_entry* file;
int ret=0;
file = proc_create(NAME_OF_PROC, 0644, NULL, &test_fops);
if (!file)
return -ENOMEM;


ret=i2c_dev_init();
LCD_init();
return ret;
}



static void __exit func_module_exit(void)
{
remove_proc_entry(NAME_OF_PROC, NULL);
i2c_dev_exit();

}

module_init(func_module_init);
module_exit(func_module_exit);

MODULE_AUTHOR("greatcat@ms18.hinet.net");
MODULE_DESCRIPTION("proc_module "+NAME_OF_PROC);
MODULE_LICENSE("GPL");



77 changes: 77 additions & 0 deletions lcd1602i2c2/src/io_i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/string.h>
#include "io_i2c.h"

//-----------------
#define I2C_BUS_AVAILABLE ( 0 ) // I2C Bus that we have created
#define SLAVE_DEVICE_NAME ( "I2CLCD1602") // Device and Driver Name
#define LCDI2C_SLAVE_ADDR ( 0x27 ) // LCD Slave Address
//----



struct i2c_client *ext_i2c_dev = NULL;; // I2C device Structure

static struct i2c_adapter *ext_i2c_adapter = NULL; // I2C Adapter Structure

static int i2c_dev_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_info("I2C dev Probed!!!\n");

return 0;
}

static int i2c_dev_remove(struct i2c_client *client)
{

pr_info("I2C dev Removed!!!\n");
return 0;
}


static struct i2c_board_info lcd_i2c_board_info = {
I2C_BOARD_INFO(SLAVE_DEVICE_NAME, LCDI2C_SLAVE_ADDR)
};
static const struct i2c_device_id I2c_dev_id[] = {
{ SLAVE_DEVICE_NAME, 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, I2c_dev_id);
static struct i2c_driver ext_oled_driver = {
.driver = {
.name = SLAVE_DEVICE_NAME,
.owner = THIS_MODULE,
},
.probe = i2c_dev_probe,
.remove = i2c_dev_remove,
.id_table = I2c_dev_id,
};

int i2c_dev_init(void){

ext_i2c_adapter = i2c_get_adapter(I2C_BUS_AVAILABLE);
if( ext_i2c_adapter != NULL ){
ext_i2c_dev = i2c_new_device(ext_i2c_adapter, &lcd_i2c_board_info);

if( ext_i2c_dev != NULL )
{
i2c_add_driver(&ext_oled_driver);
} else {
printk("err, ext_i2c_dev = null\n");
return -ENOMEM;
}
i2c_put_adapter(ext_i2c_adapter);
} else {
printk("err! ext_i2c_adapter = NULL\n");
return -ENOMEM;
}
printk("%s init ok!\n",SLAVE_DEVICE_NAME);
return 0;
}
void i2c_dev_exit(void){
i2c_unregister_device(ext_i2c_dev);
i2c_del_driver(&ext_oled_driver);
printk("%s exit ok\n",SLAVE_DEVICE_NAME);
}
7 changes: 7 additions & 0 deletions lcd1602i2c2/src/io_i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef IO_I2C_H
#define IO_I2C_H

int i2c_dev_init(void);
void i2c_dev_exit(void);

#endif
Loading

0 comments on commit 2c3183a

Please sign in to comment.