Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Richard 祝发兴 - -IT
rt-thread
提交
e69f4c45
R
rt-thread
项目概览
Richard 祝发兴 - -IT
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e69f4c45
编写于
8月 19, 2019
作者:
B
Bernard Xiong
提交者:
GitHub
8月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2967 from wuhanstudio/add-pwm
Add pwm
上级
70d6d367
a1a7621b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
200 addition
and
25 deletion
+200
-25
bsp/stm32/stm32f103-yf-ufun/README.md
bsp/stm32/stm32f103-yf-ufun/README.md
+6
-6
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/Kconfig
bsp/stm32/stm32f103-yf-ufun/board/Kconfig
+23
-0
未找到文件。
bsp/stm32/stm32f103-yf-ufun/README.md
浏览文件 @
e69f4c45
...
...
@@ -38,18 +38,18 @@ yf-ufun STM32F103 是优凡(天津)科技有限公司推出的一款基于 A
|
**板载外设**
|
**支持情况**
|
**备注**
|
| :----------------- | :----------: | :------------------------------------|
| USB 转串口 | 支持 | |
| 蜂鸣器 |
暂不
支持 | |
| 蜂鸣器 | 支持 | |
| LED | 支持 | |
| RGB LED |
暂不
支持 | |
| RGB LED | 支持 | |
| 触摸按键 | 暂不支持 | |
|
**片上外设**
|
**支持情况**
|
**备注**
|
| GPIO | 支持 | PA0-PA14,PB0-PB15,PC0-PC5,PC7-PC12 |
| UART | 支持 | UART1 |
| SPI |
暂不支持 |
|
| I2C |
暂不支持 |
|
| SDIO |
暂不
支持 | |
| SPI |
支持 | SPI1
|
| I2C |
支持 | 软件 I2C
|
| SDIO | 支持 | |
| RTC | 暂不支持 | |
| PWM |
暂不
支持 | |
| PWM | 支持 | |
| USB Device | 暂不支持 | |
| USB Host | 暂不支持 | |
| IWG | 暂不支持 | |
...
...
bsp/stm32/stm32f103-yf-ufun/board/CubeMX_Config/.mxproject
浏览文件 @
e69f4c45
[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
浏览文件 @
e69f4c45
...
...
@@ -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
浏览文件 @
e69f4c45
...
...
@@ -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
浏览文件 @
e69f4c45
...
...
@@ -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
浏览文件 @
e69f4c45
...
...
@@ -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
浏览文件 @
e69f4c45
...
...
@@ -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
...
...
bsp/stm32/stm32f103-yf-ufun/board/Kconfig
浏览文件 @
e69f4c45
...
...
@@ -69,6 +69,29 @@ menu "On-chip Peripheral Drivers"
default 16
endif
menuconfig BSP_USING_PWM
bool "Enable PWM"
default n
select RT_USING_PWM
if BSP_USING_PWM
menuconfig BSP_USING_PWM2
bool "Enable timer2 output pwm"
default n
if BSP_USING_PWM2
config BSP_USING_PWM2_CH1
bool "Enable PWM2 channel 1"
default n
config BSP_USING_PWM2_CH2
bool "Enable PWM2 channel 2"
default n
config BSP_USING_PWM2_CH3
bool "Enable PWM2 channel 3"
default n
endif
endif
config BSP_USING_SDIO
bool "Enable SDCARD (sdio)"
select RT_USING_SDIO
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录