Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逝缘~
rt-thread
提交
c1168675
R
rt-thread
项目概览
逝缘~
/
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,发现更多精彩内容 >>
提交
c1168675
编写于
9月 24, 2019
作者:
T
tangweikang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32][driver][drv_pulse_encoder.c] code style
上级
f1fe6479
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
72 addition
and
62 deletion
+72
-62
bsp/stm32/libraries/HAL_Drivers/config/f1/pulse_encoder_config.h
...32/libraries/HAL_Drivers/config/f1/pulse_encoder_config.h
+20
-16
bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
+52
-46
未找到文件。
bsp/stm32/libraries/HAL_Drivers/config/f1/pulse_encoder_config.h
浏览文件 @
c1168675
...
@@ -22,6 +22,7 @@ extern "C" {
...
@@ -22,6 +22,7 @@ extern "C" {
#define PULSE_ENCODER1_CONFIG \
#define PULSE_ENCODER1_CONFIG \
{ \
{ \
.tim_handler.Instance = TIM1, \
.tim_handler.Instance = TIM1, \
.encoder_irqn = TIM1_UP_IRQn, \
.name = "pulse1" \
.name = "pulse1" \
}
}
#endif
/* PULSE_ENCODER1_CONFIG */
#endif
/* PULSE_ENCODER1_CONFIG */
...
@@ -32,6 +33,7 @@ extern "C" {
...
@@ -32,6 +33,7 @@ extern "C" {
#define PULSE_ENCODER2_CONFIG \
#define PULSE_ENCODER2_CONFIG \
{ \
{ \
.tim_handler.Instance = TIM2, \
.tim_handler.Instance = TIM2, \
.encoder_irqn = TIM2_IRQn, \
.name = "pulse2" \
.name = "pulse2" \
}
}
#endif
/* PULSE_ENCODER2_CONFIG */
#endif
/* PULSE_ENCODER2_CONFIG */
...
@@ -42,6 +44,7 @@ extern "C" {
...
@@ -42,6 +44,7 @@ extern "C" {
#define PULSE_ENCODER3_CONFIG \
#define PULSE_ENCODER3_CONFIG \
{ \
{ \
.tim_handler.Instance = TIM3, \
.tim_handler.Instance = TIM3, \
.encoder_irqn = TIM3_IRQn, \
.name = "pulse3" \
.name = "pulse3" \
}
}
#endif
/* PULSE_ENCODER3_CONFIG */
#endif
/* PULSE_ENCODER3_CONFIG */
...
@@ -52,6 +55,7 @@ extern "C" {
...
@@ -52,6 +55,7 @@ extern "C" {
#define PULSE_ENCODER4_CONFIG \
#define PULSE_ENCODER4_CONFIG \
{ \
{ \
.tim_handler.Instance = TIM4, \
.tim_handler.Instance = TIM4, \
.encoder_irqn = TIM4_IRQn, \
.name = "pulse4" \
.name = "pulse4" \
}
}
#endif
/* PULSE_ENCODER4_CONFIG */
#endif
/* PULSE_ENCODER4_CONFIG */
...
...
bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
浏览文件 @
c1168675
...
@@ -51,7 +51,7 @@ struct stm32_pulse_encoder_device
...
@@ -51,7 +51,7 @@ struct stm32_pulse_encoder_device
struct
rt_pulse_encoder_device
pulse_encoder
;
struct
rt_pulse_encoder_device
pulse_encoder
;
TIM_HandleTypeDef
tim_handler
;
TIM_HandleTypeDef
tim_handler
;
IRQn_Type
encoder_irqn
;
IRQn_Type
encoder_irqn
;
volatile
rt_int32_t
over_under_flowcount
;
rt_int32_t
over_under_flowcount
;
char
*
name
;
char
*
name
;
};
};
...
@@ -82,7 +82,7 @@ rt_err_t pulse_encoder_init(struct rt_pulse_encoder_device *pulse_encoder)
...
@@ -82,7 +82,7 @@ rt_err_t pulse_encoder_init(struct rt_pulse_encoder_device *pulse_encoder)
TIM_Encoder_InitTypeDef
sConfig
;
TIM_Encoder_InitTypeDef
sConfig
;
TIM_MasterConfigTypeDef
sMasterConfig
;
TIM_MasterConfigTypeDef
sMasterConfig
;
struct
stm32_pulse_encoder_device
*
stm32_device
;
struct
stm32_pulse_encoder_device
*
stm32_device
;
stm32_device
=
rt_container_of
(
pulse_encoder
,
struct
stm32_pulse_encoder_device
,
pulse_encoder
)
;
stm32_device
=
(
struct
stm32_pulse_encoder_device
*
)
pulse_encoder
;
stm32_device
->
tim_handler
.
Init
.
Prescaler
=
0
;
stm32_device
->
tim_handler
.
Init
.
Prescaler
=
0
;
stm32_device
->
tim_handler
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
stm32_device
->
tim_handler
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
...
@@ -133,7 +133,7 @@ rt_err_t pulse_encoder_init(struct rt_pulse_encoder_device *pulse_encoder)
...
@@ -133,7 +133,7 @@ rt_err_t pulse_encoder_init(struct rt_pulse_encoder_device *pulse_encoder)
rt_err_t
pulse_encoder_clear_count
(
struct
rt_pulse_encoder_device
*
pulse_encoder
)
rt_err_t
pulse_encoder_clear_count
(
struct
rt_pulse_encoder_device
*
pulse_encoder
)
{
{
struct
stm32_pulse_encoder_device
*
stm32_device
;
struct
stm32_pulse_encoder_device
*
stm32_device
;
stm32_device
=
rt_container_of
(
pulse_encoder
,
struct
stm32_pulse_encoder_device
,
pulse_encoder
)
;
stm32_device
=
(
struct
stm32_pulse_encoder_device
*
)
pulse_encoder
;
stm32_device
->
over_under_flowcount
=
0
;
stm32_device
->
over_under_flowcount
=
0
;
__HAL_TIM_SET_COUNTER
(
&
stm32_device
->
tim_handler
,
0
);
__HAL_TIM_SET_COUNTER
(
&
stm32_device
->
tim_handler
,
0
);
return
RT_EOK
;
return
RT_EOK
;
...
@@ -142,15 +142,15 @@ rt_err_t pulse_encoder_clear_count(struct rt_pulse_encoder_device *pulse_encoder
...
@@ -142,15 +142,15 @@ rt_err_t pulse_encoder_clear_count(struct rt_pulse_encoder_device *pulse_encoder
rt_int32_t
pulse_encoder_get_count
(
struct
rt_pulse_encoder_device
*
pulse_encoder
)
rt_int32_t
pulse_encoder_get_count
(
struct
rt_pulse_encoder_device
*
pulse_encoder
)
{
{
struct
stm32_pulse_encoder_device
*
stm32_device
;
struct
stm32_pulse_encoder_device
*
stm32_device
;
stm32_device
=
rt_container_of
(
pulse_encoder
,
struct
stm32_pulse_encoder_device
,
pulse_encoder
)
;
stm32_device
=
(
struct
stm32_pulse_encoder_device
*
)
pulse_encoder
;
return
(
rt_int32_t
)((
rt_int16_t
)
__HAL_TIM_GET_COUNTER
(
&
stm32_device
->
tim_handler
)
+
stm32_device
->
over_under_flowcount
*
AUTO_RELOAD_VALUE
);
return
(
rt_int32_t
)((
rt_int16_t
)
__HAL_TIM_GET_COUNTER
(
&
stm32_device
->
tim_handler
)
+
stm32_device
->
over_under_flowcount
*
AUTO_RELOAD_VALUE
);
}
}
rt_err_t
pulse_encoder_control
(
struct
rt_pulse_encoder_device
*
pulse_encoder
,
rt_uint32_t
cmd
,
void
*
args
)
rt_err_t
pulse_encoder_control
(
struct
rt_pulse_encoder_device
*
pulse_encoder
,
rt_uint32_t
cmd
,
void
*
args
)
{
{
rt_err_t
result
;
rt_err_t
result
;
struct
stm32_pulse_encoder_device
*
stm32_device
;
struct
stm32_pulse_encoder_device
*
stm32_device
;
stm32_device
=
rt_container_of
(
pulse_encoder
,
struct
stm32_pulse_encoder_device
,
pulse_encoder
)
;
stm32_device
=
(
struct
stm32_pulse_encoder_device
*
)
pulse_encoder
;
result
=
RT_EOK
;
result
=
RT_EOK
;
...
@@ -178,7 +178,7 @@ void pulse_encoder_update_isr(struct stm32_pulse_encoder_device *device)
...
@@ -178,7 +178,7 @@ void pulse_encoder_update_isr(struct stm32_pulse_encoder_device *device)
if
(
__HAL_TIM_GET_FLAG
(
&
device
->
tim_handler
,
TIM_FLAG_UPDATE
)
!=
RESET
)
if
(
__HAL_TIM_GET_FLAG
(
&
device
->
tim_handler
,
TIM_FLAG_UPDATE
)
!=
RESET
)
{
{
__HAL_TIM_CLEAR_IT
(
&
device
->
tim_handler
,
TIM_IT_UPDATE
);
__HAL_TIM_CLEAR_IT
(
&
device
->
tim_handler
,
TIM_IT_UPDATE
);
if
(
__HAL_TIM_IS_TIM_COUNTING_DOWN
(
&
device
->
tim_handler
))
if
(
__HAL_TIM_IS_TIM_COUNTING_DOWN
(
&
device
->
tim_handler
))
{
{
device
->
over_under_flowcount
--
;
device
->
over_under_flowcount
--
;
}
}
...
@@ -225,7 +225,13 @@ void pulse_encoder_update_isr(struct stm32_pulse_encoder_device *device)
...
@@ -225,7 +225,13 @@ void pulse_encoder_update_isr(struct stm32_pulse_encoder_device *device)
}
}
#ifdef BSP_USING_PULSE_ENCODER1
#ifdef BSP_USING_PULSE_ENCODER1
void
TIM1_UP_TIM10_IRQHandler
(
void
)
#if defined(SOC_SERIES_STM32F4)
void
TIM1_UP_TIM10_IRQHandler
(
void
)
#elif defined(SOC_SERIES_STM32F1)
void
TIM1_UP_IRQHandler
(
void
)
#else
#error "Please check TIM1's IRQHandler"
#endif
{
{
/* enter interrupt */
/* enter interrupt */
rt_interrupt_enter
();
rt_interrupt_enter
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录