drv_spi_flash.c 628 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "drv_spi.h"
  7. #include "drv_spi_flash.h"
  8. #include "rtthread.h"
  9. #include "rtdevice.h"
  10. #include "spi_flash.h"
  11. #include "spi_flash_sfud.h"
  12. #define RT_SPI_FLASH_CS_PIN (2)
  13. int rt_hw_flash_init(void)
  14. {
  15. rt_err_t result;
  16. result = lpc_spi_bus_attach_device("spi2", "spi20", RT_SPI_FLASH_CS_PIN);
  17. if(result != RT_EOK)
  18. {
  19. return result;
  20. }
  21. if(rt_sfud_flash_probe("flash0", "spi20") == RT_NULL)
  22. {
  23. return RT_ERROR;
  24. }
  25. return RT_EOK;
  26. }
  27. INIT_DEVICE_EXPORT(rt_hw_flash_init);