-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dongwencai
committed
May 13, 2015
1 parent
566a4a7
commit 5d29a6a
Showing
22 changed files
with
1,968 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cmd_/home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209.ko := mipsel-openwrt-linux-ld -r -m elf32ltsmip -T /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/linux-3.10.49/scripts/module-common.lds -s --build-id -o /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209.ko /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209.o /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209.mod.o |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209.ko | ||
/home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ARCH ?=mips | ||
CROSS_COMPILE ?=mipsel-openwrt-linux- | ||
CC=$(CROSS_COMPILE)gcc | ||
obj-m := axp209.o #要生成的模块名 | ||
mymodules-objs:= axp209.o #生成这个模块名所需要的目标文件 | ||
|
||
KDIR :=/home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/linux-3.10.49/ | ||
|
||
PWD := $(shell pwd) | ||
|
||
default: | ||
$(CC) demo.c -o demo | ||
$(CC) axp.c -o axp209 -lm | ||
make -C $(KDIR) M=$(PWD) modules | ||
|
||
clean: | ||
rm -rf *.o .* .cmd *.ko *.mod.c .tmp_versions demo axp209 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0x00000000 unregister_axp209_notifier /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209 EXPORT_SYMBOL | ||
0x00000000 rgbled_notifier /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/rgbled/rgbled EXPORT_SYMBOL | ||
0x00000000 register_axp209_notifier /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209 EXPORT_SYMBOL | ||
0x00000000 call_axp209_notifiers /home/mrdong/openwrt/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620a/driver_dev/axp209_drv/axp209 EXPORT_SYMBOL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include "axp209.h" | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <math.h> | ||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#include <sys/stat.h> | ||
#include <sys/ioctl.h> | ||
void usage() __attribute__ ((noreturn)); | ||
void usage() | ||
{ | ||
printf("-----------usage----------->\n"); | ||
printf("axp209 set reg value\n"); | ||
printf("axp209 get reg\n"); | ||
exit(-1); | ||
} | ||
|
||
int hex2int(char *szhex) | ||
{ | ||
int n = 0, len; | ||
int value = 0; | ||
char hs2i[128] ={ | ||
['0'] = 0, | ||
['1'] = 1, | ||
['2'] = 2, | ||
['3'] = 3, | ||
['4'] = 4, | ||
['5'] = 5, | ||
['6'] = 6, | ||
['7'] = 7, | ||
['8'] = 8, | ||
['9'] = 9, | ||
['A'] = 10, | ||
['B'] = 11, | ||
['C'] = 12, | ||
['D'] = 13, | ||
['E'] = 14, | ||
['F'] = 15, | ||
['a'] = 10, | ||
['b'] = 11, | ||
['c'] = 12, | ||
['d'] = 13, | ||
['e'] = 14, | ||
['f'] = 15, | ||
}; | ||
len = strlen(szhex); | ||
while(len) | ||
{ | ||
value += hs2i[szhex[len - 1]] * pow(16, n); | ||
n ++; | ||
len --; | ||
} | ||
return value; | ||
} | ||
int str2int(char *hex) | ||
{ | ||
if(hex[1] == 'x' || hex[1] == 'X') | ||
{ | ||
return hex2int(&hex[2]); | ||
} | ||
return atoi(hex); | ||
} | ||
int main(int argc, char *argv[]) | ||
{ | ||
int fd = -1; | ||
unsigned char status = 0xff; | ||
unsigned short context = 0xff; | ||
fd = open("/dev/axp209",O_RDWR, S_IRUSR | S_IWUSR); | ||
ioctl(fd, AXP209_GET_ELEC, &status); | ||
printf("%s\t%d\t%d\n", __func__, __LINE__, status); | ||
if(argc > 2 && (!strcmp("get",argv[1])) ) | ||
{ | ||
context = (str2int(argv[2]) & 0xff) << 8; | ||
ioctl(fd, AXP209_GET_REG, &context); | ||
printf("%x\t%x\n",context >> 8, context & 0xff); | ||
} | ||
else if(argc > 3 && (!strcmp("set",argv[1]))) | ||
{ | ||
context = (str2int(argv[2]) & 0xff) << 8; | ||
context |= (str2int(argv[3]) & 0xff); | ||
ioctl(fd, AXP209_SET_REG, &context); | ||
} | ||
else | ||
{ | ||
// usage(); | ||
ioctl(fd, AXP209_GET_ADDR, 0x00); | ||
} | ||
close(fd); | ||
return 0; | ||
} |
Oops, something went wrong.