Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
b76d3dac
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b76d3dac
编写于
8月 30, 2019
作者:
T
tangweikang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[components][drivers] change name: encoder -> pulse_encoder
上级
05b1dff0
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
522 addition
and
210 deletion
+522
-210
bsp/stm32/libraries/HAL_Drivers/SConscript
bsp/stm32/libraries/HAL_Drivers/SConscript
+2
-2
bsp/stm32/libraries/HAL_Drivers/config/f1/encoder_config.h
bsp/stm32/libraries/HAL_Drivers/config/f1/encoder_config.h
+0
-64
bsp/stm32/libraries/HAL_Drivers/config/f1/pulse_encoder_config.h
...32/libraries/HAL_Drivers/config/f1/pulse_encoder_config.h
+64
-0
bsp/stm32/libraries/HAL_Drivers/config/f4/encoder_config.h
bsp/stm32/libraries/HAL_Drivers/config/f4/encoder_config.h
+0
-64
bsp/stm32/libraries/HAL_Drivers/config/f4/pulse_encoder_config.h
...32/libraries/HAL_Drivers/config/f4/pulse_encoder_config.h
+64
-0
bsp/stm32/libraries/HAL_Drivers/drv_config.h
bsp/stm32/libraries/HAL_Drivers/drv_config.h
+2
-2
bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
+176
-0
bsp/stm32/libraries/STM32F1xx_HAL/SConscript
bsp/stm32/libraries/STM32F1xx_HAL/SConscript
+1
-1
bsp/stm32/libraries/STM32F4xx_HAL/SConscript
bsp/stm32/libraries/STM32F4xx_HAL/SConscript
+1
-1
bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig
bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig
+6
-6
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
+6
-6
components/drivers/Kconfig
components/drivers/Kconfig
+2
-2
components/drivers/include/drivers/encoder.h
components/drivers/include/drivers/encoder.h
+0
-58
components/drivers/include/drivers/pulse_encoder.h
components/drivers/include/drivers/pulse_encoder.h
+58
-0
components/drivers/include/rtdevice.h
components/drivers/include/rtdevice.h
+2
-2
components/drivers/misc/SConscript
components/drivers/misc/SConscript
+2
-2
components/drivers/misc/pulse_encoder.c
components/drivers/misc/pulse_encoder.c
+136
-0
未找到文件。
bsp/stm32/libraries/HAL_Drivers/SConscript
浏览文件 @
b76d3dac
...
...
@@ -85,8 +85,8 @@ if GetDepend(['BSP_USING_SDIO']):
if
GetDepend
([
'BSP_USING_USBD_FS'
]):
src
+=
[
'drv_usbd_fs.c'
]
if
GetDepend
([
'BSP_USING_ENCODER'
]):
src
+=
[
'drv_encoder.c'
]
if
GetDepend
([
'BSP_USING_
PULSE_
ENCODER'
]):
src
+=
[
'drv_
pulse_
encoder.c'
]
src
+=
[
'drv_common.c'
]
...
...
bsp/stm32/libraries/HAL_Drivers/config/f1/encoder_config.h
已删除
100644 → 0
浏览文件 @
05b1dff0
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-08-23 balanceTWK first version
*/
#ifndef __ENCODER_CONFIG_H__
#define __ENCODER_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef BSP_USING_ENCODER1
#ifndef ENCODER1_CONFIG
#define ENCODER1_CONFIG \
{ \
.tim_handler.Instance = TIM1, \
.name = "encoder1" \
}
#endif
/* ENCODER1_CONFIG */
#endif
/* BSP_USING_ENCODER1 */
#ifdef BSP_USING_ENCODER2
#ifndef ENCODER2_CONFIG
#define ENCODER2_CONFIG \
{ \
.tim_handler.Instance = TIM2, \
.name = "encoder2" \
}
#endif
/* ENCODER2_CONFIG */
#endif
/* BSP_USING_ENCODER2 */
#ifdef BSP_USING_ENCODER3
#ifndef ENCODER3_CONFIG
#define ENCODER3_CONFIG \
{ \
.tim_handler.Instance = TIM3, \
.name = "encoder3" \
}
#endif
/* ENCODER3_CONFIG */
#endif
/* BSP_USING_ENCODER3 */
#ifdef BSP_USING_ENCODER4
#ifndef ENCODER4_CONFIG
#define ENCODER4_CONFIG \
{ \
.tim_handler.Instance = TIM4, \
.name = "encoder4" \
}
#endif
/* ENCODER4_CONFIG */
#endif
/* BSP_USING_ENCODER4 */
#ifdef __cplusplus
}
#endif
#endif
/* __ENCODER_CONFIG_H__ */
bsp/stm32/libraries/HAL_Drivers/config/f1/pulse_encoder_config.h
0 → 100644
浏览文件 @
b76d3dac
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-08-23 balanceTWK first version
*/
#ifndef __PULSE_ENCODER_CONFIG_H__
#define __PULSE_ENCODER_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef BSP_USING_PULSE_ENCODER1
#ifndef PULSE_ENCODER1_CONFIG
#define PULSE_ENCODER1_CONFIG \
{ \
.tim_handler.Instance = TIM1, \
.name = "pulse1" \
}
#endif
/* PULSE_ENCODER1_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER1 */
#ifdef BSP_USING_PULSE_ENCODER2
#ifndef PULSE_ENCODER2_CONFIG
#define PULSE_ENCODER2_CONFIG \
{ \
.tim_handler.Instance = TIM2, \
.name = "pulse2" \
}
#endif
/* PULSE_ENCODER2_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER2 */
#ifdef BSP_USING_PULSE_ENCODER3
#ifndef PULSE_ENCODER3_CONFIG
#define PULSE_ENCODER3_CONFIG \
{ \
.tim_handler.Instance = TIM3, \
.name = "pulse3" \
}
#endif
/* PULSE_ENCODER3_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER3 */
#ifdef BSP_USING_PULSE_ENCODER4
#ifndef PULSE_ENCODER4_CONFIG
#define PULSE_ENCODER4_CONFIG \
{ \
.tim_handler.Instance = TIM4, \
.name = "pulse4" \
}
#endif
/* PULSE_ENCODER4_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER4 */
#ifdef __cplusplus
}
#endif
#endif
/* __PULSE_ENCODER_CONFIG_H__ */
bsp/stm32/libraries/HAL_Drivers/config/f4/encoder_config.h
已删除
100644 → 0
浏览文件 @
05b1dff0
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-08-23 balanceTWK first version
*/
#ifndef __ENCODER_CONFIG_H__
#define __ENCODER_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef BSP_USING_ENCODER1
#ifndef ENCODER1_CONFIG
#define ENCODER1_CONFIG \
{ \
.tim_handler.Instance = TIM1, \
.name = "encoder1" \
}
#endif
/* ENCODER1_CONFIG */
#endif
/* BSP_USING_ENCODER1 */
#ifdef BSP_USING_ENCODER2
#ifndef ENCODER2_CONFIG
#define ENCODER2_CONFIG \
{ \
.tim_handler.Instance = TIM2, \
.name = "encoder2" \
}
#endif
/* ENCODER2_CONFIG */
#endif
/* BSP_USING_ENCODER2 */
#ifdef BSP_USING_ENCODER3
#ifndef ENCODER3_CONFIG
#define ENCODER3_CONFIG \
{ \
.tim_handler.Instance = TIM3, \
.name = "encoder3" \
}
#endif
/* ENCODER3_CONFIG */
#endif
/* BSP_USING_ENCODER3 */
#ifdef BSP_USING_ENCODER4
#ifndef ENCODER4_CONFIG
#define ENCODER4_CONFIG \
{ \
.tim_handler.Instance = TIM4, \
.name = "encoder4" \
}
#endif
/* ENCODER4_CONFIG */
#endif
/* BSP_USING_ENCODER4 */
#ifdef __cplusplus
}
#endif
#endif
/* __ENCODER_CONFIG_H__ */
bsp/stm32/libraries/HAL_Drivers/config/f4/pulse_encoder_config.h
0 → 100644
浏览文件 @
b76d3dac
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-08-23 balanceTWK first version
*/
#ifndef __PULSE_ENCODER_CONFIG_H__
#define __PULSE_ENCODER_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef BSP_USING_PULSE_ENCODER1
#ifndef PULSE_ENCODER1_CONFIG
#define PULSE_ENCODER1_CONFIG \
{ \
.tim_handler.Instance = TIM1, \
.name = "pulse1" \
}
#endif
/* PULSE_ENCODER1_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER1 */
#ifdef BSP_USING_PULSE_ENCODER2
#ifndef PULSE_ENCODER2_CONFIG
#define PULSE_ENCODER2_CONFIG \
{ \
.tim_handler.Instance = TIM2, \
.name = "pulse2" \
}
#endif
/* PULSE_ENCODER2_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER2 */
#ifdef BSP_USING_PULSE_ENCODER3
#ifndef PULSE_ENCODER3_CONFIG
#define PULSE_ENCODER3_CONFIG \
{ \
.tim_handler.Instance = TIM3, \
.name = "pulse3" \
}
#endif
/* PULSE_ENCODER3_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER3 */
#ifdef BSP_USING_PULSE_ENCODER4
#ifndef PULSE_ENCODER4_CONFIG
#define PULSE_ENCODER4_CONFIG \
{ \
.tim_handler.Instance = TIM4, \
.name = "pulse4" \
}
#endif
/* PULSE_ENCODER4_CONFIG */
#endif
/* BSP_USING_PULSE_ENCODER4 */
#ifdef __cplusplus
}
#endif
#endif
/* __PULSE_ENCODER_CONFIG_H__ */
bsp/stm32/libraries/HAL_Drivers/drv_config.h
浏览文件 @
b76d3dac
...
...
@@ -34,7 +34,7 @@ extern "C" {
#include "f1/sdio_config.h"
#include "f1/pwm_config.h"
#include "f1/usbd_fs_config.h"
#include "f1/encoder_config.h"
#include "f1/
pulse_
encoder_config.h"
#elif defined(SOC_SERIES_STM32F2)
#include "f2/dma_config.h"
#include "f2/uart_config.h"
...
...
@@ -53,7 +53,7 @@ extern "C" {
#include "f4/tim_config.h"
#include "f4/sdio_config.h"
#include "f4/pwm_config.h"
#include "f4/encoder_config.h"
#include "f4/
pulse_
encoder_config.h"
#elif defined(SOC_SERIES_STM32F7)
#include "f7/dma_config.h"
#include "f7/uart_config.h"
...
...
bsp/stm32/libraries/HAL_Drivers/drv_encoder.c
→
bsp/stm32/libraries/HAL_Drivers/drv_
pulse_
encoder.c
浏览文件 @
b76d3dac
...
...
@@ -10,74 +10,74 @@
#include "board.h"
#include "drv_config.h"
#ifdef RT_USING_ENCODER
#ifdef RT_USING_
PULSE_
ENCODER
//#define DRV_DEBUG
#define LOG_TAG "drv.encoder"
#define LOG_TAG "drv.
pulse_
encoder"
#include <drv_log.h>
#if !defined(BSP_USING_
ENCODER1) && !defined(BSP_USING_ENCODER2) && !defined(BSP_USING
_ENCODER3) \
&& !defined(BSP_USING_
ENCODER4) && !defined(BSP_USING_ENCODER5) && !defined(BSP_USING_ENCODER6) && !defined(BSP_USING_LPENCODER1
)
#error "Please define at least one BSP_USING_ENCODERx"
#if !defined(BSP_USING_
PULSE_ENCODER1) && !defined(BSP_USING_PULSE_ENCODER2) && !defined(BSP_USING_PULSE
_ENCODER3) \
&& !defined(BSP_USING_
PULSE_ENCODER4) && !defined(BSP_USING_PULSE_ENCODER5) && !defined(BSP_USING_PULSE_ENCODER6
)
#error "Please define at least one BSP_USING_
PULSE_
ENCODERx"
/* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */
#endif
enum
{
#ifdef BSP_USING_ENCODER1
ENCODER1_INDEX
,
#ifdef BSP_USING_
PULSE_
ENCODER1
PULSE_
ENCODER1_INDEX
,
#endif
#ifdef BSP_USING_ENCODER2
ENCODER2_INDEX
,
#ifdef BSP_USING_
PULSE_
ENCODER2
PULSE_
ENCODER2_INDEX
,
#endif
#ifdef BSP_USING_ENCODER3
ENCODER3_INDEX
,
#ifdef BSP_USING_
PULSE_
ENCODER3
PULSE_
ENCODER3_INDEX
,
#endif
#ifdef BSP_USING_ENCODER4
ENCODER4_INDEX
,
#ifdef BSP_USING_
PULSE_
ENCODER4
PULSE_
ENCODER4_INDEX
,
#endif
#ifdef BSP_USING_ENCODER5
ENCODER5_INDEX
,
#ifdef BSP_USING_
PULSE_
ENCODER5
PULSE_
ENCODER5_INDEX
,
#endif
#ifdef BSP_USING_ENCODER6
ENCODER6_INDEX
,
#ifdef BSP_USING_
PULSE_
ENCODER6
PULSE_
ENCODER6_INDEX
,
#endif
};
struct
stm32_encoder_device
struct
stm32_
pulse_
encoder_device
{
struct
rt_
encoder_device
encoder
;
struct
rt_
pulse_encoder_device
pulse_
encoder
;
TIM_HandleTypeDef
tim_handler
;
char
*
name
;
};
static
struct
stm32_
encoder_device
stm32
_encoder_obj
[]
=
static
struct
stm32_
pulse_encoder_device
stm32_pulse
_encoder_obj
[]
=
{
#ifdef BSP_USING_ENCODER1
ENCODER1_CONFIG
,
#ifdef BSP_USING_
PULSE_
ENCODER1
PULSE_
ENCODER1_CONFIG
,
#endif
#ifdef BSP_USING_ENCODER2
ENCODER2_CONFIG
,
#ifdef BSP_USING_
PULSE_
ENCODER2
PULSE_
ENCODER2_CONFIG
,
#endif
#ifdef BSP_USING_ENCODER3
ENCODER3_CONFIG
,
#ifdef BSP_USING_
PULSE_
ENCODER3
PULSE_
ENCODER3_CONFIG
,
#endif
#ifdef BSP_USING_ENCODER4
ENCODER4_CONFIG
,
#ifdef BSP_USING_
PULSE_
ENCODER4
PULSE_
ENCODER4_CONFIG
,
#endif
#ifdef BSP_USING_ENCODER5
ENCODER5_CONFIG
,
#ifdef BSP_USING_
PULSE_
ENCODER5
PULSE_
ENCODER5_CONFIG
,
#endif
#ifdef BSP_USING_ENCODER6
ENCODER6_CONFIG
,
#ifdef BSP_USING_
PULSE_
ENCODER6
PULSE_
ENCODER6_CONFIG
,
#endif
};
rt_err_t
encoder_init
(
struct
rt_encoder_device
*
encoder
)
rt_err_t
pulse_encoder_init
(
struct
rt_pulse_encoder_device
*
pulse_
encoder
)
{
TIM_Encoder_InitTypeDef
sConfig
;
TIM_MasterConfigTypeDef
sMasterConfig
;
TIM_HandleTypeDef
*
tim_handler
=
(
TIM_HandleTypeDef
*
)
encoder
->
parent
.
user_data
;
TIM_HandleTypeDef
*
tim_handler
=
(
TIM_HandleTypeDef
*
)
pulse_
encoder
->
parent
.
user_data
;
tim_handler
->
Init
.
Prescaler
=
0
;
tim_handler
->
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
...
...
@@ -96,7 +96,7 @@ rt_err_t encoder_init(struct rt_encoder_device *encoder)
if
(
HAL_TIM_Encoder_Init
(
tim_handler
,
&
sConfig
)
!=
HAL_OK
)
{
LOG_E
(
"encoder init failed"
);
LOG_E
(
"
pulse_
encoder init failed"
);
return
-
RT_ERROR
;
}
...
...
@@ -112,28 +112,28 @@ rt_err_t encoder_init(struct rt_encoder_device *encoder)
return
RT_EOK
;
}
rt_int32_t
encoder_get_count
(
struct
rt_encoder_device
*
encoder
)
rt_int32_t
pulse_encoder_get_count
(
struct
rt_pulse_encoder_device
*
pulse_
encoder
)
{
TIM_HandleTypeDef
*
tim_handler
=
(
TIM_HandleTypeDef
*
)
encoder
->
parent
.
user_data
;
TIM_HandleTypeDef
*
tim_handler
=
(
TIM_HandleTypeDef
*
)
pulse_
encoder
->
parent
.
user_data
;
return
(
rt_int16_t
)
__HAL_TIM_GET_COUNTER
(
tim_handler
);
}
rt_err_t
encoder_control
(
struct
rt_encoder_device
*
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
;
TIM_HandleTypeDef
*
tim_handler
=
(
TIM_HandleTypeDef
*
)
encoder
->
parent
.
user_data
;
TIM_HandleTypeDef
*
tim_handler
=
(
TIM_HandleTypeDef
*
)
pulse_
encoder
->
parent
.
user_data
;
result
=
RT_EOK
;
switch
(
cmd
)
{
case
ENCODER_CMD_ENABLE
:
case
PULSE_
ENCODER_CMD_ENABLE
:
HAL_TIM_Encoder_Start
(
tim_handler
,
TIM_CHANNEL_ALL
);
break
;
case
ENCODER_CMD_DISABLE
:
case
PULSE_
ENCODER_CMD_DISABLE
:
HAL_TIM_Encoder_Stop
(
tim_handler
,
TIM_CHANNEL_ALL
);
break
;
case
ENCODER_CMD_CLEAR_COUNT
:
case
PULSE_
ENCODER_CMD_CLEAR_COUNT
:
__HAL_TIM_SET_COUNTER
(
tim_handler
,
0
);
break
;
default:
...
...
@@ -144,33 +144,33 @@ rt_err_t encoder_control(struct rt_encoder_device *encoder, rt_uint32_t cmd, voi
return
result
;
}
static
const
struct
rt_encoder_ops
_ops
=
static
const
struct
rt_
pulse_
encoder_ops
_ops
=
{
.
init
=
encoder_init
,
.
get_count
=
encoder_get_count
,
.
control
=
encoder_control
,
.
init
=
pulse_
encoder_init
,
.
get_count
=
pulse_
encoder_get_count
,
.
control
=
pulse_
encoder_control
,
};
int
hw_encoder_init
(
void
)
int
hw_
pulse_
encoder_init
(
void
)
{
int
i
;
int
result
;
result
=
RT_EOK
;
for
(
i
=
0
;
i
<
sizeof
(
stm32_
encoder_obj
)
/
sizeof
(
stm32
_encoder_obj
[
0
]);
i
++
)
for
(
i
=
0
;
i
<
sizeof
(
stm32_
pulse_encoder_obj
)
/
sizeof
(
stm32_pulse
_encoder_obj
[
0
]);
i
++
)
{
stm32_
encoder_obj
[
i
].
encoder
.
type
=
AB_PHA
SE_ENCODER
;
stm32_
encoder_obj
[
i
].
encoder
.
ops
=
&
_ops
;
stm32_
pulse_encoder_obj
[
i
].
pulse_encoder
.
type
=
AB_PHASE_PUL
SE_ENCODER
;
stm32_
pulse_encoder_obj
[
i
].
pulse_
encoder
.
ops
=
&
_ops
;
if
(
rt_device_
encoder_register
(
&
stm32_encoder_obj
[
i
].
encoder
,
stm32_encoder_obj
[
i
].
name
,
&
stm32
_encoder_obj
[
i
].
tim_handler
)
!=
RT_EOK
)
if
(
rt_device_
pulse_encoder_register
(
&
stm32_pulse_encoder_obj
[
i
].
pulse_encoder
,
stm32_pulse_encoder_obj
[
i
].
name
,
&
stm32_pulse
_encoder_obj
[
i
].
tim_handler
)
!=
RT_EOK
)
{
LOG_E
(
"%s register failed"
,
stm32_encoder_obj
[
i
].
name
);
LOG_E
(
"%s register failed"
,
stm32_
pulse_
encoder_obj
[
i
].
name
);
result
=
-
RT_ERROR
;
}
}
return
result
;
}
INIT_BOARD_EXPORT
(
hw_encoder_init
);
INIT_BOARD_EXPORT
(
hw_
pulse_
encoder_init
);
#endif
bsp/stm32/libraries/STM32F1xx_HAL/SConscript
浏览文件 @
b76d3dac
...
...
@@ -44,7 +44,7 @@ if GetDepend(['RT_USING_USB_HOST']) or GetDepend(['RT_USING_USB_DEVICE']):
if
GetDepend
([
'RT_USING_CAN'
]):
src
+=
[
'STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c'
]
if
GetDepend
([
'RT_USING_HWTIMER'
])
or
GetDepend
([
'RT_USING_PWM'
])
or
GetDepend
([
'RT_USING_ENCODER'
]):
if
GetDepend
([
'RT_USING_HWTIMER'
])
or
GetDepend
([
'RT_USING_PWM'
])
or
GetDepend
([
'RT_USING_
PULSE_
ENCODER'
]):
src
+=
[
'STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c'
]
src
+=
[
'STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c'
]
...
...
bsp/stm32/libraries/STM32F4xx_HAL/SConscript
浏览文件 @
b76d3dac
...
...
@@ -46,7 +46,7 @@ if GetDepend(['RT_USING_USB_HOST']) or GetDepend(['RT_USING_USB_DEVICE']):
if
GetDepend
([
'RT_USING_CAN'
]):
src
+=
[
'STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c'
]
if
GetDepend
([
'RT_USING_HWTIMER'
])
or
GetDepend
([
'RT_USING_PWM'
])
or
GetDepend
([
'RT_USING_ENCODER'
]):
if
GetDepend
([
'RT_USING_HWTIMER'
])
or
GetDepend
([
'RT_USING_PWM'
])
or
GetDepend
([
'RT_USING_
PULSE_
ENCODER'
]):
src
+=
[
'STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c'
]
src
+=
[
'STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c'
]
src
+=
[
'STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_lptim.c'
]
...
...
bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig
浏览文件 @
b76d3dac
...
...
@@ -201,13 +201,13 @@ menu "On-chip Peripheral Drivers"
select RT_USING_WDT
default n
menuconfig BSP_USING_ENCODER
bool "Enable Encoder"
menuconfig BSP_USING_
PULSE_
ENCODER
bool "Enable
Pulse
Encoder"
default n
select RT_USING_ENCODER
if BSP_USING_ENCODER
config BSP_USING_ENCODER3
bool "Enable Encoder3"
select RT_USING_
PULSE_
ENCODER
if BSP_USING_
PULSE_
ENCODER
config BSP_USING_
PULSE_
ENCODER3
bool "Enable
Pulse
Encoder3"
default n
endif
...
...
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
浏览文件 @
b76d3dac
...
...
@@ -294,13 +294,13 @@ menu "On-chip Peripheral Drivers"
select RT_USING_DFS
default n
menuconfig BSP_USING_ENCODER
bool "Enable Encoder"
menuconfig BSP_USING_
PULSE_
ENCODER
bool "Enable
Pulse
Encoder"
default n
select RT_USING_ENCODER
if BSP_USING_ENCODER
config BSP_USING_ENCODER4
bool "Enable Encoder4"
select RT_USING_
PULSE_
ENCODER
if BSP_USING_
PULSE_
ENCODER
config BSP_USING_
PULSE_
ENCODER4
bool "Enable
Pulse
Encoder4"
default n
endif
...
...
components/drivers/Kconfig
浏览文件 @
b76d3dac
...
...
@@ -434,8 +434,8 @@ menuconfig RT_USING_HWCRYPTO
endif
endif
config RT_USING_ENCODER
bool "Using ENCODER device drivers"
config RT_USING_
PULSE_
ENCODER
bool "Using
PULSE
ENCODER device drivers"
default n
config RT_USING_INPUT_CAPTURE
...
...
components/drivers/include/drivers/encoder.h
已删除
100644 → 0
浏览文件 @
05b1dff0
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-08-08 balanceTWK the first version
*/
#ifndef __ENCODER_H__
#define __ENCODER_H__
#include <rtthread.h>
#include <rtdevice.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/* encoder control command */
#define ENCODER_CMD_GET_TYPE (128 + 0)
/* get a encoder type information */
#define ENCODER_CMD_ENABLE (128 + 1)
/* enable encoder */
#define ENCODER_CMD_DISABLE (128 + 2)
/* disable encoder */
#define ENCODER_CMD_CLEAR_COUNT (128 + 3)
/* clear encoder count */
/* encoder type */
enum
rt_encoder_type
{
UNKNOWN_ENCODER_TYPE
=
0x00
,
/* Unknown encoder type */
SINGLE_PHASE_ENCODER
,
/* single phase encoder */
AB_PHASE_ENCODER
/* two phase encoder */
};
struct
rt_encoder_device
;
struct
rt_encoder_ops
{
rt_err_t
(
*
init
)(
struct
rt_encoder_device
*
encoder
);
rt_int32_t
(
*
get_count
)(
struct
rt_encoder_device
*
encoder
);
rt_err_t
(
*
clear_count
)(
struct
rt_encoder_device
*
encoder
);
rt_err_t
(
*
control
)(
struct
rt_encoder_device
*
encoder
,
rt_uint32_t
cmd
,
void
*
args
);
};
struct
rt_encoder_device
{
struct
rt_device
parent
;
const
struct
rt_encoder_ops
*
ops
;
enum
rt_encoder_type
type
;
};
rt_err_t
rt_device_encoder_register
(
struct
rt_encoder_device
*
encoder
,
const
char
*
name
,
void
*
user_data
);
#ifdef __cplusplus
}
#endif
#endif
/* __ENCODER_H__ */
components/drivers/include/drivers/pulse_encoder.h
0 → 100644
浏览文件 @
b76d3dac
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-08-08 balanceTWK the first version
*/
#ifndef __PULSE_ENCODER_H__
#define __PULSE_ENCODER_H__
#include <rtthread.h>
#include <rtdevice.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/* pulse_encoder control command */
#define PULSE_ENCODER_CMD_GET_TYPE (128 + 0)
/* get a pulse_encoder type information */
#define PULSE_ENCODER_CMD_ENABLE (128 + 1)
/* enable pulse_encoder */
#define PULSE_ENCODER_CMD_DISABLE (128 + 2)
/* disable pulse_encoder */
#define PULSE_ENCODER_CMD_CLEAR_COUNT (128 + 3)
/* clear pulse_encoder count */
/* pulse_encoder type */
enum
rt_pulse_encoder_type
{
UNKNOWN_PULSE_ENCODER_TYPE
=
0x00
,
/* Unknown pulse_encoder type */
SINGLE_PHASE_PULSE_ENCODER
,
/* single phase pulse_encoder */
AB_PHASE_PULSE_ENCODER
/* two phase pulse_encoder */
};
struct
rt_pulse_encoder_device
;
struct
rt_pulse_encoder_ops
{
rt_err_t
(
*
init
)(
struct
rt_pulse_encoder_device
*
pulse_encoder
);
rt_int32_t
(
*
get_count
)(
struct
rt_pulse_encoder_device
*
pulse_encoder
);
rt_err_t
(
*
clear_count
)(
struct
rt_pulse_encoder_device
*
pulse_encoder
);
rt_err_t
(
*
control
)(
struct
rt_pulse_encoder_device
*
pulse_encoder
,
rt_uint32_t
cmd
,
void
*
args
);
};
struct
rt_pulse_encoder_device
{
struct
rt_device
parent
;
const
struct
rt_pulse_encoder_ops
*
ops
;
enum
rt_pulse_encoder_type
type
;
};
rt_err_t
rt_device_pulse_encoder_register
(
struct
rt_pulse_encoder_device
*
pulse_encoder
,
const
char
*
name
,
void
*
user_data
);
#ifdef __cplusplus
}
#endif
#endif
/* __PULSE_ENCODER_H__ */
components/drivers/include/rtdevice.h
浏览文件 @
b76d3dac
...
...
@@ -126,8 +126,8 @@ extern "C" {
#include "drivers/crypto.h"
#endif
#ifdef RT_USING_ENCODER
#include "drivers/encoder.h"
#ifdef RT_USING_
PULSE_
ENCODER
#include "drivers/
pulse_
encoder.h"
#endif
#ifdef RT_USING_INPUT_CAPTURE
...
...
components/drivers/misc/SConscript
浏览文件 @
b76d3dac
...
...
@@ -14,8 +14,8 @@ if GetDepend(['RT_USING_ADC']):
if
GetDepend
([
'RT_USING_PWM'
]):
src
=
src
+
[
'rt_drv_pwm.c'
]
if
GetDepend
([
'RT_USING_ENCODER'
]):
src
=
src
+
[
'encoder.c'
]
if
GetDepend
([
'RT_USING_
PULSE_
ENCODER'
]):
src
=
src
+
[
'
pulse_
encoder.c'
]
if
GetDepend
([
'RT_USING_INPUT_CAPTURE'
]):
src
=
src
+
[
'rt_inputcapture.c'
]
...
...
components/drivers/misc/encoder.c
→
components/drivers/misc/
pulse_
encoder.c
浏览文件 @
b76d3dac
...
...
@@ -11,14 +11,14 @@
#include <rtthread.h>
#include <rtdevice.h>
static
rt_err_t
rt_encoder_init
(
struct
rt_device
*
dev
)
static
rt_err_t
rt_
pulse_
encoder_init
(
struct
rt_device
*
dev
)
{
struct
rt_
encoder_device
*
encoder
;
struct
rt_
pulse_encoder_device
*
pulse_
encoder
;
encoder
=
(
struct
rt
_encoder_device
*
)
dev
;
if
(
encoder
->
ops
->
init
)
pulse_encoder
=
(
struct
rt_pulse
_encoder_device
*
)
dev
;
if
(
pulse_
encoder
->
ops
->
init
)
{
return
encoder
->
ops
->
init
(
encoder
);
return
pulse_encoder
->
ops
->
init
(
pulse_
encoder
);
}
else
{
...
...
@@ -26,14 +26,14 @@ static rt_err_t rt_encoder_init(struct rt_device *dev)
}
}
static
rt_err_t
rt_encoder_open
(
struct
rt_device
*
dev
,
rt_uint16_t
oflag
)
static
rt_err_t
rt_
pulse_
encoder_open
(
struct
rt_device
*
dev
,
rt_uint16_t
oflag
)
{
struct
rt_
encoder_device
*
encoder
;
struct
rt_
pulse_encoder_device
*
pulse_
encoder
;
encoder
=
(
struct
rt
_encoder_device
*
)
dev
;
if
(
encoder
->
ops
->
control
)
pulse_encoder
=
(
struct
rt_pulse
_encoder_device
*
)
dev
;
if
(
pulse_
encoder
->
ops
->
control
)
{
return
encoder
->
ops
->
control
(
encoder
,
ENCODER_CMD_ENABLE
,
RT_NULL
);
return
pulse_encoder
->
ops
->
control
(
pulse_encoder
,
PULSE_
ENCODER_CMD_ENABLE
,
RT_NULL
);
}
else
{
...
...
@@ -41,14 +41,14 @@ static rt_err_t rt_encoder_open(struct rt_device *dev, rt_uint16_t oflag)
}
}
static
rt_err_t
rt_encoder_close
(
struct
rt_device
*
dev
)
static
rt_err_t
rt_
pulse_
encoder_close
(
struct
rt_device
*
dev
)
{
struct
rt_
encoder_device
*
encoder
;
struct
rt_
pulse_encoder_device
*
pulse_
encoder
;
encoder
=
(
struct
rt
_encoder_device
*
)
dev
;
if
(
encoder
->
ops
->
control
)
pulse_encoder
=
(
struct
rt_pulse
_encoder_device
*
)
dev
;
if
(
pulse_
encoder
->
ops
->
control
)
{
return
encoder
->
ops
->
control
(
encoder
,
ENCODER_CMD_DISABLE
,
RT_NULL
);
return
pulse_encoder
->
ops
->
control
(
pulse_encoder
,
PULSE_
ENCODER_CMD_DISABLE
,
RT_NULL
);
}
else
{
...
...
@@ -56,36 +56,36 @@ static rt_err_t rt_encoder_close(struct rt_device *dev)
}
}
static
rt_size_t
rt_encoder_read
(
struct
rt_device
*
dev
,
rt_off_t
pos
,
void
*
buffer
,
rt_size_t
size
)
static
rt_size_t
rt_
pulse_
encoder_read
(
struct
rt_device
*
dev
,
rt_off_t
pos
,
void
*
buffer
,
rt_size_t
size
)
{
struct
rt_
encoder_device
*
encoder
;
struct
rt_
pulse_encoder_device
*
pulse_
encoder
;
encoder
=
(
struct
rt
_encoder_device
*
)
dev
;
if
(
encoder
->
ops
->
get_count
)
pulse_encoder
=
(
struct
rt_pulse
_encoder_device
*
)
dev
;
if
(
pulse_
encoder
->
ops
->
get_count
)
{
*
(
rt_int32_t
*
)
buffer
=
encoder
->
ops
->
get_count
(
encoder
);
*
(
rt_int32_t
*
)
buffer
=
pulse_encoder
->
ops
->
get_count
(
pulse_
encoder
);
}
return
1
;
}
static
rt_err_t
rt_encoder_control
(
struct
rt_device
*
dev
,
int
cmd
,
void
*
args
)
static
rt_err_t
rt_
pulse_
encoder_control
(
struct
rt_device
*
dev
,
int
cmd
,
void
*
args
)
{
rt_err_t
result
;
struct
rt_
encoder_device
*
encoder
;
struct
rt_
pulse_encoder_device
*
pulse_
encoder
;
result
=
RT_EOK
;
encoder
=
(
struct
rt
_encoder_device
*
)
dev
;
pulse_encoder
=
(
struct
rt_pulse
_encoder_device
*
)
dev
;
switch
(
cmd
)
{
case
ENCODER_CMD_CLEAR_COUNT
:
result
=
encoder
->
ops
->
clear_count
(
encoder
);
case
PULSE_
ENCODER_CMD_CLEAR_COUNT
:
result
=
pulse_encoder
->
ops
->
clear_count
(
pulse_
encoder
);
break
;
case
ENCODER_CMD_GET_TYPE
:
*
(
enum
rt_
encoder_type
*
)
args
=
encoder
->
type
;
case
PULSE_
ENCODER_CMD_GET_TYPE
:
*
(
enum
rt_
pulse_encoder_type
*
)
args
=
pulse_
encoder
->
type
;
break
;
case
ENCODER_CMD_ENABLE
:
case
ENCODER_CMD_DISABLE
:
result
=
encoder
->
ops
->
control
(
encoder
,
cmd
,
args
);
case
PULSE_
ENCODER_CMD_ENABLE
:
case
PULSE_
ENCODER_CMD_DISABLE
:
result
=
pulse_encoder
->
ops
->
control
(
pulse_
encoder
,
cmd
,
args
);
break
;
default:
result
=
-
RT_ENOSYS
;
...
...
@@ -96,39 +96,39 @@ static rt_err_t rt_encoder_control(struct rt_device *dev, int cmd, void *args)
}
#ifdef RT_USING_DEVICE_OPS
const
static
struct
rt_device_ops
encoder_ops
=
const
static
struct
rt_device_ops
pulse_
encoder_ops
=
{
rt_encoder_init
,
rt_encoder_open
,
rt_encoder_close
,
rt_encoder_read
,
rt_
pulse_
encoder_init
,
rt_
pulse_
encoder_open
,
rt_
pulse_
encoder_close
,
rt_
pulse_
encoder_read
,
RT_NULL
,
rt_encoder_control
rt_
pulse_
encoder_control
};
#endif
rt_err_t
rt_device_
encoder_register
(
struct
rt_encoder_device
*
encoder
,
const
char
*
name
,
void
*
user_data
)
rt_err_t
rt_device_
pulse_encoder_register
(
struct
rt_pulse_encoder_device
*
pulse_
encoder
,
const
char
*
name
,
void
*
user_data
)
{
struct
rt_device
*
device
;
RT_ASSERT
(
encoder
!=
RT_NULL
);
RT_ASSERT
(
encoder
->
ops
!=
RT_NULL
);
RT_ASSERT
(
pulse_
encoder
!=
RT_NULL
);
RT_ASSERT
(
pulse_
encoder
->
ops
!=
RT_NULL
);
device
=
&
(
encoder
->
parent
);
device
=
&
(
pulse_
encoder
->
parent
);
device
->
type
=
RT_Device_Class_Miscellaneous
;
device
->
rx_indicate
=
RT_NULL
;
device
->
tx_complete
=
RT_NULL
;
#ifdef RT_USING_DEVICE_OPS
device
->
ops
=
&
encoder_ops
;
device
->
ops
=
&
pulse_
encoder_ops
;
#else
device
->
init
=
rt_encoder_init
;
device
->
open
=
rt_encoder_open
;
device
->
close
=
rt_encoder_close
;
device
->
read
=
rt_encoder_read
;
device
->
init
=
rt_
pulse_
encoder_init
;
device
->
open
=
rt_
pulse_
encoder_open
;
device
->
close
=
rt_
pulse_
encoder_close
;
device
->
read
=
rt_
pulse_
encoder_read
;
device
->
write
=
RT_NULL
;
device
->
control
=
rt_encoder_control
;
device
->
control
=
rt_
pulse_
encoder_control
;
#endif
device
->
user_data
=
user_data
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录