From 900050ba98b0dc6bfe2eae0f8e82054841987a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=BF=9E=E9=92=8A?= Date: Wed, 13 Mar 2019 16:20:56 +0800 Subject: [PATCH] =?UTF-8?q?[bsp][stm32][stm32f103-fire-arbitrary][board]?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9stm32f1xx=5Fhal=5Fmsp.c=E6=96=87=E4=BB=B6C?= =?UTF-8?q?AN=E5=BC=95=E8=84=9A=E9=85=8D=E7=BD=AE,=20=E4=BF=AE=E6=94=B9Kco?= =?UTF-8?q?nfig=E6=96=87=E4=BB=B6,=E5=8F=96=E6=B6=88CAN2=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=86=85=E5=AE=B9=20=E8=BF=98=E5=8E=9Fstm32f1xx=5Fhal=5Fconf.h?= =?UTF-8?q?=E4=B8=AD=E4=B8=8ECAN=E4=B8=8D=E7=9B=B8=E5=85=B3=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CubeMX_Config/Inc/stm32f1xx_hal_conf.h | 2 +- .../CubeMX_Config/Src/stm32f1xx_hal_msp.c | 22 ++++++++------- .../board/CubeMX_Config/stm32f103zet6.ioc | 28 ++++++++++--------- .../stm32f103-fire-arbitrary/board/Kconfig | 7 +---- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h b/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h index 09e80a7af8..da03637772 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h @@ -50,7 +50,7 @@ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ +/*#define HAL_CRYP_MODULE_ENABLED */ #define HAL_CAN_MODULE_ENABLED /*#define HAL_CEC_MODULE_ENABLED */ /*#define HAL_CORTEX_MODULE_ENABLED */ diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c b/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c index 342287de06..bfcbb8e69e 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c @@ -184,20 +184,22 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan) /* Peripheral clock enable */ __HAL_RCC_CAN1_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); /**CAN GPIO Configuration - PA11 ------> CAN_RX - PA12 ------> CAN_TX + PB8 ------> CAN_RX + PB9 ------> CAN_TX */ - GPIO_InitStruct.Pin = GPIO_PIN_11; + GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_12; + GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + __HAL_AFIO_REMAP_CAN1_2(); /* USER CODE BEGIN CAN1_MspInit 1 */ @@ -225,10 +227,10 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan) __HAL_RCC_CAN1_CLK_DISABLE(); /**CAN GPIO Configuration - PA11 ------> CAN_RX - PA12 ------> CAN_TX + PB8 ------> CAN_RX + PB9 ------> CAN_TX */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); /* USER CODE BEGIN CAN1_MspDeInit 1 */ diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/stm32f103zet6.ioc b/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/stm32f103zet6.ioc index 4f52bc8de9..2701405c12 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/stm32f103zet6.ioc +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/CubeMX_Config/stm32f103zet6.ioc @@ -45,15 +45,15 @@ Mcu.Pin18=PC9 Mcu.Pin19=PA9 Mcu.Pin2=OSC_IN Mcu.Pin20=PA10 -Mcu.Pin21=PA11 -Mcu.Pin22=PA12 -Mcu.Pin23=PA13 -Mcu.Pin24=PA14 -Mcu.Pin25=PC10 -Mcu.Pin26=PC11 -Mcu.Pin27=PC12 -Mcu.Pin28=PD2 -Mcu.Pin29=PB5 +Mcu.Pin21=PA13 +Mcu.Pin22=PA14 +Mcu.Pin23=PC10 +Mcu.Pin24=PC11 +Mcu.Pin25=PC12 +Mcu.Pin26=PD2 +Mcu.Pin27=PB5 +Mcu.Pin28=PB8 +Mcu.Pin29=PB9 Mcu.Pin3=OSC_OUT Mcu.Pin30=VP_IWDG_VS_IWDG Mcu.Pin31=VP_RTC_VS_RTC_Activate @@ -91,10 +91,6 @@ OSC_OUT.Mode=HSE-External-Oscillator OSC_OUT.Signal=RCC_OSC_OUT PA10.Mode=Asynchronous PA10.Signal=USART1_RX -PA11.Mode=Master -PA11.Signal=CAN_RX -PA12.Mode=Master -PA12.Signal=CAN_TX PA13.Mode=Serial_Wire PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Serial_Wire @@ -124,6 +120,12 @@ PB14.Signal=SPI2_MISO PB15.Mode=Full_Duplex_Master PB15.Signal=SPI2_MOSI PB5.Signal=S_TIM3_CH2 +PB8.Locked=true +PB8.Mode=Master +PB8.Signal=CAN_RX +PB9.Locked=true +PB9.Mode=Master +PB9.Signal=CAN_TX PC1.Locked=true PC1.Signal=ADCx_IN11 PC10.Mode=SD_4_bits_Wide_bus diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/Kconfig b/bsp/stm32/stm32f103-fire-arbitrary/board/Kconfig index 69e15c202f..62f6ea86ce 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/Kconfig +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/Kconfig @@ -268,18 +268,13 @@ menu "On-chip Peripheral Drivers" default n menuconfig BSP_USING_CAN - bool "Enable can" + bool "Enable CAN" default n select RT_USING_CAN if BSP_USING_CAN config BSP_USING_CAN1 bool "using CAN1" default n - - config BSP_USING_CAN2 - bool "using CAN2" - default n - select BSP_USING_CAN1 endif endmenu