drv_spi.h 884 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * 20012-01-01 aozima first implementation.
  9. */
  10. #ifndef STM32F20X_40X_SPI_H_INCLUDED
  11. #define STM32F20X_40X_SPI_H_INCLUDED
  12. #include <rtthread.h>
  13. #include <drivers/spi.h>
  14. #include "stm32f4xx_hal.h"
  15. //#define SPI_USE_DMA
  16. struct stm32f4_spi
  17. {
  18. SPI_HandleTypeDef spi_handle;
  19. #ifdef SPI_USE_DMA
  20. DMA_HandleTypeDef hdma_rx;
  21. IRQn_Type hdma_rx_irq;
  22. DMA_HandleTypeDef hdma_tx;
  23. IRQn_Type hdma_tx_irq;
  24. #endif /* #ifdef SPI_USE_DMA */
  25. };
  26. struct stm32_spi_cs
  27. {
  28. GPIO_TypeDef * GPIOx;
  29. uint16_t GPIO_Pin;
  30. };
  31. /* public function */
  32. rt_err_t stm32_spi_bus_register(SPI_TypeDef * SPI,
  33. //struct stm32_spi_bus * stm32_spi,
  34. const char * spi_bus_name);
  35. #endif // STM32F20X_40X_SPI_H_INCLUDED