dev_soft_spi.h 896 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @file softspi.h
  3. * @author Myth
  4. * @version 0.2
  5. * @date 2021.10.12
  6. * @brief STM32 SoftSPI Library
  7. */
  8. #ifndef DEV_SOFT_SPI_H
  9. #define DEV_SOFT_SPI_H
  10. #include "dev_spi_conf.h"
  11. /**
  12. * @brief SoftSPI Structure definition
  13. */
  14. typedef struct
  15. {
  16. GPIO_TypeDef *SCLK_GPIO;
  17. uint32_t SCLK_Pin;
  18. GPIO_TypeDef *MOSI_GPIO;
  19. uint32_t MOSI_Pin;
  20. GPIO_TypeDef *MISO_GPIO;
  21. uint32_t MISO_Pin;
  22. GPIO_TypeDef *SS_GPIO;
  23. uint32_t SS_Pin;
  24. GPIO_TypeDef *WP_GPIO;
  25. uint32_t WP_Pin;
  26. uint32_t Delay_Time;
  27. } SoftSPI_TypeDef;
  28. HAL_StatusTypeDef SoftSPI_Init(SoftSPI_TypeDef *SoftSPIx);
  29. void SoftSPI_SetSS(SoftSPI_TypeDef *SoftSPIx);
  30. void SoftSPI_ClrSS(SoftSPI_TypeDef *SoftSPIx);
  31. uint8_t SoftSPI_WriteRead(SoftSPI_TypeDef *SoftSPIx, uint8_t byte);
  32. void SoftSPI_WriteReadBuff(SoftSPI_TypeDef *SoftSPIx, uint8_t *pWrite, uint8_t *pRead, uint32_t len);
  33. #endif