drv_spi.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. * Copyright (c) 2022, Xiaohua Semiconductor Co., Ltd.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2022-04-28 CDT first version
  10. */
  11. #ifndef __DRV_SPI_H__
  12. #define __DRV_SPI_H__
  13. /*******************************************************************************
  14. * Include files
  15. ******************************************************************************/
  16. #include <rtthread.h>
  17. #include "rtdevice.h"
  18. #include "drv_dma.h"
  19. #include "drv_irq.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. struct hc32_hw_spi_cs
  24. {
  25. rt_uint8_t port;
  26. rt_uint16_t pin;
  27. };
  28. struct hc32_spi_config
  29. {
  30. CM_SPI_TypeDef *Instance;
  31. char *bus_name;
  32. rt_uint32_t clock;
  33. // struct hc32_irq_config irq_config;
  34. struct dma_config *dma_rx;
  35. struct dma_config *dma_tx;
  36. };
  37. struct hc32_spi
  38. {
  39. struct hc32_spi_config *config;
  40. struct rt_spi_configuration *cfg;
  41. struct rt_spi_bus spi_bus;
  42. rt_uint8_t spi_dma_flag;
  43. };
  44. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, uint8_t cs_gpio_port, uint16_t cs_gpio_pin);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* __DRV_SPI_H__ */