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.

31 lines
484 B

#ifndef SOFTWARE_SPI_H_
#define SOFTWARE_SPI_H_
#include <inttypes.h>
#include <util/delay.h>
#include <avr/io.h>
#define delay 2
//PC0 = clock
//PC1 = MOSI (output)
//PC2 = MISO (input)
//PC3-5 empty
#define CLK_invert PORTC ^= (1<<PORTC0)
#define MOSI_Hi PORTC |= (1<<PORTC1)
#define MOSI_Lo PORTC &= ~(1<<PORTC1)
void sSPI_init();
void sSPI_select(uint8_t ch);
void sSPI_free();
void sSPI_write_byte(uint8_t byte);
uint8_t sSPI_read_byte();
#endif /* SOFTWARE_SPI_H_ */