spi_flash_init.c 803 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-27 SummerGift add spi flash port file
  9. */
  10. #include <rtthread.h>
  11. #include "spi_flash.h"
  12. #include "spi_flash_sfud.h"
  13. #include "drv_spi.h"
  14. #if defined(BSP_USING_SPI_FLASH)
  15. #ifdef FAL_USING_NOR_FLASH_DEV_NAME
  16. #define _SPI_FLASH_NAME FAL_USING_NOR_FLASH_DEV_NAME
  17. #else
  18. #define _SPI_FLASH_NAME "W25Q128"
  19. #endif
  20. static int rt_hw_spi_flash_init(void)
  21. {
  22. __HAL_RCC_GPIOB_CLK_ENABLE();
  23. rt_hw_spi_device_attach("spi1", "spi10", GPIOB, GPIO_PIN_14);
  24. if (RT_NULL == rt_sfud_flash_probe(_SPI_FLASH_NAME, "spi10"))
  25. {
  26. return -RT_ERROR;
  27. };
  28. return RT_EOK;
  29. }
  30. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  31. #endif