Browse Source

[bsp][Infineon] Update the peripherals of XMC7100D

hydevcode 6 days ago
parent
commit
b4e051a890

+ 12 - 0
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 <drv_spi.h>
@@ -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",

+ 7 - 0
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

+ 28 - 2
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

+ 5 - 0
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')

+ 19 - 0
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')

+ 33 - 0
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 <rtthread.h>
+#include <rtdevice.h>
+#include <dfs_fs.h>
+
+#define DBG_TAG "app.filesystem"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
+#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*/

+ 28 - 0
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 <rtthread.h>
+#include <rtdevice.h>
+#include "drv_spi.h"
+#include "dev_spi_msd.h"
+#include <dfs_fs.h>
+
+#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 */