This repository has been archived on 2025-01-09. You can view files and clone it, but cannot push or open issues or pull requests.
pig-feeder/lib/utils/spi.cpp

23 lines
418 B
C++

//
// Created by kirillius on 25.09.2021.
//
#include "spi.h"
uint8_t SPI::transfer(uint8_t byte){
SPDR = byte;
while(!(SPSR & (1<<SPIF))); //ожидание готовности SPI
return SPDR; //возврат того, что пришло
}
void SPI::send(uint8_t byte){
SPI::transfer(byte);
}
uint8_t SPI::receive(){
return SPI::transfer(0xFF);
}
uint8_t SPI::data() {
return SPDR;
}