spi_flash_init.c 697 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2006-2018, 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. #if defined(BSP_USING_SPI_FLASH)
  12. #include "spi_flash.h"
  13. #include "spi_flash_sfud.h"
  14. #include "drv_spi.h"
  15. #include "drv_gpio.h"
  16. #define CS_PIN GET_PIN(1,4) /* P104,GPIO_AD_B0_04 */
  17. static int rt_hw_spi_flash_init(void)
  18. {
  19. rt_hw_spi_device_attach("spi3", "spi30", CS_PIN);
  20. if (RT_NULL == rt_sfud_flash_probe("W25Q256", "spi30"))
  21. {
  22. return -RT_ERROR;
  23. }
  24. return RT_EOK;
  25. }
  26. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  27. #endif