1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2025-04-21 12:27:27 +03:00
This commit is contained in:
Carlos Camargo
2010-09-12 19:57:04 -05:00
parent d01e4f4f47
commit 0975cd73dc
74 changed files with 23913 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
DIRS = lua_blink_led lua_calls_C1 lua_calls_C2 lua_calls_C3 lua_calls_C4 lua_calls_C5
DIRS = lua_blink_led lua_calls_C1 lua_calls_C2 lua_calls_C3 lua_calls_C5
all:
for n in $(DIRS); do $(MAKE) -C $$n || exit 1; done

View File

@@ -19,7 +19,6 @@ $(TARGET): $(COMMON_OBJECTS)
.c.o:
$(CC) -c $(CCFLAGS) $< -o $@
upload: $(TARGET)
scp $(TARGET).so test_gpio.lua $(NANO_PATH)

Binary file not shown.

View File

@@ -1,5 +1,5 @@
CC = mipsel-openwrt-linux-gcc
CXX = mipsel-openwrt-linux-g++
CXX = mipsel-openwrt-linux-g++
OPENWRT_BUILD_DIR = /home/cain/Embedded/ingenic/sakc/build/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1
INCLUDE = -I. -I$(OPENWRT_BUILD_DIR)/usr/include/
WARNINGS = -Wcast-align -Wpacked -Wpadded -Wall
@@ -7,13 +7,17 @@ CCFLAGS = ${INCLUDE} ${DEBUG} ${WARNINGS} -std=c99 -fPIC
LDFLAGS = -L$(OPENWRT_BUILD_DIR)/usr/lib -llua -ldl
DEBUG = -O3 -g0
NANO_PATH = root@192.168.254.101:
TARGET = mylib
TARGET = wrap
$(TARGET):
$(CC) $(CCFLAGS) $(LDFLAGS) -shared liba.c liba_wrapper.c -o $(TARGET).so
COMMON_SOURCES = liba.c liba_wrapper.c
COMMON_OBJECTS = $(COMMON_SOURCES:.c=.o)
$(TARGET): $(COMMON_OBJECTS)
$(CC) $(CCFLAGS) $(LDFLAGS) -shared $(COMMON_OBJECTS) -o $(TARGET).so
.c.o:
$(CC) -c $(CCFLAGS) -o $@
$(CC) -c $(CCFLAGS) $< -o $@
upload: $(TARGET)
scp $(TARGET).so test.lua $(NANO_PATH)

View File

@@ -113,7 +113,7 @@ static const struct luaL_reg functions[] = {
//This is the init function that will be called when you require 'mylib'
int luaopen_mylib(lua_State *L) {
int luaopen_wrap(lua_State *L) {
luaL_newmetatable(L, metaname);
@@ -126,6 +126,6 @@ int luaopen_mylib(lua_State *L) {
luaL_newmetatable(L,metaname);
return 1;
}
luaL_register(L, "mylib", functions);
luaL_register(L, "wrap", functions);
return 1;
}

View File

@@ -1,16 +1,16 @@
package.cpath = "./?.so"
require "mylib"
require "wrap"
--test1
mylib.lib_a_f_1()
wrap.lib_a_f_1()
--test2
assert(6==mylib.lib_a_f_2(2,3))
assert(6==wrap.lib_a_f_2(2,3))
--test3
assert(5==mylib.lib_a_f_3("hello"))
assert(5==wrap.lib_a_f_3("hello"))
--test4 : use userdata to pass structure
t=mylib.point_new(3,6)
t=wrap.point_new(3,6)
assert(18 == mylib.lib_a_f_4(t))
--test5, return userdata
t=mylib.lib_a_f_5()
assert(600 == mylib.lib_a_f_4(t))
assert(mylib.point_geta(t) == 20)
assert(mylib.point_getb(t) == 30)
t=wrap.lib_a_f_5()
assert(600 == wrap.lib_a_f_4(t))
assert(wrap.point_geta(t) == 20)
assert(wrap.point_getb(t) == 30)