Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
失败笔记本
rt-thread
提交
14722a48
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,发现更多精彩内容 >>
提交
14722a48
编写于
10月 29, 2022
作者:
L
linshire
提交者:
mysterywolf
10月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "提交stm32 bsp drv_pwm.c里面的一个小建议 (#6517)"
This reverts commit
a4eb5a53
.
上级
a4eb5a53
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
42 addition
and
130 deletion
+42
-130
bsp/stm32/libraries/HAL_Drivers/config/f0/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/f0/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/f1/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/f1/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/f2/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/f2/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/f3/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/f3/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/f4/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/f4/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/f7/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/f7/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/g0/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/g0/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/g4/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/g4/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/h7/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/h7/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/l1/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/l1/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/l4/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/l4/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/l5/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/l5/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/mp1/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/mp1/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/u5/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/u5/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/config/wb/pwm_config.h
bsp/stm32/libraries/HAL_Drivers/config/wb/pwm_config.h
+0
-6
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
+42
-40
未找到文件。
bsp/stm32/libraries/HAL_Drivers/config/f0/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/f1/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/f2/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/f3/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/f4/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/f7/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/g0/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -18,12 +18,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/g4/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/h7/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -18,12 +18,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/l1/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/l4/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/l5/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/mp1/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM2
#ifndef PWM2_CONFIG
#define PWM2_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/u5/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/config/wb/pwm_config.h
浏览文件 @
14722a48
...
...
@@ -17,12 +17,6 @@
extern
"C"
{
#endif
/*
* .tim_handle.Instance = TIM1/2/3...,
* .name = "your pwm device name",
* .channel = 1/2/3/4
*/
#ifdef BSP_USING_PWM1
#ifndef PWM1_CONFIG
#define PWM1_CONFIG \
...
...
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
浏览文件 @
14722a48
...
...
@@ -234,13 +234,7 @@ static struct rt_pwm_ops drv_ops =
static
rt_err_t
drv_pwm_enable
(
TIM_HandleTypeDef
*
htim
,
struct
rt_pwm_configuration
*
configuration
,
rt_bool_t
enable
)
{
/* Converts the channel number to the channel number of Hal library */
rt_uint32_t
channel
=
configuration
->
channel
;
if
(
channel
<
1
||
channel
>
4
)
{
LOG_E
(
"pwm channel %d is invalid, failed to enable"
,
configuration
->
channel
);
return
-
RT_ERROR
;
}
channel
=
0x04
*
(
configuration
->
channel
-
1
);
rt_uint32_t
channel
=
0x04
*
(
configuration
->
channel
-
1
);
if
(
!
configuration
->
complementary
)
{
...
...
@@ -271,13 +265,7 @@ static rt_err_t drv_pwm_enable(TIM_HandleTypeDef *htim, struct rt_pwm_configurat
static
rt_err_t
drv_pwm_get
(
TIM_HandleTypeDef
*
htim
,
struct
rt_pwm_configuration
*
configuration
)
{
/* Converts the channel number to the channel number of Hal library */
rt_uint32_t
channel
=
configuration
->
channel
;
if
(
channel
<
1
||
channel
>
4
)
{
LOG_E
(
"pwm channel %d is invalid, failed to get"
,
configuration
->
channel
);
return
-
RT_ERROR
;
}
channel
=
0x04
*
(
configuration
->
channel
-
1
);
rt_uint32_t
channel
=
0x04
*
(
configuration
->
channel
-
1
);
rt_uint64_t
tim_clock
;
tim_clock
=
tim_clock_get
(
htim
);
...
...
@@ -303,13 +291,7 @@ static rt_err_t drv_pwm_set(TIM_HandleTypeDef *htim, struct rt_pwm_configuration
rt_uint32_t
period
,
pulse
;
rt_uint64_t
tim_clock
,
psc
;
/* Converts the channel number to the channel number of Hal library */
rt_uint32_t
channel
=
configuration
->
channel
;
if
(
channel
<
1
||
channel
>
4
)
{
LOG_E
(
"pwm channel %d is invalid, failed to set"
,
configuration
->
channel
);
return
-
RT_ERROR
;
}
channel
=
0x04
*
(
configuration
->
channel
-
1
);
rt_uint32_t
channel
=
0x04
*
(
configuration
->
channel
-
1
);
tim_clock
=
tim_clock_get
(
htim
);
/* Convert nanosecond to frequency and duty cycle. 1s = 1 * 1000 * 1000 * 1000 ns */
...
...
@@ -372,13 +354,7 @@ static rt_err_t drv_pwm_set_pulse(TIM_HandleTypeDef *htim, struct rt_pwm_configu
rt_uint32_t
period
,
pulse
;
rt_uint64_t
tim_clock
;
/* Converts the channel number to the channel number of Hal library */
rt_uint32_t
channel
=
configuration
->
channel
;
if
(
channel
<
1
||
channel
>
4
)
{
LOG_E
(
"pwm channel %d is invalid, failed to set pulse"
,
configuration
->
channel
);
return
-
RT_ERROR
;
}
channel
=
0x04
*
(
configuration
->
channel
-
1
);
rt_uint32_t
channel
=
0x04
*
(
configuration
->
channel
-
1
);
tim_clock
=
tim_clock_get
(
htim
);
/* Convert nanosecond to frequency and duty cycle. 1s = 1 * 1000 * 1000 * 1000 ns */
...
...
@@ -432,14 +408,6 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
TIM_MasterConfigTypeDef
master_config
=
{
0
};
TIM_ClockConfigTypeDef
clock_config
=
{
0
};
rt_uint32_t
channel
=
device
->
channel
;
if
(
channel
<
1
||
channel
>
4
)
{
LOG_E
(
"%s pwm channel %d is invalid, failed to init"
,
device
->
name
,
device
->
channel
);
return
-
RT_ERROR
;
}
channel
=
0x04
*
(
device
->
channel
-
1
);
RT_ASSERT
(
device
!=
RT_NULL
);
tim
=
(
TIM_HandleTypeDef
*
)
&
device
->
tim_handle
;
...
...
@@ -490,11 +458,45 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
oc_config
.
OCNIdleState
=
TIM_OCNIDLESTATE_RESET
;
oc_config
.
OCIdleState
=
TIM_OCIDLESTATE_RESET
;
if
(
HAL_TIM_PWM_ConfigChannel
(
tim
,
&
oc_config
,
channel
)
!=
HAL_OK
)
/* config pwm channel */
if
(
device
->
channel
&
0x01
)
{
LOG_E
(
"%s %d config failed"
,
device
->
name
,
device
->
channel
);
result
=
-
RT_ERROR
;
goto
__exit
;
if
(
HAL_TIM_PWM_ConfigChannel
(
tim
,
&
oc_config
,
TIM_CHANNEL_1
)
!=
HAL_OK
)
{
LOG_E
(
"%s channel1 config failed"
,
device
->
name
);
result
=
-
RT_ERROR
;
goto
__exit
;
}
}
if
(
device
->
channel
&
0x02
)
{
if
(
HAL_TIM_PWM_ConfigChannel
(
tim
,
&
oc_config
,
TIM_CHANNEL_2
)
!=
HAL_OK
)
{
LOG_E
(
"%s channel2 config failed"
,
device
->
name
);
result
=
-
RT_ERROR
;
goto
__exit
;
}
}
if
(
device
->
channel
&
0x04
)
{
if
(
HAL_TIM_PWM_ConfigChannel
(
tim
,
&
oc_config
,
TIM_CHANNEL_3
)
!=
HAL_OK
)
{
LOG_E
(
"%s channel3 config failed"
,
device
->
name
);
result
=
-
RT_ERROR
;
goto
__exit
;
}
}
if
(
device
->
channel
&
0x08
)
{
if
(
HAL_TIM_PWM_ConfigChannel
(
tim
,
&
oc_config
,
TIM_CHANNEL_4
)
!=
HAL_OK
)
{
LOG_E
(
"%s channel4 config failed"
,
device
->
name
);
result
=
-
RT_ERROR
;
goto
__exit
;
}
}
/* pwm pin configuration */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录