Skip to content

Commit 59a690a

Browse files
authored
GD32: add CAN driver for GD32F4xx (#10152)
* GD32: add CAN driver for GD32F4xx * Removed extra spaces * Add attachconfig.yml, edit CAN0 GPIO * Changed attachconfig.yml * Fixed config defines names
1 parent 97850b5 commit 59a690a

File tree

5 files changed

+1137
-0
lines changed

5 files changed

+1137
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
peripheral.can0:
2+
kconfig:
3+
- CONFIG_BSP_USING_CAN=y
4+
- CONFIG_BSP_USING_CAN0=y

bsp/gd32/arm/gd32450z-eval/board/Kconfig

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,74 @@ menu "On-chip Peripheral Drivers"
374374
endif
375375
endif
376376

377+
menuconfig BSP_USING_CAN
378+
bool "Enable CAN BUS"
379+
default n
380+
select RT_USING_CAN
381+
select RT_USING_DEVICE_IPC
382+
if BSP_USING_CAN
383+
config BSP_USING_CAN0
384+
bool "Enable CAN0"
385+
default n
386+
387+
if BSP_USING_CAN0
388+
choice
389+
prompt "Select CAN0 TX source"
390+
default BSP_CAN0_TX_PD1
391+
392+
config BSP_CAN0_TX_PA12
393+
bool "GPIOA pin 12"
394+
config BSP_CAN0_TX_PB9
395+
bool "GPIOB pin 9"
396+
config BSP_CAN0_TX_PD1
397+
bool "GPIOD pin 1"
398+
config BSP_CAN0_TX_PH13
399+
bool "GPIOH pin 13"
400+
endchoice
401+
402+
choice
403+
prompt "Select CAN0 RX source"
404+
default BSP_CAN0_RX_PD0
405+
406+
config BSP_CAN0_RX_PA11
407+
bool "GPIOA pin 11"
408+
config BSP_CAN0_RX_PB8
409+
bool "GPIOB pin 8"
410+
config BSP_CAN0_RX_PD0
411+
bool "GPIOD pin 0"
412+
config BSP_CAN0_RX_PI9
413+
bool "GPIOI pin 9"
414+
endchoice
415+
endif
416+
417+
config BSP_USING_CAN1
418+
bool "Enable CAN1"
419+
default n
420+
421+
if BSP_USING_CAN1
422+
choice
423+
prompt "Select CAN1 TX source"
424+
default BSP_CAN1_TX_PB6
425+
426+
config BSP_CAN1_TX_PB6
427+
bool "GPIOB pin 6"
428+
config BSP_CAN1_TX_PB13
429+
bool "GPIOB pin 13"
430+
endchoice
431+
432+
choice
433+
prompt "Select CAN1 RX source"
434+
default BSP_CAN1_RX_PB5
435+
436+
config BSP_CAN1_RX_PB5
437+
bool "GPIOB pin 5"
438+
config BSP_CAN1_RX_PI12
439+
bool "GPIOI pin 12"
440+
endchoice
441+
endif
442+
443+
endif
444+
377445
rsource "../../libraries/gd32_drivers/Kconfig"
378446

379447
endmenu

bsp/gd32/arm/libraries/gd32_drivers/SConscript

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ if GetDepend('RT_USING_SDIO'):
5656
if GetDepend('RT_USING_PWM'):
5757
src += ['drv_pwm.c']
5858

59+
# add can drivers.
60+
if GetDepend('RT_USING_CAN'):
61+
src += ['drv_can.c']
62+
5963
# add sdram drivers.
6064
if GetDepend('BSP_USING_SDRAM'):
6165
src += ['drv_sdram.c']

0 commit comments

Comments
 (0)