spi.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file spi.h
  5. * @brief This file contains all the function prototypes for
  6. * the spi.c file
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2024 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __SPI_H__
  22. #define __SPI_H__
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "main.h"
  28. /* USER CODE BEGIN Includes */
  29. /* USER CODE END Includes */
  30. extern SPI_HandleTypeDef hspi1;
  31. /* USER CODE BEGIN Private defines */
  32. /* SPI总线速度设置 */
  33. #define SPI_SPEED_2 0
  34. #define SPI_SPEED_4 1
  35. #define SPI_SPEED_8 2
  36. #define SPI_SPEED_16 3
  37. #define SPI_SPEED_32 4
  38. #define SPI_SPEED_64 5
  39. #define SPI_SPEED_128 6
  40. #define SPI_SPEED_256 7
  41. /* USER CODE END Private defines */
  42. void MX_SPI1_Init(void);
  43. /* USER CODE BEGIN Prototypes */
  44. // @brief SPI速度设置函数
  45. void spi_set_speed(uint8_t speed);
  46. // @brief SPI读写一个字节的数据
  47. uint8_t spi_read_write_byte(uint8_t txdata);
  48. /* USER CODE END Prototypes */
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* __SPI_H__ */