Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
05b1dff0
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,发现更多精彩内容 >>
提交
05b1dff0
编写于
8月 23, 2019
作者:
T
tangweikang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32] add drv_encoder.c to stm32f103-atk-warshipv3
上级
94d7bdd0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
220 addition
and
21 deletion
+220
-21
bsp/stm32/libraries/HAL_Drivers/config/f1/encoder_config.h
bsp/stm32/libraries/HAL_Drivers/config/f1/encoder_config.h
+64
-0
bsp/stm32/libraries/HAL_Drivers/drv_config.h
bsp/stm32/libraries/HAL_Drivers/drv_config.h
+1
-0
bsp/stm32/libraries/HAL_Drivers/drv_encoder.c
bsp/stm32/libraries/HAL_Drivers/drv_encoder.c
+0
-7
bsp/stm32/libraries/STM32F1xx_HAL/SConscript
bsp/stm32/libraries/STM32F1xx_HAL/SConscript
+1
-1
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/.mxproject
...32/stm32f103-atk-warshipv3/board/CubeMX_Config/.mxproject
+3
-2
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/CubeMX_Config.ioc
...2f103-atk-warshipv3/board/CubeMX_Config/CubeMX_Config.ioc
+20
-9
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h
...tk-warshipv3/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h
+1
-1
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Src/main.c
...32/stm32f103-atk-warshipv3/board/CubeMX_Config/Src/main.c
+53
-0
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c
...atk-warshipv3/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c
+65
-0
bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig
bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig
+12
-1
未找到文件。
bsp/stm32/libraries/HAL_Drivers/config/f1/encoder_config.h
0 → 100644
浏览文件 @
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/drv_config.h
浏览文件 @
05b1dff0
...
...
@@ -34,6 +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"
#elif defined(SOC_SERIES_STM32F2)
#include "f2/dma_config.h"
#include "f2/uart_config.h"
...
...
bsp/stm32/libraries/HAL_Drivers/drv_encoder.c
浏览文件 @
05b1dff0
/*
* @Description: In User Settings Edit
* @Author: your name
* @Date: 2019-08-09 15:25:34
* @LastEditTime: 2019-08-09 17:29:27
* @LastEditors: Please set LastEditors
*/
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
...
...
bsp/stm32/libraries/STM32F1xx_HAL/SConscript
浏览文件 @
05b1dff0
...
...
@@ -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'
]):
if
GetDepend
([
'RT_USING_HWTIMER'
])
or
GetDepend
([
'RT_USING_PWM'
])
or
GetDepend
([
'RT_USING_ENCODER'
])
:
src
+=
[
'STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c'
]
src
+=
[
'STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c'
]
...
...
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/.mxproject
浏览文件 @
05b1dff0
[PreviousGenFiles]
HeaderPath=
G:/Wondfo/RT-Thread/Official information/rt-thread-master/bsp/1stm32/stm32f103-atk-warshipV
3/board/CubeMX_Config/Inc
HeaderPath=
E:/workspace/rt-thread/bsp/stm32/stm32f103-atk-warshipv
3/board/CubeMX_Config/Inc
HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h;
SourcePath=
G:/Wondfo/RT-Thread/Official information/rt-thread-master/bsp/1stm32/stm32f103-atk-warshipV
3/board/CubeMX_Config/Src
SourcePath=
E:/workspace/rt-thread/bsp/stm32/stm32f103-atk-warshipv
3/board/CubeMX_Config/Src
SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c;
[PreviousLibFiles]
...
...
@@ -10,4 +10,5 @@ LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_
[PreviousUsedKeilFiles]
SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;null;
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc;
CDefines=USE_HAL_DRIVER;STM32F103xE;USE_HAL_DRIVER;STM32F103xE;
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/CubeMX_Config.ioc
浏览文件 @
05b1dff0
...
...
@@ -5,19 +5,22 @@ Mcu.Family=STM32F1
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SYS
Mcu.IP3=USART1
Mcu.IPNb=4
Mcu.IP3=TIM3
Mcu.IP4=USART1
Mcu.IPNb=5
Mcu.Name=STM32F103Z(C-D-E)Tx
Mcu.Package=LQFP144
Mcu.Pin0=PC14-OSC32_IN
Mcu.Pin1=PC15-OSC32_OUT
Mcu.Pin2=OSC_IN
Mcu.Pin3=OSC_OUT
Mcu.Pin4=PA9
Mcu.Pin5=PA10
Mcu.Pin6=VP_SYS_VS_ND
Mcu.Pin7=VP_SYS_VS_Systick
Mcu.PinsNb=8
Mcu.Pin4=PC6
Mcu.Pin5=PC7
Mcu.Pin6=PA9
Mcu.Pin7=PA10
Mcu.Pin8=VP_SYS_VS_ND
Mcu.Pin9=VP_SYS_VS_Systick
Mcu.PinsNb=10
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103ZETx
...
...
@@ -45,6 +48,10 @@ PC14-OSC32_IN.Mode=LSE-External-Oscillator
PC14-OSC32_IN.Signal=RCC_OSC32_IN
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
PC6.Locked=true
PC6.Signal=S_TIM3_CH1
PC7.Locked=true
PC7.Signal=S_TIM3_CH2
PCC.Checker=false
PCC.Line=STM32F103
PCC.MCU=STM32F103Z(C-D-E)Tx
...
...
@@ -54,7 +61,7 @@ PCC.Series=STM32F1
PCC.Temperature=25
PCC.Vdd=3.3
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=
tru
e
ProjectManager.AskForMigrate=
fals
e
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
...
...
@@ -80,7 +87,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true
,4-MX_TIM8_Init-TIM8-false-HAL-true
RCC.ADCFreqValue=36000000
RCC.AHBFreq_Value=72000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2
...
...
@@ -107,6 +114,10 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.TimSysFreq_Value=72000000
RCC.USBFreq_Value=72000000
RCC.VCOOutput2Freq_Value=8000000
SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface
SH.S_TIM3_CH1.ConfNb=1
SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface
SH.S_TIM3_CH2.ConfNb=1
USART1.IPParameters=VirtualMode
USART1.VirtualMode=VM_ASYNC
VP_SYS_VS_ND.Mode=No_Debug
...
...
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h
浏览文件 @
05b1dff0
...
...
@@ -78,7 +78,7 @@
/*#define HAL_SMARTCARD_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
/*#define HAL_SRAM_MODULE_ENABLED */
/*#define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_WWDG_MODULE_ENABLED */
...
...
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Src/main.c
浏览文件 @
05b1dff0
...
...
@@ -42,6 +42,8 @@
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
TIM_HandleTypeDef
htim3
;
UART_HandleTypeDef
huart1
;
/* USER CODE BEGIN PV */
...
...
@@ -52,6 +54,7 @@ UART_HandleTypeDef huart1;
void
SystemClock_Config
(
void
);
static
void
MX_GPIO_Init
(
void
);
static
void
MX_USART1_UART_Init
(
void
);
static
void
MX_TIM3_Init
(
void
);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
...
...
@@ -90,6 +93,7 @@ int main(void)
/* Initialize all configured peripherals */
MX_GPIO_Init
();
MX_USART1_UART_Init
();
MX_TIM3_Init
();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
...
...
@@ -142,6 +146,55 @@ void SystemClock_Config(void)
}
}
/**
* @brief TIM3 Initialization Function
* @param None
* @retval None
*/
static
void
MX_TIM3_Init
(
void
)
{
/* USER CODE BEGIN TIM3_Init 0 */
/* USER CODE END TIM3_Init 0 */
TIM_Encoder_InitTypeDef
sConfig
=
{
0
};
TIM_MasterConfigTypeDef
sMasterConfig
=
{
0
};
/* USER CODE BEGIN TIM3_Init 1 */
/* USER CODE END TIM3_Init 1 */
htim3
.
Instance
=
TIM3
;
htim3
.
Init
.
Prescaler
=
0
;
htim3
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
htim3
.
Init
.
Period
=
0
;
htim3
.
Init
.
ClockDivision
=
TIM_CLOCKDIVISION_DIV1
;
htim3
.
Init
.
AutoReloadPreload
=
TIM_AUTORELOAD_PRELOAD_DISABLE
;
sConfig
.
EncoderMode
=
TIM_ENCODERMODE_TI1
;
sConfig
.
IC1Polarity
=
TIM_ICPOLARITY_RISING
;
sConfig
.
IC1Selection
=
TIM_ICSELECTION_DIRECTTI
;
sConfig
.
IC1Prescaler
=
TIM_ICPSC_DIV1
;
sConfig
.
IC1Filter
=
0
;
sConfig
.
IC2Polarity
=
TIM_ICPOLARITY_RISING
;
sConfig
.
IC2Selection
=
TIM_ICSELECTION_DIRECTTI
;
sConfig
.
IC2Prescaler
=
TIM_ICPSC_DIV1
;
sConfig
.
IC2Filter
=
0
;
if
(
HAL_TIM_Encoder_Init
(
&
htim3
,
&
sConfig
)
!=
HAL_OK
)
{
Error_Handler
();
}
sMasterConfig
.
MasterOutputTrigger
=
TIM_TRGO_RESET
;
sMasterConfig
.
MasterSlaveMode
=
TIM_MASTERSLAVEMODE_DISABLE
;
if
(
HAL_TIMEx_MasterConfigSynchronization
(
&
htim3
,
&
sMasterConfig
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN TIM3_Init 2 */
/* USER CODE END TIM3_Init 2 */
}
/**
* @brief USART1 Initialization Function
* @param None
...
...
bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c
浏览文件 @
05b1dff0
...
...
@@ -81,6 +81,71 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
/**
* @brief TIM_Encoder MSP Initialization
* This function configures the hardware resources used in this example
* @param htim_encoder: TIM_Encoder handle pointer
* @retval None
*/
void
HAL_TIM_Encoder_MspInit
(
TIM_HandleTypeDef
*
htim_encoder
)
{
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
if
(
htim_encoder
->
Instance
==
TIM3
)
{
/* USER CODE BEGIN TIM3_MspInit 0 */
/* USER CODE END TIM3_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM3_CLK_ENABLE
();
__HAL_RCC_GPIOC_CLK_ENABLE
();
/**TIM3 GPIO Configuration
PC6 ------> TIM3_CH1
PC7 ------> TIM3_CH2
*/
GPIO_InitStruct
.
Pin
=
GPIO_PIN_6
|
GPIO_PIN_7
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_INPUT
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
HAL_GPIO_Init
(
GPIOC
,
&
GPIO_InitStruct
);
__HAL_AFIO_REMAP_TIM3_ENABLE
();
/* USER CODE BEGIN TIM3_MspInit 1 */
/* USER CODE END TIM3_MspInit 1 */
}
}
/**
* @brief TIM_Encoder MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param htim_encoder: TIM_Encoder handle pointer
* @retval None
*/
void
HAL_TIM_Encoder_MspDeInit
(
TIM_HandleTypeDef
*
htim_encoder
)
{
if
(
htim_encoder
->
Instance
==
TIM3
)
{
/* USER CODE BEGIN TIM3_MspDeInit 0 */
/* USER CODE END TIM3_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM3_CLK_DISABLE
();
/**TIM3 GPIO Configuration
PC6 ------> TIM3_CH1
PC7 ------> TIM3_CH2
*/
HAL_GPIO_DeInit
(
GPIOC
,
GPIO_PIN_6
|
GPIO_PIN_7
);
/* USER CODE BEGIN TIM3_MspDeInit 1 */
/* USER CODE END TIM3_MspDeInit 1 */
}
}
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
...
...
bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig
浏览文件 @
05b1dff0
...
...
@@ -200,7 +200,18 @@ menu "On-chip Peripheral Drivers"
bool "Enable Watchdog Timer"
select RT_USING_WDT
default n
menuconfig BSP_USING_ENCODER
bool "Enable Encoder"
default n
select RT_USING_ENCODER
if BSP_USING_ENCODER
config BSP_USING_ENCODER3
bool "Enable Encoder3"
default n
endif
source "../libraries/HAL_Drivers/Kconfig"
endmenu
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录