From 8b8dba661f5e29e1592cc9df92ef219099809330 Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Sat, 29 May 2010 14:19:56 +0000 Subject: module developing git-svn-id: https://rt-thread.googlecode.com/svn/trunk@742 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- .../examples/application/basicapp/SConscript | 27 ++++++++++++++++++++++ .../examples/application/basicapp/basicapp.c | 26 +++++++++++++++++++++ .../examples/application/basicapp/module_entry.c | 21 +++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 components/module/examples/application/basicapp/SConscript create mode 100644 components/module/examples/application/basicapp/basicapp.c create mode 100644 components/module/examples/application/basicapp/module_entry.c (limited to 'components/module/examples/application/basicapp') diff --git a/components/module/examples/application/basicapp/SConscript b/components/module/examples/application/basicapp/SConscript new file mode 100644 index 0000000000..e8f79a5fd9 --- /dev/null +++ b/components/module/examples/application/basicapp/SConscript @@ -0,0 +1,27 @@ +Import('env') +Import('projects') +Import('RTT_ROOT') +Import('rtconfig') + +# group definitions +group = {} +group['name'] = 'examples' +group['src'] = Glob('*.c') +group['CCFLAGS'] = '' +group['CPPPATH'] = [RTT_ROOT + '/components/module/interface'] +group['CPPDEFINES'] = '' + +target = 'hello.mo' + +# add group to project list +projects.append(group) + +env.Append(CCFLAGS = group['CCFLAGS']) +env.Append(CPPPATH = group['CPPPATH']) +env.Append(CPPDEFINES = group['CPPDEFINES']) +module_env = env.Clone(CPPDEFINE = 'RT_MODULE') +module_env.Replace(LINKFLAGS = ' -mcpu=arm920t -r -d -e rt_module_entry -nostdlib -s') + +src_local = Glob('*.c') + +module_env.Program(target, src_local) diff --git a/components/module/examples/application/basicapp/basicapp.c b/components/module/examples/application/basicapp/basicapp.c new file mode 100644 index 0000000000..90d39f1427 --- /dev/null +++ b/components/module/examples/application/basicapp/basicapp.c @@ -0,0 +1,26 @@ +#include +#include + +int a = 0; +int b = 1000000; +int c = 0; + +void function(int count1, int count2, int count3) +{ + rt_kprintf("Hello RT-Thread %d %d\n", count1, count2, count3); +} + +int rt_application_entry(void) +{ + int i; + for(i=0; i<1000; i++) + { + a++; + b--; + c++; + function(a, b, c); + } + + return 0; +} + diff --git a/components/module/examples/application/basicapp/module_entry.c b/components/module/examples/application/basicapp/module_entry.c new file mode 100644 index 0000000000..1b523da100 --- /dev/null +++ b/components/module/examples/application/basicapp/module_entry.c @@ -0,0 +1,21 @@ +#include +#include + +extern int rt_application_entry(); +rt_shell_t ishell = RT_NULL; + +int rt_module_entry(const void* shell, void** object_info) +{ + /* init shell */ + ishell = (rt_shell_t)shell; + struct rt_module_info *info = (struct rt_module_info*)rt_malloc(sizeof(struct rt_module_info)); + + info->module_refs = 0; + info->module_type = RT_Module_Class_APP; + info->module_guid = 0xdead; + info->exec_entry = (void *)rt_application_entry; + info->module_interface = RT_NULL; + + *object_info = info; +} + -- cgit v1.3.1