11/*
2- * Copyright (c) 2006-2024 RT-Thread Development Team
2+ * Copyright (c) 2006-2025 RT-Thread Development Team
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 *
@@ -349,6 +349,19 @@ rt_err_t rt_spi_bus_attach_device(struct rt_spi_device *device,
349349 const char * bus_name ,
350350 void * user_data );
351351
352+ /**
353+ * @brief Detach a device from the SPI bus.
354+ *
355+ * This function serves as the high-level API to detach a SPI device from its bus.
356+ * It unregisters the device from the device framework and ensures all associated
357+ * resources, such as the chip select pin, are properly released by calling
358+ * the underlying implementation.
359+ *
360+ * @param device The SPI device to be detached.
361+ *
362+ * @return rt_err_t The result of the operation. RT_EOK on success, otherwise an error code.
363+ */
364+ rt_err_t rt_spi_bus_detach_device (struct rt_spi_device * device );
352365
353366/**
354367 * @brief attach a device on SPI bus with CS pin
@@ -367,6 +380,21 @@ rt_err_t rt_spi_bus_attach_device_cspin(struct rt_spi_device *device,
367380 rt_base_t cs_pin ,
368381 void * user_data );
369382
383+ /**
384+ * @brief Detach a device from the SPI bus and release its CS pin.
385+ *
386+ * This function provides the low-level implementation for detaching a device
387+ * from the SPI bus. It specifically handles the operations for the chip select (CS)
388+ * pin, resetting it to input mode to release it. This function is typically
389+ * called by the higher-level rt_spi_bus_detach_device() and should not be
390+ * called directly by the user application.
391+ *
392+ * @param device The SPI device to be detached.
393+ *
394+ * @return rt_err_t The result of the operation. RT_EOK on success, otherwise an error code.
395+ */
396+ rt_err_t rt_spi_bus_detach_device_cspin (struct rt_spi_device * device );
397+
370398/**
371399 * @brief Reconfigure the SPI bus for the specified device.
372400 *
0 commit comments