drv_spiflash.c 702 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2019 Winner Microelectronics Co., Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-12 fanwenl 1st version
  9. */
  10. #include <rtthread.h>
  11. #include <rtdevice.h>
  12. #ifdef BSP_USING_FLASH
  13. #include "drv_spi.h"
  14. #include "string.h"
  15. #include "spi_flash.h"
  16. #include "spi_flash_sfud.h"
  17. int wm_nor_flash_init(void)
  18. {
  19. rt_spi_flash_device_t spi_device;
  20. wm_spi_bus_attach_device(SPI_Flash_BUS_NAME, "norspi", SPI_Flash_CS_PIN);
  21. spi_device = rt_sfud_flash_probe("flash0", "norspi");
  22. if (spi_device == RT_NULL)
  23. {
  24. return -RT_ERROR;
  25. }
  26. return 0;
  27. }
  28. INIT_DEVICE_EXPORT(wm_nor_flash_init);
  29. #endif