From b4e051a890b1dba5368af6b52f8a55c5d830870d Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sun, 27 Apr 2025 14:09:44 +0800 Subject: [PATCH] [bsp][Infineon] Update the peripherals of XMC7100D --- bsp/Infineon/libraries/HAL_Drivers/drv_spi.c | 12 +++++++ .../.ci/attachconfig/ci.attachconfig.yml | 7 ++++ .../xmc7100d-f144k4160aa/board/Kconfig | 30 +++++++++++++++-- .../xmc7100d-f144k4160aa/board/SConscript | 5 +++ .../board/ports/SConscript | 19 +++++++++++ .../board/ports/drv_filesystem.c | 33 +++++++++++++++++++ .../board/ports/spi_flash_init.c | 28 ++++++++++++++++ 7 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 bsp/Infineon/xmc7100d-f144k4160aa/board/ports/SConscript create mode 100644 bsp/Infineon/xmc7100d-f144k4160aa/board/ports/drv_filesystem.c create mode 100644 bsp/Infineon/xmc7100d-f144k4160aa/board/ports/spi_flash_init.c diff --git a/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c b/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c index 3d0ecb6ed0..d66ef594e5 100644 --- a/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c +++ b/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c @@ -7,6 +7,7 @@ * Date Author Notes * 2022-07-18 Rbb666 first version * 2023-03-30 Rbb666 update spi driver + * 2025-04-27 Hydevcode update spi driver */ #include @@ -28,6 +29,9 @@ #ifdef BSP_USING_SPI3 static struct rt_spi_bus spi_bus3; #endif +#ifdef BSP_USING_SPI5 + static struct rt_spi_bus spi_bus5; +#endif #ifdef BSP_USING_SPI6 static struct rt_spi_bus spi_bus6; #endif @@ -50,6 +54,14 @@ static struct ifx_spi_handle spi_bus_obj[] = .mosi_pin = GET_PIN(6, 0), }, #endif +#if defined(BSP_USING_SPI5) + { + .bus_name = "spi5", + .sck_pin = GET_PIN(7, 2), + .miso_pin = GET_PIN(7, 0), + .mosi_pin = GET_PIN(7, 1), + }, +#endif #if defined(BSP_USING_SPI6) { .bus_name = "spi6", diff --git a/bsp/Infineon/xmc7100d-f144k4160aa/.ci/attachconfig/ci.attachconfig.yml b/bsp/Infineon/xmc7100d-f144k4160aa/.ci/attachconfig/ci.attachconfig.yml index da7fa27476..bf17c09726 100644 --- a/bsp/Infineon/xmc7100d-f144k4160aa/.ci/attachconfig/ci.attachconfig.yml +++ b/bsp/Infineon/xmc7100d-f144k4160aa/.ci/attachconfig/ci.attachconfig.yml @@ -7,3 +7,10 @@ Drivers.I2C: kconfig: - CONFIG_BSP_USING_I2C=y - CONFIG_BSP_USING_HW_I2C1=y +# ------ Peripheral CI ------ +Peripheral.tfcard: + kconfig: + - CONFIG_BSP_USING_TF_CARD=y +Peripheral.qmi8658: + kconfig: + - CONFIG_BSP_USING_QMI8658=y \ No newline at end of file diff --git a/bsp/Infineon/xmc7100d-f144k4160aa/board/Kconfig b/bsp/Infineon/xmc7100d-f144k4160aa/board/Kconfig index 5e624f0192..8bac874859 100644 --- a/bsp/Infineon/xmc7100d-f144k4160aa/board/Kconfig +++ b/bsp/Infineon/xmc7100d-f144k4160aa/board/Kconfig @@ -15,6 +15,24 @@ menu "Onboard Peripheral Drivers" select BSP_USING_UART select BSP_USING_UART4 default y + menuconfig BSP_USING_TF_CARD + bool "Enable TF_CARD" + select BSP_USING_SPI + select RT_USING_SPI_MSD + select RT_USING_DFS + select RT_USING_DFS_DEVFS + select RT_USING_DFS_ELMFAT + default n + if BSP_USING_TF_CARD + config BSP_USING_SPI_FLASH + bool "Using SPI TO SDCARD" + default y + endif + config BSP_USING_QMI8658 + bool "Enable QMI8658" + select BSP_USING_I2C + select PKG_USING_QMI8658 + default n endmenu menu "On-chip Peripheral Drivers" @@ -47,7 +65,7 @@ menu "On-chip Peripheral Drivers" if BSP_USING_I2C menuconfig BSP_USING_HW_I2C1 bool "Enable BSP_USING_HW_I2C1" - default n + default y if BSP_USING_HW_I2C1 config BSP_I2C1_SCL_PIN int "BSP_I2C1_SCL_PIN number(18,2)" @@ -59,7 +77,15 @@ menu "On-chip Peripheral Drivers" default 145 endif endif - + menuconfig BSP_USING_SPI + bool "Enable SPI" + default n + select RT_USING_SPI + if BSP_USING_SPI + config BSP_USING_SPI5 + bool "Enable BSP_USING_SPI5" + default y + endif endmenu endmenu diff --git a/bsp/Infineon/xmc7100d-f144k4160aa/board/SConscript b/bsp/Infineon/xmc7100d-f144k4160aa/board/SConscript index d4626d83e4..4e5fff8733 100644 --- a/bsp/Infineon/xmc7100d-f144k4160aa/board/SConscript +++ b/bsp/Infineon/xmc7100d-f144k4160aa/board/SConscript @@ -58,4 +58,9 @@ CPPDEFINES = ['XMC7100D_F144K4160', 'TARGET_APP_KIT_XMC71_EVK_LITE_V2'] group = DefineGroup('Drivers', src, depend=[''], CPPPATH=path, CPPDEFINES=CPPDEFINES) +list = os.listdir(cwd) +for item in list: + if os.path.isfile(os.path.join(cwd, item, 'SConscript')): + group = group + SConscript(os.path.join(item, 'SConscript')) + Return('group') diff --git a/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/SConscript b/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/SConscript new file mode 100644 index 0000000000..0f1e6e1f3d --- /dev/null +++ b/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/SConscript @@ -0,0 +1,19 @@ +import os +from building import * + +objs = [] +cwd = GetCurrentDir() + +# add general drivers +src = [] +path = [cwd] + +if GetDepend(['BSP_USING_SPI_FLASH']): + src += Glob('spi_flash_init.c') + +if GetDepend(['BSP_USING_TF_CARD']): + src += Glob('drv_filesystem.c') + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path) + +Return('group') diff --git a/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/drv_filesystem.c b/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/drv_filesystem.c new file mode 100644 index 0000000000..552cc223a0 --- /dev/null +++ b/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/drv_filesystem.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-04-27 Hydevcode first version + */ +#include +#include +#include + +#define DBG_TAG "app.filesystem" +#define DBG_LVL DBG_INFO +#include + +#ifdef BSP_USING_TF_CARD +static int filesystem_mount(void) +{ + //elm-fat + if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) + { + LOG_I("Filesystem initialized!"); + } + else + { + LOG_E("Failed to initialize filesystem!"); + } + return 0; +} +INIT_APP_EXPORT(filesystem_mount); +#endif /*BSP_USING_TF_CARD*/ \ No newline at end of file diff --git a/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/spi_flash_init.c b/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/spi_flash_init.c new file mode 100644 index 0000000000..4d461f6564 --- /dev/null +++ b/bsp/Infineon/xmc7100d-f144k4160aa/board/ports/spi_flash_init.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-04-27 Hydevcode first version + */ +#include +#include +#include "drv_spi.h" +#include "dev_spi_msd.h" +#include + +#ifdef BSP_USING_SPI_FLASH +static int rt_spi_flash_init(void) +{ + rt_hw_spi_device_attach("spi5", "spi30", GET_PIN(7, 3)); + if (RT_NULL == msd_init("sd0", "spi30")) + { + return -RT_ERROR; + } + + return RT_EOK; +} +INIT_COMPONENT_EXPORT(rt_spi_flash_init); +#endif /* BSP_USING_SPI_FLASH */