summaryrefslogtreecommitdiff
path: root/spi.h
diff options
context:
space:
mode:
Diffstat (limited to 'spi.h')
-rw-r--r--spi.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/spi.h b/spi.h
new file mode 100644
index 0000000..51351a5
--- /dev/null
+++ b/spi.h
@@ -0,0 +1,27 @@
+#ifndef _SPI_H_
+#define _SPI_H_
+
+#include <stdint.h>
+#include <avr/io.h>
+
+#define PORT_SPI PORTB
+#define DDR_SPI DDRB
+#define DD_MISO DDB4
+#define DD_MOSI DDB3
+#define DD_SS DDB2
+#define DD_SCK DDB5
+
+inline void spi_cs_low()
+{
+ PORT_SPI &= ~(_BV(DD_SS));
+}
+
+inline void spi_cs_high()
+{
+ PORT_SPI |= _BV(DD_SS);
+}
+
+extern void spi_init();
+extern uint8_t spi_two_byte(uint8_t cmd, uint8_t data);
+
+#endif /* _SPI_H_ */