Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
75dc0dcb
R
rt-thread
项目概览
AdRainty
/
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,发现更多精彩内容 >>
未验证
提交
75dc0dcb
编写于
4月 07, 2019
作者:
B
Bernard Xiong
提交者:
GitHub
4月 07, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2543 from Guozhanxin/f411
[bsp][stm32]完善 f4xx-nucleo spi、rtc支持
上级
7d2471c4
e48a7b71
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
344 addition
and
25 deletion
+344
-25
bsp/stm32/stm32f411-st-nucleo/.config
bsp/stm32/stm32f411-st-nucleo/.config
+2
-0
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc
...stm32f411-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc
+43
-20
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Inc/stm32f4xx_hal_conf.h
...11-st-nucleo/board/CubeMX_Config/Inc/stm32f4xx_hal_conf.h
+3
-3
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Src/main.c
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Src/main.c
+121
-1
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c
...411-st-nucleo/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c
+127
-0
bsp/stm32/stm32f411-st-nucleo/board/Kconfig
bsp/stm32/stm32f411-st-nucleo/board/Kconfig
+39
-0
bsp/stm32/stm32f411-st-nucleo/board/board.c
bsp/stm32/stm32f411-st-nucleo/board/board.c
+9
-1
未找到文件。
bsp/stm32/stm32f411-st-nucleo/.config
浏览文件 @
75dc0dcb
...
...
@@ -356,7 +356,9 @@ CONFIG_BSP_USING_UART=y
CONFIG_BSP_USING_UART2
=
y
# CONFIG_BSP_USING_UART6 is not set
# CONFIG_BSP_USING_I2C1 is not set
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_PWM is not set
# CONFIG_BSP_USING_ONCHIP_RTC is not set
# CONFIG_BSP_USING_ON_CHIP_FLASH is not set
#
...
...
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/CubeMX_Config.ioc
浏览文件 @
75dc0dcb
...
...
@@ -2,34 +2,42 @@
File.Version=6
KeepUserPlacement=true
Mcu.Family=STM32F4
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SYS
Mcu.IP3=TIM3
Mcu.IP4=USART2
Mcu.IP5=USART6
Mcu.IPNb=6
Mcu.IP0=IWDG
Mcu.IP1=NVIC
Mcu.IP2=RCC
Mcu.IP3=RTC
Mcu.IP4=SPI1
Mcu.IP5=SYS
Mcu.IP6=TIM3
Mcu.IP7=USART2
Mcu.IP8=USART6
Mcu.IPNb=9
Mcu.Name=STM32F411R(C-E)Tx
Mcu.Package=LQFP64
Mcu.Pin0=PC13-ANTI_TAMP
Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PB1
Mcu.Pin11=PA11
Mcu.Pin12=PA12
Mcu.Pin13=PA13
Mcu.Pin14=PA14
Mcu.Pin15=PB3
Mcu.Pin16=VP_SYS_VS_Systick
Mcu.Pin17=VP_TIM3_VS_ClockSourceINT
Mcu.Pin10=PB0
Mcu.Pin11=PB1
Mcu.Pin12=PA11
Mcu.Pin13=PA12
Mcu.Pin14=PA13
Mcu.Pin15=PA14
Mcu.Pin16=PB3
Mcu.Pin17=PB4
Mcu.Pin18=PB5
Mcu.Pin19=VP_IWDG_VS_IWDG
Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin20=VP_RTC_VS_RTC_Activate
Mcu.Pin21=VP_SYS_VS_Systick
Mcu.Pin22=VP_TIM3_VS_ClockSourceINT
Mcu.Pin3=PH0 - OSC_IN
Mcu.Pin4=PH1 - OSC_OUT
Mcu.Pin5=PA2
Mcu.Pin6=PA3
Mcu.Pin7=PA
6
Mcu.Pin8=PA
7
Mcu.Pin9=P
B0
Mcu.PinsNb=
18
Mcu.Pin7=PA
5
Mcu.Pin8=PA
6
Mcu.Pin9=P
A7
Mcu.PinsNb=
23
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F411RETx
...
...
@@ -65,6 +73,8 @@ PA2.Mode=Asynchronous
PA2.Signal=USART2_TX
PA3.Mode=Asynchronous
PA3.Signal=USART2_RX
PA5.Mode=Full_Duplex_Master
PA5.Signal=SPI1_SCK
PA6.Signal=S_TIM3_CH1
PA7.Signal=S_TIM3_CH2
PB0.Signal=S_TIM3_CH3
...
...
@@ -73,6 +83,10 @@ PB3.GPIOParameters=GPIO_Label
PB3.GPIO_Label=SWO
PB3.Locked=true
PB3.Signal=SYS_JTDO-SWO
PB4.Mode=Full_Duplex_Master
PB4.Signal=SPI1_MISO
PB5.Mode=Full_Duplex_Master
PB5.Signal=SPI1_MOSI
PC13-ANTI_TAMP.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PC13-ANTI_TAMP.GPIO_Label=B1 [Blue PushButton]
PC13-ANTI_TAMP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
...
...
@@ -125,7 +139,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_USART2_UART_Init-USART2-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true,5-MX_USART6_UART_Init-USART6-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true,5-MX_USART6_UART_Init-USART6-false-HAL-true
,6-MX_RTC_Init-RTC-false-HAL-true,7-MX_IWDG_Init-IWDG-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true
RCC.48MHZClocksFreq_Value=42000000
RCC.AHBFreq_Value=84000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2
...
...
@@ -169,6 +183,11 @@ SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3
SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
SH.S_TIM3_CH4.ConfNb=1
SPI1.CalculateBaudRate=42.0 MBits/s
SPI1.Direction=SPI_DIRECTION_2LINES
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
SPI1.Mode=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
...
...
@@ -178,6 +197,10 @@ USART2.IPParameters=VirtualMode
USART2.VirtualMode=VM_ASYNC
USART6.IPParameters=VirtualMode
USART6.VirtualMode=VM_ASYNC
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM3_VS_ClockSourceINT.Mode=Internal
...
...
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Inc/stm32f4xx_hal_conf.h
浏览文件 @
75dc0dcb
...
...
@@ -66,14 +66,14 @@
/* #define HAL_HASH_MODULE_ENABLED */
/* #define HAL_I2C_MODULE_ENABLED */
/* #define HAL_I2S_MODULE_ENABLED */
/* #define HAL_IWDG_MODULE_ENABLED */
#define HAL_IWDG_MODULE_ENABLED
/* #define HAL_LTDC_MODULE_ENABLED */
/* #define HAL_RNG_MODULE_ENABLED */
/* #define HAL_RTC_MODULE_ENABLED */
#define HAL_RTC_MODULE_ENABLED
/* #define HAL_SAI_MODULE_ENABLED */
/* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/* #define HAL_USART_MODULE_ENABLED */
...
...
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Src/main.c
浏览文件 @
75dc0dcb
...
...
@@ -62,6 +62,12 @@
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
IWDG_HandleTypeDef
hiwdg
;
RTC_HandleTypeDef
hrtc
;
SPI_HandleTypeDef
hspi1
;
TIM_HandleTypeDef
htim3
;
UART_HandleTypeDef
huart2
;
...
...
@@ -77,6 +83,9 @@ static void MX_GPIO_Init(void);
static
void
MX_USART2_UART_Init
(
void
);
static
void
MX_TIM3_Init
(
void
);
static
void
MX_USART6_UART_Init
(
void
);
static
void
MX_RTC_Init
(
void
);
static
void
MX_IWDG_Init
(
void
);
static
void
MX_SPI1_Init
(
void
);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
...
...
@@ -117,6 +126,9 @@ int main(void)
MX_USART2_UART_Init
();
MX_TIM3_Init
();
MX_USART6_UART_Init
();
MX_RTC_Init
();
MX_IWDG_Init
();
MX_SPI1_Init
();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
...
...
@@ -140,6 +152,7 @@ void SystemClock_Config(void)
{
RCC_OscInitTypeDef
RCC_OscInitStruct
=
{
0
};
RCC_ClkInitTypeDef
RCC_ClkInitStruct
=
{
0
};
RCC_PeriphCLKInitTypeDef
PeriphClkInitStruct
=
{
0
};
/**Configure the main internal regulator output voltage
*/
...
...
@@ -147,8 +160,9 @@ void SystemClock_Config(void)
__HAL_PWR_VOLTAGESCALING_CONFIG
(
PWR_REGULATOR_VOLTAGE_SCALE1
);
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct
.
OscillatorType
=
RCC_OSCILLATORTYPE_HSE
;
RCC_OscInitStruct
.
OscillatorType
=
RCC_OSCILLATORTYPE_
LSI
|
RCC_OSCILLATORTYPE_
HSE
;
RCC_OscInitStruct
.
HSEState
=
RCC_HSE_BYPASS
;
RCC_OscInitStruct
.
LSIState
=
RCC_LSI_ON
;
RCC_OscInitStruct
.
PLL
.
PLLState
=
RCC_PLL_ON
;
RCC_OscInitStruct
.
PLL
.
PLLSource
=
RCC_PLLSOURCE_HSE
;
RCC_OscInitStruct
.
PLL
.
PLLM
=
4
;
...
...
@@ -172,6 +186,112 @@ void SystemClock_Config(void)
{
Error_Handler
();
}
PeriphClkInitStruct
.
PeriphClockSelection
=
RCC_PERIPHCLK_RTC
;
PeriphClkInitStruct
.
RTCClockSelection
=
RCC_RTCCLKSOURCE_LSI
;
if
(
HAL_RCCEx_PeriphCLKConfig
(
&
PeriphClkInitStruct
)
!=
HAL_OK
)
{
Error_Handler
();
}
}
/**
* @brief IWDG Initialization Function
* @param None
* @retval None
*/
static
void
MX_IWDG_Init
(
void
)
{
/* USER CODE BEGIN IWDG_Init 0 */
/* USER CODE END IWDG_Init 0 */
/* USER CODE BEGIN IWDG_Init 1 */
/* USER CODE END IWDG_Init 1 */
hiwdg
.
Instance
=
IWDG
;
hiwdg
.
Init
.
Prescaler
=
IWDG_PRESCALER_4
;
hiwdg
.
Init
.
Reload
=
4095
;
if
(
HAL_IWDG_Init
(
&
hiwdg
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN IWDG_Init 2 */
/* USER CODE END IWDG_Init 2 */
}
/**
* @brief RTC Initialization Function
* @param None
* @retval None
*/
static
void
MX_RTC_Init
(
void
)
{
/* USER CODE BEGIN RTC_Init 0 */
/* USER CODE END RTC_Init 0 */
/* USER CODE BEGIN RTC_Init 1 */
/* USER CODE END RTC_Init 1 */
/**Initialize RTC Only
*/
hrtc
.
Instance
=
RTC
;
hrtc
.
Init
.
HourFormat
=
RTC_HOURFORMAT_24
;
hrtc
.
Init
.
AsynchPrediv
=
127
;
hrtc
.
Init
.
SynchPrediv
=
255
;
hrtc
.
Init
.
OutPut
=
RTC_OUTPUT_DISABLE
;
hrtc
.
Init
.
OutPutPolarity
=
RTC_OUTPUT_POLARITY_HIGH
;
hrtc
.
Init
.
OutPutType
=
RTC_OUTPUT_TYPE_OPENDRAIN
;
if
(
HAL_RTC_Init
(
&
hrtc
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN RTC_Init 2 */
/* USER CODE END RTC_Init 2 */
}
/**
* @brief SPI1 Initialization Function
* @param None
* @retval None
*/
static
void
MX_SPI1_Init
(
void
)
{
/* USER CODE BEGIN SPI1_Init 0 */
/* USER CODE END SPI1_Init 0 */
/* USER CODE BEGIN SPI1_Init 1 */
/* USER CODE END SPI1_Init 1 */
/* SPI1 parameter configuration*/
hspi1
.
Instance
=
SPI1
;
hspi1
.
Init
.
Mode
=
SPI_MODE_MASTER
;
hspi1
.
Init
.
Direction
=
SPI_DIRECTION_2LINES
;
hspi1
.
Init
.
DataSize
=
SPI_DATASIZE_8BIT
;
hspi1
.
Init
.
CLKPolarity
=
SPI_POLARITY_LOW
;
hspi1
.
Init
.
CLKPhase
=
SPI_PHASE_1EDGE
;
hspi1
.
Init
.
NSS
=
SPI_NSS_SOFT
;
hspi1
.
Init
.
BaudRatePrescaler
=
SPI_BAUDRATEPRESCALER_2
;
hspi1
.
Init
.
FirstBit
=
SPI_FIRSTBIT_MSB
;
hspi1
.
Init
.
TIMode
=
SPI_TIMODE_DISABLE
;
hspi1
.
Init
.
CRCCalculation
=
SPI_CRCCALCULATION_DISABLE
;
hspi1
.
Init
.
CRCPolynomial
=
10
;
if
(
HAL_SPI_Init
(
&
hspi1
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN SPI1_Init 2 */
/* USER CODE END SPI1_Init 2 */
}
/**
...
...
bsp/stm32/stm32f411-st-nucleo/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c
浏览文件 @
75dc0dcb
...
...
@@ -101,6 +101,133 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
/**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example
* @param hrtc: RTC handle pointer
* @retval None
*/
void
HAL_RTC_MspInit
(
RTC_HandleTypeDef
*
hrtc
)
{
if
(
hrtc
->
Instance
==
RTC
)
{
/* USER CODE BEGIN RTC_MspInit 0 */
/* USER CODE END RTC_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_RTC_ENABLE
();
/* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */
}
}
/**
* @brief RTC MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hrtc: RTC handle pointer
* @retval None
*/
void
HAL_RTC_MspDeInit
(
RTC_HandleTypeDef
*
hrtc
)
{
if
(
hrtc
->
Instance
==
RTC
)
{
/* USER CODE BEGIN RTC_MspDeInit 0 */
/* USER CODE END RTC_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_RTC_DISABLE
();
/* USER CODE BEGIN RTC_MspDeInit 1 */
/* USER CODE END RTC_MspDeInit 1 */
}
}
/**
* @brief SPI MSP Initialization
* This function configures the hardware resources used in this example
* @param hspi: SPI handle pointer
* @retval None
*/
void
HAL_SPI_MspInit
(
SPI_HandleTypeDef
*
hspi
)
{
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
if
(
hspi
->
Instance
==
SPI1
)
{
/* USER CODE BEGIN SPI1_MspInit 0 */
/* USER CODE END SPI1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_SPI1_CLK_ENABLE
();
__HAL_RCC_GPIOA_CLK_ENABLE
();
__HAL_RCC_GPIOB_CLK_ENABLE
();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PB4 ------> SPI1_MISO
PB5 ------> SPI1_MOSI
*/
GPIO_InitStruct
.
Pin
=
GPIO_PIN_5
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_VERY_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF5_SPI1
;
HAL_GPIO_Init
(
GPIOA
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Pin
=
GPIO_PIN_4
|
GPIO_PIN_5
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_VERY_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF5_SPI1
;
HAL_GPIO_Init
(
GPIOB
,
&
GPIO_InitStruct
);
/* USER CODE BEGIN SPI1_MspInit 1 */
/* USER CODE END SPI1_MspInit 1 */
}
}
/**
* @brief SPI MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hspi: SPI handle pointer
* @retval None
*/
void
HAL_SPI_MspDeInit
(
SPI_HandleTypeDef
*
hspi
)
{
if
(
hspi
->
Instance
==
SPI1
)
{
/* USER CODE BEGIN SPI1_MspDeInit 0 */
/* USER CODE END SPI1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_SPI1_CLK_DISABLE
();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PB4 ------> SPI1_MISO
PB5 ------> SPI1_MOSI
*/
HAL_GPIO_DeInit
(
GPIOA
,
GPIO_PIN_5
);
HAL_GPIO_DeInit
(
GPIOB
,
GPIO_PIN_4
|
GPIO_PIN_5
);
/* USER CODE BEGIN SPI1_MspDeInit 1 */
/* USER CODE END SPI1_MspDeInit 1 */
}
}
/**
* @brief TIM_Base MSP Initialization
* This function configures the hardware resources used in this example
...
...
bsp/stm32/stm32f411-st-nucleo/board/Kconfig
浏览文件 @
75dc0dcb
...
...
@@ -58,6 +58,27 @@ menu "On-chip Peripheral Drivers"
default 25
endif
menuconfig BSP_USING_SPI
bool "Enable SPI BUS"
default n
select RT_USING_SPI
if BSP_USING_SPI
config BSP_USING_SPI1
bool "Enable SPI1 BUS"
default n
config BSP_SPI1_TX_USING_DMA
bool "Enable SPI1 TX DMA"
depends on BSP_USING_SPI1
default n
config BSP_SPI1_RX_USING_DMA
bool "Enable SPI1 RX DMA"
depends on BSP_USING_SPI1
select BSP_SPI1_TX_USING_DMA
default n
endif
menuconfig BSP_USING_PWM
bool "Enable pwm"
default n
...
...
@@ -85,6 +106,24 @@ menu "On-chip Peripheral Drivers"
endif
endif
menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC"
select RT_USING_RTC
select RT_USING_LIBC
default n
if BSP_USING_ONCHIP_RTC
choice
prompt "Select clock source"
default BSP_RTC_USING_LSE
config BSP_RTC_USING_LSE
bool "RTC USING LSE"
config BSP_RTC_USING_LSI
bool "RTC USING LSI"
endchoice
endif
config BSP_USING_ON_CHIP_FLASH
bool "Enable on-chip FLASH"
default n
...
...
bsp/stm32/stm32f411-st-nucleo/board/board.c
浏览文件 @
75dc0dcb
...
...
@@ -14,6 +14,7 @@ void SystemClock_Config(void)
{
RCC_OscInitTypeDef
RCC_OscInitStruct
=
{
0
};
RCC_ClkInitTypeDef
RCC_ClkInitStruct
=
{
0
};
RCC_PeriphCLKInitTypeDef
PeriphClkInitStruct
=
{
0
};
/**Configure the main internal regulator output voltage
*/
...
...
@@ -21,8 +22,9 @@ void SystemClock_Config(void)
__HAL_PWR_VOLTAGESCALING_CONFIG
(
PWR_REGULATOR_VOLTAGE_SCALE1
);
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct
.
OscillatorType
=
RCC_OSCILLATORTYPE_HSE
;
RCC_OscInitStruct
.
OscillatorType
=
RCC_OSCILLATORTYPE_
LSI
|
RCC_OSCILLATORTYPE_
HSE
;
RCC_OscInitStruct
.
HSEState
=
RCC_HSE_BYPASS
;
RCC_OscInitStruct
.
LSIState
=
RCC_LSI_ON
;
RCC_OscInitStruct
.
PLL
.
PLLState
=
RCC_PLL_ON
;
RCC_OscInitStruct
.
PLL
.
PLLSource
=
RCC_PLLSOURCE_HSE
;
RCC_OscInitStruct
.
PLL
.
PLLM
=
4
;
...
...
@@ -46,4 +48,10 @@ void SystemClock_Config(void)
{
Error_Handler
();
}
PeriphClkInitStruct
.
PeriphClockSelection
=
RCC_PERIPHCLK_RTC
;
PeriphClkInitStruct
.
RTCClockSelection
=
RCC_RTCCLKSOURCE_LSI
;
if
(
HAL_RCCEx_PeriphCLKConfig
(
&
PeriphClkInitStruct
)
!=
HAL_OK
)
{
Error_Handler
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录