drv_spi_flash.c 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2.  * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
  3.  *
  4.  * SPDX-License-Identifier: Apache-2.0.
  5.  *
  6. * @Date: 2021-04-25 14:01:16
  7. * @LastEditTime: 2021-04-30 14:43:12
  8. * @Description:  This files is for
  9. *
  10. * @Modify History:
  11. * Ver   Who        Date         Changes
  12. * ----- ------     --------    --------------------------------------
  13. */
  14. #include <board.h>
  15. #include <drv_spi.h>
  16. #include <rtdevice.h>
  17. #include <rthw.h>
  18. #include <finsh.h>
  19. #include "ft_spi.h"
  20. #ifdef BSP_USE_SPI
  21. #include "spi_flash.h"
  22. #include "spi_flash_sfud.h"
  23. static int rt_hw_spi_flash_init(void)
  24. {
  25. uint16_t cs_pin = 5;
  26. rt_hw_spi_device_attach(SPI_BUS_NAME, SPI_DEV_NAME, cs_pin);
  27. rt_kprintf("attach spi flash\r\n");
  28. /* lookup flah */
  29. if (RT_NULL == rt_sfud_flash_probe("S25FS256S", SPI_DEV_NAME))
  30. {
  31. rt_kprintf("attach spi flash failed\r\n");
  32. return -RT_ERROR;
  33. }
  34. return RT_EOK;
  35. }
  36. INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
  37. #endif