Skip to content

Commit 9dc0bbb

Browse files
committed
Merge remote-tracking branch 'gitee/gitee_master'
2 parents 8c00fa3 + 0577726 commit 9dc0bbb

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Inc/stm32f1xx_hal_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define HAL_MODULE_ENABLED
3636
/*#define HAL_ADC_MODULE_ENABLED */
3737
/*#define HAL_CRYP_MODULE_ENABLED */
38-
/*#define HAL_CAN_MODULE_ENABLED */
38+
#define HAL_CAN_MODULE_ENABLED
3939
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
4040
/*#define HAL_CEC_MODULE_ENABLED */
4141
/*#define HAL_CORTEX_MODULE_ENABLED */

bsp/stm32/stm32f103-atk-warshipv3/board/CubeMX_Config/Src/stm32f1xx_hal_msp.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,73 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
294294
}
295295

296296
}
297+
/**
298+
* @brief CAN MSP Initialization
299+
* This function configures the hardware resources used in this example
300+
* @param hcan: CAN handle pointer
301+
* @retval None
302+
*/
303+
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
304+
{
305+
GPIO_InitTypeDef GPIO_InitStruct = {0};
306+
if(hcan->Instance==CAN1)
307+
{
308+
/* USER CODE BEGIN CAN1_MspInit 0 */
309+
310+
/* USER CODE END CAN1_MspInit 0 */
311+
/* Peripheral clock enable */
312+
__HAL_RCC_CAN1_CLK_ENABLE();
313+
314+
__HAL_RCC_GPIOA_CLK_ENABLE();
315+
/**CAN GPIO Configuration
316+
PA11 ------> CAN_RX
317+
PA12 ------> CAN_TX
318+
*/
319+
GPIO_InitStruct.Pin = GPIO_PIN_11;
320+
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
321+
GPIO_InitStruct.Pull = GPIO_NOPULL;
322+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
323+
324+
GPIO_InitStruct.Pin = GPIO_PIN_12;
325+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
326+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
327+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
328+
329+
/* USER CODE BEGIN CAN1_MspInit 1 */
330+
331+
/* USER CODE END CAN1_MspInit 1 */
332+
}
333+
334+
}
335+
/**
336+
* @brief CAN MSP De-Initialization
337+
* This function freeze the hardware resources used in this example
338+
* @param hcan: CAN handle pointer
339+
* @retval None
340+
*/
341+
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
342+
{
343+
if(hcan->Instance==CAN1)
344+
{
345+
/* USER CODE BEGIN CAN1_MspDeInit 0 */
346+
347+
/* USER CODE END CAN1_MspDeInit 0 */
348+
/* Peripheral clock disable */
349+
__HAL_RCC_CAN1_CLK_DISABLE();
350+
351+
/**CAN GPIO Configuration
352+
PA11 ------> CAN_RX
353+
PA12 ------> CAN_TX
354+
*/
355+
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
356+
357+
/* USER CODE BEGIN CAN1_MspDeInit 1 */
358+
359+
/* USER CODE END CAN1_MspDeInit 1 */
360+
}
361+
362+
}
363+
297364

298365
static uint32_t FSMC_Initialized = 0;
299366

bsp/stm32/stm32f103-atk-warshipv3/board/Kconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,18 @@ menu "On-chip Peripheral Drivers"
188188
bool "Enable ADC1"
189189
default n
190190
endif
191-
191+
menuconfig BSP_USING_CAN
192+
bool "Enable CAN"
193+
default n
194+
select RT_USING_CAN
195+
if BSP_USING_CAN
196+
config BSP_USING_CAN1
197+
bool "Enable CAN1"
198+
default n
199+
config BSP_USING_CAN2
200+
bool "Enable CAN2"
201+
default n
202+
endif
192203
config BSP_USING_ON_CHIP_FLASH
193204
bool "Enable on-chip FLASH"
194205
default n

tools/rtthread.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ $(if $(strip $(LOCALS)),$(eval $(LOCALS): $(S_SRC)
5555
@$(CROSS_COMPILE)gcc $$(AFLAGS) -c $$< -o $$@))
5656
endef
5757

58+
define add_s_file
59+
$(eval S_SRC := $(1:$(BSP_ROOT)/%=%)) \
60+
$(eval S_SRC := $(S_SRC:$(RTT_ROOT)/%=%)) \
61+
$(eval SOBJ := $(1:%.s=%.o)) \
62+
$(eval SOBJ := $(SOBJ:$(BSP_ROOT)/%=$(BSP_BUILD_DIR)/%)) \
63+
$(eval SOBJ := $(SOBJ:$(RTT_ROOT)/%=$(RTT_BUILD_DIR)/%)) \
64+
$(eval LOCALS := $(addprefix $(BUILD_DIR)/,$(SOBJ))) \
65+
$(eval OBJS += $(LOCALS)) \
66+
$(if $(strip $(LOCALS)),$(eval $(LOCALS): $(S_SRC)
67+
@if [ ! -d $$(@D) ]; then mkdir -p $$(@D); fi
68+
@echo cc $$<
69+
@$(CROSS_COMPILE)gcc $$(AFLAGS) -c $$< -o $$@))
70+
endef
71+
5872
add_flg = $(eval CFLAGS += $1) \
5973
$(eval AFLAGS += $1) \
6074
$(eval CXXFLAGS += $1)
@@ -89,6 +103,9 @@ $(if $(SRCS),$(foreach f,$(SRCS),$(call add_cxx_file,$(f))))
89103
SRCS := $(strip $(filter %.S,$(SRC_FILES)))
90104
$(if $(SRCS),$(foreach f,$(SRCS),$(call add_S_file,$(f))))
91105

106+
SRCS := $(strip $(filter %.s,$(SRC_FILES)))
107+
$(if $(SRCS),$(foreach f,$(SRCS),$(call add_s_file,$(f))))
108+
92109
CFLAGS += $(CPPPATHS)
93110
CXXFLAGS += $(CPPPATHS)
94111
AFLAGS += $(CPPPATHS)

0 commit comments

Comments
 (0)