spi_flash_init.c 684 B

123456789101112131415161718192021222324252627282930313233
  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 "dev_spi_flash.h"
  12. #include "dev_spi_flash_sfud.h"
  13. #include <drv_spi.h>
  14. #include <drv_gpio.h>
  15. #if defined(BSP_USING_SPI_FLASH)
  16. static int rt_hw_spi_flash_init(void)
  17. {
  18. __HAL_RCC_GPIOB_CLK_ENABLE();
  19. rt_hw_spi_device_attach("spi1", "spi10", GET_PIN(A, 4));
  20. if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi10"))
  21. {
  22. return -RT_ERROR;
  23. }
  24. return RT_EOK;
  25. }
  26. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  27. #endif