drv_spi.h 925 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-12-20 BruceOu first implementation
  9. */
  10. #ifndef __DRV_SPI_H__
  11. #define __DRV_SPI_H__
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include <board.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. struct gd32_spi_cs
  19. {
  20. uint32_t GPIOx;
  21. uint32_t GPIO_Pin;
  22. };
  23. /* gd32 spi dirver class */
  24. struct gd32_spi
  25. {
  26. uint32_t spi_periph;
  27. char *bus_name;
  28. rcu_periph_enum spi_clk;
  29. rcu_periph_enum gpio_clk;
  30. struct rt_spi_bus *spi_bus;
  31. uint32_t spi_port;
  32. #if defined SOC_SERIES_GD32F4xx
  33. uint32_t alt_func_num;
  34. #endif
  35. uint16_t sck_pin;
  36. uint16_t miso_pin;
  37. uint16_t mosi_pin;
  38. };
  39. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_base_t cs_pin);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* __DRV_SPI_H__ */