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.
cooler-controller/Board/lib/utils/spi.h

20 lines
409 B
C++

//
// Created by kirillius on 25.09.2021.
//
#ifndef AVR_IOHELP_SPI_H
#define AVR_IOHELP_SPI_H
#include <avr/io.h>
#define SPI(MOSI, MISO, SCK) do{DDRB = ((DDRB&~(1<<MISO))|(1<<MOSI)|(1<<SCK)); (SPCR |= (1<<SPE)|(1<<MSTR)); SPSR |= (1<<SPI2X);}while(0)
namespace SPI{
uint8_t transfer(uint8_t byte);
void send(uint8_t byte);
uint8_t receive();
uint8_t data();
}
#endif //AVR_IOHELP_SPI_H