drv_spi.h 750 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. struct at32_spi_config
  16. {
  17. spi_type *spi_x;
  18. const char *spi_name;
  19. };
  20. struct at32_spi
  21. {
  22. struct at32_spi_config *config;
  23. struct rt_spi_bus spi_bus;
  24. };
  25. struct at32_spi_cs
  26. {
  27. gpio_type *gpio_x;
  28. uint32_t gpio_pin;
  29. };
  30. /* public function */
  31. int rt_hw_spi_init(void);
  32. 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);
  33. #endif // __DRV_SPI__