spi_flash_init.c 658 B

12345678910111213141516171819202122232425262728293031
  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. static int rt_hw_spi_flash_init(void)
  16. {
  17. __HAL_RCC_GPIOA_CLK_ENABLE();
  18. rt_hw_spi_device_attach("spi2", "spi20", GPIOB, GPIO_PIN_12);
  19. if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi20"))
  20. {
  21. return -RT_ERROR;
  22. };
  23. return RT_EOK;
  24. }
  25. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  26. #endif