drv_spi.h 857 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. * 2022-05-16 shelton first version
  9. */
  10. #ifndef __DRV_SPI__
  11. #define __DRV_SPI__
  12. #include <rtthread.h>
  13. #include <drivers/spi.h>
  14. #include "drv_common.h"
  15. #include "drv_dma.h"
  16. struct at32_spi_config
  17. {
  18. spi_type *spi_x;
  19. const char *spi_name;
  20. IRQn_Type irqn;
  21. struct dma_config *dma_rx;
  22. struct dma_config *dma_tx;
  23. rt_uint16_t spi_dma_flag;
  24. };
  25. struct at32_spi
  26. {
  27. struct at32_spi_config *config;
  28. struct rt_spi_bus spi_bus;
  29. };
  30. struct at32_spi_cs
  31. {
  32. gpio_type *gpio_x;
  33. uint32_t gpio_pin;
  34. };
  35. /* public function */
  36. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, gpio_type *cs_gpiox, uint16_t cs_gpio_pin);
  37. #endif // __DRV_SPI__