Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
9ddd395e
R
rt-thread
项目概览
BaiXuePrincess
/
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看板
提交
9ddd395e
编写于
7月 05, 2015
作者:
A
Aubr.Cool
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
correct canapp.c code indentation
上级
fece837e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
37 deletion
+37
-37
bsp/lpc408x/applications/canapp.c
bsp/lpc408x/applications/canapp.c
+37
-37
未找到文件。
bsp/lpc408x/applications/canapp.c
浏览文件 @
9ddd395e
...
@@ -19,65 +19,65 @@
...
@@ -19,65 +19,65 @@
#include "drv_lpccan.h"
#include "drv_lpccan.h"
struct
can_app_struct
struct
can_app_struct
{
{
const
char
*
name
;
const
char
*
name
;
struct
rt_can_filter_config
*
filter
;
struct
rt_can_filter_config
*
filter
;
rt_uint8_t
eventopt
;
rt_uint8_t
eventopt
;
struct
rt_semaphore
sem
;
struct
rt_semaphore
sem
;
};
};
static
struct
can_app_struct
can_data
[
1
];
static
struct
can_app_struct
can_data
[
1
];
struct
rt_can_filter_item
filter1item
[
4
]
=
struct
rt_can_filter_item
filter1item
[
4
]
=
{
{
LPC_CAN_AF_STD_INIT
(
1
),
LPC_CAN_AF_STD_INIT
(
1
),
LPC_CAN_AF_STD_GRP_INIT
(
3
,
5
),
LPC_CAN_AF_STD_GRP_INIT
(
3
,
5
),
LPC_CAN_AF_EXT_INIT
(
2
),
LPC_CAN_AF_EXT_INIT
(
2
),
LPC_CAN_AF_EXT_GRP_INIT
(
4
,
6
),
LPC_CAN_AF_EXT_GRP_INIT
(
4
,
6
),
};
};
struct
rt_can_filter_config
filter1
=
struct
rt_can_filter_config
filter1
=
{
{
.
count
=
4
,
.
count
=
4
,
.
actived
=
1
,
.
actived
=
1
,
.
items
=
filter1item
,
.
items
=
filter1item
,
};
};
static
struct
can_app_struct
can_data
[
1
]
=
{
static
struct
can_app_struct
can_data
[
1
]
=
{
{
{
.
name
=
"lpccan1"
,
.
name
=
"lpccan1"
,
.
filter
=
&
filter1
,
.
filter
=
&
filter1
,
.
eventopt
=
RT_EVENT_FLAG_OR
|
RT_EVENT_FLAG_CLEAR
,
.
eventopt
=
RT_EVENT_FLAG_OR
|
RT_EVENT_FLAG_CLEAR
,
},
},
};
};
static
rt_err_t
lpccanind
(
rt_device_t
dev
,
rt_size_t
size
)
static
rt_err_t
lpccanind
(
rt_device_t
dev
,
rt_size_t
size
)
{
{
rt_sem_release
(
&
can_data
[
0
].
sem
);
rt_sem_release
(
&
can_data
[
0
].
sem
);
}
}
void
rt_can_thread_entry
(
void
*
parameter
)
void
rt_can_thread_entry
(
void
*
parameter
)
{
{
struct
rt_can_msg
msg
;
struct
rt_can_msg
msg
;
struct
can_app_struct
*
canpara
=
(
struct
can_app_struct
*
)
parameter
;
struct
can_app_struct
*
canpara
=
(
struct
can_app_struct
*
)
parameter
;
rt_device_t
candev
;
rt_device_t
candev
;
candev
=
rt_device_find
(
canpara
->
name
);
candev
=
rt_device_find
(
canpara
->
name
);
RT_ASSERT
(
candev
);
RT_ASSERT
(
candev
);
rt_sem_init
(
&
canpara
->
sem
,
canpara
->
name
,
0
,
RT_IPC_FLAG_FIFO
);
rt_sem_init
(
&
canpara
->
sem
,
canpara
->
name
,
0
,
RT_IPC_FLAG_FIFO
);
rt_device_open
(
candev
,
(
RT_DEVICE_OFLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_INT_TX
));
rt_device_open
(
candev
,
(
RT_DEVICE_OFLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_INT_TX
));
rt_device_control
(
candev
,
RT_CAN_CMD_SET_FILTER
,
canpara
->
filter
);
rt_device_control
(
candev
,
RT_CAN_CMD_SET_FILTER
,
canpara
->
filter
);
rt_device_set_rx_indicate
(
candev
,
lpccanind
);
rt_device_set_rx_indicate
(
candev
,
lpccanind
);
while
(
1
)
{
while
(
1
)
{
rt_sem_take
(
&
canpara
->
sem
,
RT_WAITING_FOREVER
);
rt_sem_take
(
&
canpara
->
sem
,
RT_WAITING_FOREVER
);
while
(
rt_device_read
(
candev
,
0
,
&
msg
,
sizeof
(
msg
))
==
sizeof
(
msg
))
{
while
(
rt_device_read
(
candev
,
0
,
&
msg
,
sizeof
(
msg
))
==
sizeof
(
msg
))
{
rt_device_write
(
candev
,
0
,
&
msg
,
sizeof
(
msg
));
rt_device_write
(
candev
,
0
,
&
msg
,
sizeof
(
msg
));
}
}
}
}
}
}
int
rt_can_app_init
(
void
)
int
rt_can_app_init
(
void
)
{
{
rt_thread_t
tid
;
rt_thread_t
tid
;
tid
=
rt_thread_create
(
"canapp1"
,
tid
=
rt_thread_create
(
"canapp1"
,
rt_can_thread_entry
,
&
can_data
[
0
],
rt_can_thread_entry
,
&
can_data
[
0
],
512
,
RT_THREAD_PRIORITY_MAX
/
3
-
1
,
20
);
512
,
RT_THREAD_PRIORITY_MAX
/
3
-
1
,
20
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
return
0
;
return
0
;
}
}
INIT_APP_EXPORT
(
rt_can_app_init
);
INIT_APP_EXPORT
(
rt_can_app_init
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录