drv_spi.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. * 2022-04-28 CDT first version
  9. */
  10. #ifndef __DRV_SPI_H__
  11. #define __DRV_SPI_H__
  12. /*******************************************************************************
  13. * Include files
  14. ******************************************************************************/
  15. #include <rtthread.h>
  16. #include "rtdevice.h"
  17. #include "drv_dma.h"
  18. #include "drv_irq.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. struct hc32_spi_irq_config
  23. {
  24. struct hc32_irq_config irq_config;
  25. func_ptr_t irq_callback;
  26. };
  27. struct hc32_spi_config
  28. {
  29. CM_SPI_TypeDef *Instance;
  30. char *bus_name;
  31. rt_uint32_t clock;
  32. rt_uint32_t timeout;
  33. struct hc32_spi_irq_config err_irq;
  34. #ifdef BSP_SPI_USING_DMA
  35. struct dma_config *dma_rx;
  36. struct dma_config *dma_tx;
  37. #endif
  38. };
  39. struct hc32_spi
  40. {
  41. struct hc32_spi_config *config;
  42. struct rt_spi_configuration *cfg;
  43. struct rt_spi_bus spi_bus;
  44. rt_uint16_t spi_dma_flag;
  45. };
  46. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_base_t cs_pin);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* __DRV_SPI_H__ */