spi_flash_init.c 666 B

123456789101112131415161718192021222324252627282930
  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. * 2022-12-29 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_EnableAPB2PeriphClock(RCM_APB2_PERIPH_GPIOA);
  18. rt_hw_spi_device_attach("spi3", "spi30", GPIOA, GPIO_PIN_15);
  19. if (RT_NULL == rt_sfud_flash_probe("W25Q16", "spi30"))
  20. {
  21. return -RT_ERROR;
  22. }
  23. return RT_EOK;
  24. }
  25. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  26. #endif