Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
混口饭吃,
rt-thread
提交
a1a7621b
R
rt-thread
项目概览
混口饭吃,
/
rt-thread
与 Fork 源项目一致
Fork自
Mr_Pangza / 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,发现更多精彩内容 >>
提交
a1a7621b
编写于
8月 15, 2019
作者:
wuhanstudio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32][stm32f103-yf-ufun] add pwm CubeMX config
上级
b5fdb36b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
171 addition
and
19 deletion
+171
-19
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/.mxproject
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/.mxproject
+2
-2
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/CubeMX_Config.ioc
...2/stm32f103-yf-ufun/board/CubeMX_Config/CubeMX_Config.ioc
+32
-15
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc/main.h
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc/main.h
+2
-0
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h
...f103-yf-ufun/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h
+1
-1
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Src/main.c
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Src/main.c
+61
-0
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c
...2f103-yf-ufun/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c
+73
-1
未找到文件。
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/.mxproject
浏览文件 @
a1a7621b
[PreviousGenFiles]
HeaderPath=
F
:/rt-thread/bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc
HeaderPath=
D
:/rt-thread/bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc
HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h;
SourcePath=
F
:/rt-thread/bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Src
SourcePath=
D
:/rt-thread/bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Src
SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c;
[PreviousLibFiles]
...
...
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/CubeMX_Config.ioc
浏览文件 @
a1a7621b
...
...
@@ -6,26 +6,30 @@ Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SDIO
Mcu.IP3=SYS
Mcu.IP4=USART1
Mcu.IPNb=5
Mcu.IP4=TIM2
Mcu.IP5=USART1
Mcu.IPNb=6
Mcu.Name=STM32F103R(C-D-E)Tx
Mcu.Package=LQFP64
Mcu.Pin0=PC14-OSC32_IN
Mcu.Pin1=PC15-OSC32_OUT
Mcu.Pin10=PC10
Mcu.Pin11=PC11
Mcu.Pin12=PC12
Mcu.Pin13=PD2
Mcu.Pin14=VP_SYS_VS_Systick
Mcu.Pin10=PA10
Mcu.Pin11=PA13
Mcu.Pin12=PA14
Mcu.Pin13=PC10
Mcu.Pin14=PC11
Mcu.Pin15=PC12
Mcu.Pin16=PD2
Mcu.Pin17=VP_SYS_VS_Systick
Mcu.Pin2=PD0-OSC_IN
Mcu.Pin3=PD1-OSC_OUT
Mcu.Pin4=P
C8
Mcu.Pin5=P
C9
Mcu.Pin6=PA
9
Mcu.Pin7=P
A10
Mcu.Pin8=P
A13
Mcu.Pin9=PA
14
Mcu.PinsNb=1
5
Mcu.Pin4=P
A0-WKUP
Mcu.Pin5=P
A1
Mcu.Pin6=PA
2
Mcu.Pin7=P
C8
Mcu.Pin8=P
C9
Mcu.Pin9=PA
9
Mcu.PinsNb=1
8
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103RCTx
...
...
@@ -41,12 +45,15 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
PA0-WKUP.Signal=S_TIM2_CH1_ETR
PA1.Signal=S_TIM2_CH2
PA10.Mode=Asynchronous
PA10.Signal=USART1_RX
PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
PA2.Signal=S_TIM2_CH3
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
PC10.Mode=SD_4_bits_Wide_bus
...
...
@@ -78,7 +85,7 @@ PD1-OSC_OUT.Signal=RCC_OSC_OUT
PD2.Mode=SD_4_bits_Wide_bus
PD2.Signal=SDIO_CMD
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=
tru
e
ProjectManager.AskForMigrate=
fals
e
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
...
...
@@ -131,6 +138,16 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.TimSysFreq_Value=72000000
RCC.USBFreq_Value=72000000
RCC.VCOOutput2Freq_Value=12000000
SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1
SH.S_TIM2_CH1_ETR.ConfNb=1
SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2
SH.S_TIM2_CH2.ConfNb=1
SH.S_TIM2_CH3.0=TIM2_CH3,PWM Generation3 CH3
SH.S_TIM2_CH3.ConfNb=1
TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM2.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3
USART1.IPParameters=VirtualMode
USART1.VirtualMode=VM_ASYNC
VP_SYS_VS_Systick.Mode=SysTick
...
...
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc/main.h
浏览文件 @
a1a7621b
...
...
@@ -70,6 +70,8 @@ extern "C" {
/* USER CODE END EM */
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
);
/* Exported functions prototypes ---------------------------------------------*/
void
Error_Handler
(
void
);
...
...
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h
浏览文件 @
a1a7621b
...
...
@@ -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-yf-ufun/board/CubeMX_Config/Src/main.c
浏览文件 @
a1a7621b
...
...
@@ -64,6 +64,8 @@
/* Private variables ---------------------------------------------------------*/
SD_HandleTypeDef
hsd
;
TIM_HandleTypeDef
htim2
;
UART_HandleTypeDef
huart1
;
/* USER CODE BEGIN PV */
...
...
@@ -76,6 +78,7 @@ void SystemClock_Config(void);
static
void
MX_GPIO_Init
(
void
);
static
void
MX_USART1_UART_Init
(
void
);
static
void
MX_SDIO_SD_Init
(
void
);
static
void
MX_TIM2_Init
(
void
);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
...
...
@@ -117,6 +120,7 @@ int main(void)
MX_GPIO_Init
();
MX_USART1_UART_Init
();
MX_SDIO_SD_Init
();
MX_TIM2_Init
();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
...
...
@@ -207,6 +211,63 @@ static void MX_SDIO_SD_Init(void)
}
/**
* @brief TIM2 Initialization Function
* @param None
* @retval None
*/
static
void
MX_TIM2_Init
(
void
)
{
/* USER CODE BEGIN TIM2_Init 0 */
/* USER CODE END TIM2_Init 0 */
TIM_MasterConfigTypeDef
sMasterConfig
=
{
0
};
TIM_OC_InitTypeDef
sConfigOC
=
{
0
};
/* USER CODE BEGIN TIM2_Init 1 */
/* USER CODE END TIM2_Init 1 */
htim2
.
Instance
=
TIM2
;
htim2
.
Init
.
Prescaler
=
0
;
htim2
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
htim2
.
Init
.
Period
=
0
;
htim2
.
Init
.
ClockDivision
=
TIM_CLOCKDIVISION_DIV1
;
htim2
.
Init
.
AutoReloadPreload
=
TIM_AUTORELOAD_PRELOAD_DISABLE
;
if
(
HAL_TIM_PWM_Init
(
&
htim2
)
!=
HAL_OK
)
{
Error_Handler
();
}
sMasterConfig
.
MasterOutputTrigger
=
TIM_TRGO_RESET
;
sMasterConfig
.
MasterSlaveMode
=
TIM_MASTERSLAVEMODE_DISABLE
;
if
(
HAL_TIMEx_MasterConfigSynchronization
(
&
htim2
,
&
sMasterConfig
)
!=
HAL_OK
)
{
Error_Handler
();
}
sConfigOC
.
OCMode
=
TIM_OCMODE_PWM1
;
sConfigOC
.
Pulse
=
0
;
sConfigOC
.
OCPolarity
=
TIM_OCPOLARITY_HIGH
;
sConfigOC
.
OCFastMode
=
TIM_OCFAST_DISABLE
;
if
(
HAL_TIM_PWM_ConfigChannel
(
&
htim2
,
&
sConfigOC
,
TIM_CHANNEL_1
)
!=
HAL_OK
)
{
Error_Handler
();
}
if
(
HAL_TIM_PWM_ConfigChannel
(
&
htim2
,
&
sConfigOC
,
TIM_CHANNEL_2
)
!=
HAL_OK
)
{
Error_Handler
();
}
if
(
HAL_TIM_PWM_ConfigChannel
(
&
htim2
,
&
sConfigOC
,
TIM_CHANNEL_3
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */
HAL_TIM_MspPostInit
(
&
htim2
);
}
/**
* @brief USART1 Initialization Function
* @param None
...
...
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c
浏览文件 @
a1a7621b
...
...
@@ -78,7 +78,9 @@
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
);
/**
* Initializes the Global MSP.
*/
void
HAL_MspInit
(
void
)
...
...
@@ -182,6 +184,76 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
}
/**
* @brief TIM_PWM MSP Initialization
* This function configures the hardware resources used in this example
* @param htim_pwm: TIM_PWM handle pointer
* @retval None
*/
void
HAL_TIM_PWM_MspInit
(
TIM_HandleTypeDef
*
htim_pwm
)
{
if
(
htim_pwm
->
Instance
==
TIM2
)
{
/* USER CODE BEGIN TIM2_MspInit 0 */
/* USER CODE END TIM2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM2_CLK_ENABLE
();
/* USER CODE BEGIN TIM2_MspInit 1 */
/* USER CODE END TIM2_MspInit 1 */
}
}
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
)
{
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
if
(
htim
->
Instance
==
TIM2
)
{
/* USER CODE BEGIN TIM2_MspPostInit 0 */
/* USER CODE END TIM2_MspPostInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE
();
/**TIM2 GPIO Configuration
PA0-WKUP ------> TIM2_CH1
PA1 ------> TIM2_CH2
PA2 ------> TIM2_CH3
*/
GPIO_InitStruct
.
Pin
=
GPIO_PIN_0
|
GPIO_PIN_1
|
GPIO_PIN_2
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_LOW
;
HAL_GPIO_Init
(
GPIOA
,
&
GPIO_InitStruct
);
/* USER CODE BEGIN TIM2_MspPostInit 1 */
/* USER CODE END TIM2_MspPostInit 1 */
}
}
/**
* @brief TIM_PWM MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param htim_pwm: TIM_PWM handle pointer
* @retval None
*/
void
HAL_TIM_PWM_MspDeInit
(
TIM_HandleTypeDef
*
htim_pwm
)
{
if
(
htim_pwm
->
Instance
==
TIM2
)
{
/* USER CODE BEGIN TIM2_MspDeInit 0 */
/* USER CODE END TIM2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM2_CLK_DISABLE
();
/* USER CODE BEGIN TIM2_MspDeInit 1 */
/* USER CODE END TIM2_MspDeInit 1 */
}
}
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录