Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spi.c 397B

123456789101112131415161718
  1. #include <avr/io.h>
  2. void SPI_Start_Transmission(volatile uint8_t *port, uint8_t pinNumber)
  3. {
  4. *port &= ~(1<<pinNumber);
  5. }
  6. uint8_t SPI_Transfer_Byte(uint8_t byteToSend)
  7. {
  8. SPDR = byteToSend;
  9. while(!(SPSR & (1<<SPIF))); // Wait for transmission complete
  10. return SPDR;
  11. }
  12. void SPI_Stop_Transmission(volatile uint8_t *port, uint8_t pinNumber)
  13. {
  14. *port |= (1<<pinNumber); // Stop the transmission
  15. }