spi_flash_init.c 666 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-01-10 luobeihai first version
  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. static int rt_hw_spi_flash_init(void)
  16. {
  17. RCM_EnableAHB1PeriphClock(RCM_AHB1_PERIPH_GPIOF);
  18. rt_hw_spi_device_attach("spi1", "spi10", GPIOF, GPIO_PIN_5);
  19. if (RT_NULL == rt_sfud_flash_probe("W25Q16", "spi10"))
  20. {
  21. return -RT_ERROR;
  22. }
  23. return RT_EOK;
  24. }
  25. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  26. #endif