drv_spiflash.c 724 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-3-30 bluebear233 first version
  9. */
  10. #include <rtdevice.h>
  11. #ifdef RT_USING_SPI
  12. #if defined(RT_USING_SFUD)
  13. static struct rt_spi_device spi_device;
  14. #include "spi_flash.h"
  15. #include "spi_flash_sfud.h"
  16. #endif
  17. static int rt_hw_spi_flash_init(void)
  18. {
  19. rt_spi_bus_attach_device(&spi_device, "qspi01", "qspi0", RT_NULL);
  20. #if defined(RT_USING_SFUD)
  21. if (rt_sfud_flash_probe("flash0", "qspi01") == RT_NULL)
  22. {
  23. return -RT_ERROR;
  24. }
  25. #endif
  26. return 0;
  27. }
  28. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  29. #endif /* RT_USING_SPI */