Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lucky_草木皆兵
rt-thread
提交
07da6caa
R
rt-thread
项目概览
lucky_草木皆兵
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
07da6caa
编写于
1月 14, 2013
作者:
P
prife
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
surport finsh
上级
8f70786c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
37 addition
and
70 deletion
+37
-70
bsp/simlinux/applications/application.c
bsp/simlinux/applications/application.c
+4
-35
bsp/simlinux/drivers/serial.c
bsp/simlinux/drivers/serial.c
+1
-0
bsp/simlinux/drivers/usart_sim.c
bsp/simlinux/drivers/usart_sim.c
+23
-25
bsp/simlinux/rtconfig.py
bsp/simlinux/rtconfig.py
+3
-1
libcpu/sim/posix/cpu_port.c
libcpu/sim/posix/cpu_port.c
+6
-9
未找到文件。
bsp/simlinux/applications/application.c
浏览文件 @
07da6caa
...
...
@@ -18,6 +18,7 @@
#include <components.h>
void
rt_init_thread_entry
(
void
*
parameter
)
{
#ifdef RT_USING_LWIP
...
...
@@ -74,16 +75,8 @@ void rt_init_thread_entry(void *parameter)
}
#endif
#if 0
{
extern void application_init(void);
rt_thread_delay(RT_TICK_PER_SECOND);
application_init();
}
#endif
#if defined(RT_USING_RTGUI)
rt_thread_delay
(
3000
);
rt_thread_delay
(
RT_TICK_PER_SECOND
);
snake_main
();
#endif
}
...
...
@@ -91,56 +84,32 @@ void rt_init_thread_entry(void *parameter)
static
void
rt_test_thread_entry
(
void
*
parameter
)
{
int
i
;
for
(
i
=
0
;
i
<
10
;
i
++
)
for
(
i
=
0
;
i
<
5
;
i
++
)
{
rt_kprintf
(
"hello, world
\n
"
);
rt_thread_delay
(
RT_TICK_PER_SECOND
);
}
}
static
void
rt_high_thread_entry
(
void
*
parameter
)
{
int
i
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
rt_kprintf
(
"high thread <%d>
\n
"
,
i
);
rt_thread_delay
(
2
*
RT_TICK_PER_SECOND
);
}
}
int
rt_application_init
()
{
rt_thread_t
tid
;
#if 0
tid
=
rt_thread_create
(
"init"
,
rt_init_thread_entry
,
RT_NULL
,
2048
,
RT_THREAD_PRIORITY_MAX
/
3
,
20
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
tid
=
rt_thread_create
(
"test"
,
rt_test_thread_entry
,
RT_NULL
,
2048
,
RT_THREAD_PRIORITY_MAX
*
3
/
4
,
20
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
#endif
tid
=
rt_thread_create
(
"test1"
,
rt_high_thread_entry
,
RT_NULL
,
2048
,
RT_THREAD_PRIORITY_MAX
/
2
,
20
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
tid
=
rt_thread_create
(
"test2"
,
rt_test_thread_entry
,
RT_NULL
,
2048
,
RT_THREAD_PRIORITY_MAX
/
2
,
20
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
return
0
;
}
/*@}*/
bsp/simlinux/drivers/serial.c
浏览文件 @
07da6caa
...
...
@@ -122,6 +122,7 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buff
#endif
printf
(
"%s"
,
(
char
*
)
buffer
);
fflush
(
stdout
);
return
size
;
}
...
...
bsp/simlinux/drivers/usart_sim.c
浏览文件 @
07da6caa
...
...
@@ -59,28 +59,6 @@ void rt_hw_usart_init(void)
#include <termios.h>
/* for tcxxxattr, ECHO, etc */
#include <unistd.h>
/* for STDIN_FILENO */
/*simulate windows' getch(), it works!!*/
int
getch
(
void
)
{
int
ch
;
struct
termios
oldt
,
newt
;
// get terminal input's attribute
tcgetattr
(
STDIN_FILENO
,
&
oldt
);
newt
=
oldt
;
//set termios' local mode
newt
.
c_lflag
&=
~
(
ECHO
|
ICANON
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
newt
);
//read character from terminal input
ch
=
getchar
();
//recover terminal's attribute
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
oldt
);
return
ch
;
}
static
void
*
ThreadforKeyGet
(
void
*
lpParam
);
static
pthread_t
OSKey_Thread
;
...
...
@@ -149,16 +127,36 @@ static int savekey(unsigned char key)
#ifdef _WIN32
static
DWORD
WINAPI
ThreadforKeyGet
(
LPVOID
lpParam
)
#else
/*simulate windows' getch(), it works!!*/
static
void
setgetchar
(
void
)
{
struct
termios
oldt
,
newt
;
// get terminal input's attribute
tcgetattr
(
STDIN_FILENO
,
&
oldt
);
newt
=
oldt
;
//set termios' local mode
newt
.
c_lflag
&=
~
(
ECHO
|
ICANON
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
newt
);
}
#define getch getchar
static
void
*
ThreadforKeyGet
(
void
*
lpParam
)
#endif
#endif
/* not _WIN32*/
{
unsigned
char
key
;
(
void
)
lpParam
;
//prevent compiler warnings
#ifndef _WIN32
/* set the getchar without buffer */
setgetchar
();
#endif
for
(;;)
{
key
=
getch
();
#ifdef _WIN32
if
(
key
==
0xE0
)
{
key
=
getch
();
...
...
@@ -178,7 +176,7 @@ static void * ThreadforKeyGet(void * lpParam)
continue
;
}
#endif
savekey
(
key
);
}
}
/*** ThreadforKeyGet ***/
bsp/simlinux/rtconfig.py
浏览文件 @
07da6caa
...
...
@@ -35,11 +35,13 @@ if PLATFORM == 'gcc':
OBJCPY
=
PREFIX
+
'objcopy'
DEVICE
=
' -ffunction-sections -fdata-sections'
DEVICE
=
' '
CFLAGS
=
DEVICE
+
' -I/usr/include -w -D_REENTRANT'
AFLAGS
=
' -c'
+
DEVICE
+
' -x assembler-with-cpp'
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map,-cref,-u,Reset_Handler -T stm32_rom.ld'
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map -lpthread'
LFLAGS
=
DEVICE
+
' -Wl,--gc-sections,-Map=rtthread-linux.map -pthread'
#LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-linux.map -pthread'
LFLAGS
=
DEVICE
+
' -Wl,-Map=rtthread-linux.map -pthread -T gcc.ld'
CPATH
=
''
LPATH
=
''
...
...
libcpu/sim/posix/cpu_port.c
浏览文件 @
07da6caa
...
...
@@ -94,9 +94,9 @@ static void thread_switch_handler(int sig)
thread_from
=
(
thread_t
*
)
rt_interrupt_from_thread
;
thread_to
=
(
thread_t
*
)
rt_interrupt_to_thread
;
/*
FIXME
注意!此时 rt_thread_self的值是to线程的值! */
/* 注意!此时 rt_thread_self的值是to线程的值! */
tid
=
rt_thread_self
();
RT_ASSERT
(
thread_from
->
pthread
==
pid
);
/* FIXME RT_ASSERT(thread_from->pthread == pid); */
RT_ASSERT
((
thread_t
*
)(
tid
->
sp
)
==
thread_to
);
TRACE
(
"signal: SIGSUSPEND suspend <%s>
\n
"
,
thread_from
->
rtthread
->
name
);
...
...
@@ -124,7 +124,6 @@ static void *thread_run(void *parameter)
thread
->
task
(
thread
->
para
);
TRACE
(
"pid <%08x> tid <%s> exit...
\n
"
,
(
unsigned
int
)(
thread
->
pthread
),
tid
->
name
);
//FIXME
thread
->
exit
();
//sem_destroy(&thread->sem); //<--------------
...
...
@@ -235,7 +234,7 @@ void rt_hw_interrupt_enable(rt_base_t level)
tid
=
rt_thread_self
();
pid
=
pthread_self
();
if
(
pid
!=
mainthread_pid
)
if
(
pid
!=
mainthread_pid
&&
thread_from
->
pthread
==
pid
)
{
/* 注意这段代码是在RTT普通线程函数总函数中执行的,
* from线程就是当前rtt线程 */
...
...
@@ -245,9 +244,6 @@ void rt_hw_interrupt_enable(rt_base_t level)
thread_from
->
rtthread
->
name
,
thread_to
->
rtthread
->
name
);
/* 确定一下,这两个值一定是相等的! */
RT_ASSERT
(
thread_from
->
pthread
==
pid
);
/* 唤醒被挂起的线程 */
sem_post
(
&
thread_to
->
sem
);
cpu_pending_interrupts
--
;
...
...
@@ -259,8 +255,9 @@ void rt_hw_interrupt_enable(rt_base_t level)
}
else
{
/* 注意这段代码是在system tick 函数中执行的,
* 即此时位于主线程的SIGALRM信号处理函数中
/* 注意这段代码可能在多种情况下运行:
* 1. 在system tick中执行, 即主线程的SIGALRM信号处理函数中执行
* 2. 其他线程中调用,比如用于获取按键输入的线程中调用
*/
TRACE
(
"conswitch: S in pid<%x> ,suspend <%s>, resume <%s>!
\n
"
,
(
unsigned
int
)
pid
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录