drv_spi.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-5 SummerGift change to new framework
  9. */
  10. #ifndef __DRV_SPI_H_
  11. #define __DRV_SPI_H_
  12. #include <rtthread.h>
  13. #include "rtdevice.h"
  14. #include <rthw.h>
  15. #include <drv_common.h>
  16. #include "drv_dma.h"
  17. rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, GPIO_TypeDef* cs_gpiox, uint16_t cs_gpio_pin);
  18. struct stm32_hw_spi_cs
  19. {
  20. GPIO_TypeDef* GPIOx;
  21. uint16_t GPIO_Pin;
  22. };
  23. struct stm32_spi_config
  24. {
  25. SPI_TypeDef *Instance;
  26. char *bus_name;
  27. struct dma_config dma_rx, dma_tx;
  28. };
  29. struct stm32_spi_device
  30. {
  31. rt_uint32_t pin;
  32. char *bus_name;
  33. char *device_name;
  34. };
  35. /* stm32 spi dirver class */
  36. struct stm32_spi
  37. {
  38. SPI_HandleTypeDef handle;
  39. const struct stm32_spi_config *config;
  40. struct rt_spi_configuration *cfg;
  41. #ifdef BSP_SPI_USING_DMA
  42. struct
  43. {
  44. DMA_HandleTypeDef handle_rx;
  45. DMA_HandleTypeDef handle_tx;
  46. } dma;
  47. #endif
  48. struct rt_spi_bus spi_bus;
  49. };
  50. #endif /*__DRV_SPI_H_ */