spi_flash_init.c 743 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2025-04-27 Hydevcode first version
  9. */
  10. #include <rtthread.h>
  11. #include <rtdevice.h>
  12. #include "drv_spi.h"
  13. #include "dev_spi_msd.h"
  14. #include <dfs_fs.h>
  15. #ifdef BSP_USING_SPI_FLASH
  16. static int rt_spi_flash_init(void)
  17. {
  18. #if !defined(BSP_USING_RW007)
  19. rt_hw_spi_device_attach("spi5", "spi30", GET_PIN(7, 3));
  20. #else
  21. rt_hw_spi_device_attach(IFX_RW007_SPI_BUS_NAME, "spi30", GET_PIN(20, 3));
  22. #endif
  23. if (RT_NULL == msd_init("sd0", "spi30"))
  24. {
  25. return -RT_ERROR;
  26. }
  27. return RT_EOK;
  28. }
  29. INIT_COMPONENT_EXPORT(rt_spi_flash_init);
  30. #endif /* BSP_USING_SPI_FLASH */