drv_qspi.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2022-2024, Xiaohua Semiconductor Co., Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-06-15 CDT first version
  9. */
  10. #ifndef __DRV_QSPI_H__
  11. #define __DRV_QSPI_H__
  12. #include <rtthread.h>
  13. #include <rtdevice.h>
  14. #include "drv_dma.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. struct hc32_hw_qspi_cs
  19. {
  20. rt_uint16_t pin;
  21. };
  22. struct hc32_qspi_irq_config
  23. {
  24. struct hc32_irq_config irq_config;
  25. func_ptr_t irq_callback;
  26. };
  27. struct hc32_qspi_config
  28. {
  29. CM_QSPI_TypeDef *Instance;
  30. rt_uint32_t clock;
  31. rt_uint32_t timeout;
  32. struct hc32_qspi_irq_config err_irq;
  33. #ifdef BSP_QSPI_USING_DMA
  34. struct dma_config *dma_qspi;
  35. #if defined (HC32F448) || defined (HC32F4A8)
  36. rt_uint16_t *dma_tx_buf;
  37. rt_uint16_t dma_tx_buf_size; /* unit: half-word, DMA data width of QSPI transmitting is 16bit */
  38. #endif
  39. #endif
  40. };
  41. struct hc32_qspi_bus
  42. {
  43. struct hc32_qspi_config *config;
  44. char *bus_name;
  45. };
  46. rt_err_t rt_hw_qspi_bus_attach_device(const char *bus_name, const char *device_name, rt_uint32_t pin, rt_uint8_t data_line_width, void (*enter_qspi_mode)(), void (*exit_qspi_mode)());
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* __DRV_QSPI_H__ */