drv_spi_flash.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-02-08 RT-Thread the first version
  9. */
  10. #include <rtthread.h>
  11. #include <rthw.h>
  12. #include <rtdevice.h>
  13. #define DBG_TAG "FLASH"
  14. #define DBG_LVL DBG_LOG
  15. #include <rtdbg.h>
  16. #define SPI_FLASH_DEVICE_NAME "spi00"
  17. #define SPI_FLASH_CHIP "gd25qxx"
  18. //#define DEBUG
  19. #ifdef DEBUG
  20. #define DEBUG_PRINTF(...) rt_kprintf(__VA_ARGS__)
  21. #else
  22. #define DEBUG_PRINTF(...)
  23. #endif
  24. #ifdef TINA_USING_SPI_FLASH
  25. #include "spi_flash.h"
  26. #if defined(RT_USING_SFUD)
  27. #include "spi_flash_sfud.h"
  28. rt_spi_flash_device_t spi_device;
  29. int rt_hw_spi_flash_with_sfud_init(void)
  30. {
  31. DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
  32. spi_device = rt_sfud_flash_probe(SPI_FLASH_CHIP, SPI_FLASH_DEVICE_NAME);
  33. if (spi_device == NULL)
  34. {
  35. DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
  36. return RT_ERROR;
  37. };
  38. DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
  39. return RT_EOK;
  40. }
  41. INIT_PREV_EXPORT(rt_hw_spi_flash_with_sfud_init);
  42. #endif
  43. #endif