Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逆着光、寻觅
rt-thread
提交
b750e11e
R
rt-thread
项目概览
逆着光、寻觅
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
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,发现更多精彩内容 >>
提交
b750e11e
编写于
7月 07, 2015
作者:
A
Aubr.Cool
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp]stm32f10x add canapp can bus hook set
上级
b7571b55
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
1 deletion
+90
-1
bsp/stm32f10x/applications/canapp.c
bsp/stm32f10x/applications/canapp.c
+90
-1
未找到文件。
bsp/stm32f10x/applications/canapp.c
浏览文件 @
b750e11e
...
...
@@ -12,10 +12,99 @@
* 2015-05-14 aubrcool@qq.com first version
*/
#ifdef RT_USING_CAN
#include <board.h>
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_CAN
#define CANRT1 8
#define CANERR1 9
#define CANRT2 37
#define CANERR2 38
static
struct
canledtype
{
struct
stm32_hw_pin_userdata
rtd
;
struct
stm32_hw_pin_userdata
err
;
}
canled
[]
=
{
#ifdef USING_BXCAN1
{
{
CANRT1
,
PIN_MODE_OUTPUT_OD
,},
{
CANERR1
,
PIN_MODE_OUTPUT_OD
,},
},
#endif
/*USING_BXCAN1*/
#ifdef USING_BXCAN2
{
{
CANRT2
,
PIN_MODE_OUTPUT_OD
,},
{
CANERR2
,
PIN_MODE_OUTPUT_OD
,},
},
#endif
/*USING_BXCAN2*/
};
void
can_bus_hook
(
struct
rt_can_device
*
can
,
struct
canledtype
*
led
)
{
if
(
can
->
timerinitflag
==
1
)
{
rt_pin_write
(
led
->
rtd
.
pin
,
0
);
}
else
{
if
(
can
->
status
.
rcvchange
==
1
||
can
->
status
.
sndchange
==
1
)
{
can
->
status
.
rcvchange
=
0
;
can
->
status
.
sndchange
=
0
;
rt_pin_write
(
led
->
rtd
.
pin
,
rt_pin_read
(
led
->
rtd
.
pin
)
?
0
:
1
);
}
else
{
rt_pin_write
(
led
->
rtd
.
pin
,
1
);
}
}
if
(
can
->
timerinitflag
==
1
)
{
rt_pin_write
(
led
->
err
.
pin
,
0
);
}
else
{
if
(
can
->
status
.
errcode
)
{
rt_pin_write
(
led
->
err
.
pin
,
0
);
}
else
{
rt_pin_write
(
led
->
err
.
pin
,
1
);
}
}
}
#ifdef USING_BXCAN1
void
can1_bus_hook
(
struct
rt_can_device
*
can
)
{
static
rt_int32_t
inited
=
0
;
if
(
!
inited
)
{
inited
=
1
;
rt_pin_mode
(
canled
[
0
].
rtd
.
pin
,
canled
[
0
].
rtd
.
mode
);
rt_pin_mode
(
canled
[
0
].
err
.
pin
,
canled
[
0
].
err
.
mode
);
}
can_bus_hook
(
can
,
&
canled
[
0
]);
}
#endif
/*USING_BXCAN1*/
#ifdef USING_BXCAN2
void
can2_bus_hook
(
struct
rt_can_device
*
can
)
{
static
rt_int32_t
inited
=
0
;
if
(
!
inited
)
{
inited
=
1
;
rt_pin_mode
(
canled
[
1
].
rtd
.
pin
,
canled
[
1
].
rtd
.
mode
);
rt_pin_mode
(
canled
[
1
].
err
.
pin
,
canled
[
1
].
err
.
mode
);
}
can_bus_hook
(
can
,
&
canled
[
1
]);
}
#endif
/*USING_BXCAN2*/
int
can_bus_hook_init
(
void
)
{
rt_device_t
candev
;
#ifdef USING_BXCAN1
candev
=
rt_device_find
(
"bxcan1"
);
RT_ASSERT
(
candev
);
rt_device_control
(
candev
,
RT_CAN_CMD_SET_BUS_HOOK
,(
void
*
)
can1_bus_hook
);
#endif
/*USING_BXCAN1*/
#ifdef USING_BXCAN2
candev
=
rt_device_find
(
"bxcan2"
);
RT_ASSERT
(
candev
);
rt_device_control
(
candev
,
RT_CAN_CMD_SET_BUS_HOOK
,(
void
*
)
can2_bus_hook
);
#endif
/*USING_BXCAN2*/
return
RT_EOK
;
}
INIT_DEVICE_EXPORT
(
can_bus_hook_init
);
struct
can_app_struct
{
const
char
*
name
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录