Advertisement
phillip_bourdon234

SPI_Driver.h

Feb 28th, 2021
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. #include "stm32f10x.h"
  2.  
  3. /*
  4. Pin setup for SPI mode 1
  5.  
  6. PA4 --> SS
  7. PA5 --> SCLK
  8. PA6 --> MISO
  9. PA7 --> MOSI
  10. */
  11.  
  12. //=====================================================================================================
  13. //                                                                      FUNCTION PROTOTYPES
  14. //=====================================================================================================
  15.  
  16. //*****************************************************************************************************
  17. void spi_init_master(void);
  18.                                                                    
  19. //      The spi_init_master function enables SPI1 to the lowest speed setting (prescaler of 256),
  20. //      enables master mode, enables full duplex, and enables software slave managment. To change
  21. //      any of these settings, write the specific bytes into the SPI1->CR1 register.
  22. //*****************************************************************************************************
  23.  
  24.  
  25.  
  26. //*****************************************************************************************************
  27. void spi_write(char data);
  28.  
  29. //      The spi_write function sends 1 byte of data over the SPI line
  30. //*****************************************************************************************************
  31.  
  32.  
  33.  
  34. //*****************************************************************************************************
  35. uint8_t spi_read(void);
  36.  
  37. //      Because SPI is bidirectional, The spi_read function just returns whatever is in the SPI's
  38. //      data register.
  39. //*****************************************************************************************************
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement