soft_spi_flash_init.c 705 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. * 2022-6-14 solar first version
  9. */
  10. #include <rtthread.h>
  11. #include "spi_flash.h"
  12. #include "spi_flash_sfud.h"
  13. #include <drv_spi.h>
  14. #include <drv_soft_spi.h>
  15. #ifdef BSP_USING_SOFT_SPI_FLASH
  16. static int rt_soft_spi_flash_init(void)
  17. {
  18. __HAL_RCC_GPIOB_CLK_ENABLE();
  19. rt_hw_soft_spi_device_attach("sspi2", "sspi20", "PB.14");
  20. if (RT_NULL == rt_sfud_flash_probe("W25Q128", "sspi20"))
  21. {
  22. return -RT_ERROR;
  23. }
  24. return RT_EOK;
  25. }
  26. INIT_COMPONENT_EXPORT(rt_soft_spi_flash_init);
  27. #endif /* BSP_USING_SOFT_SPI_FLASH */