1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /*
- * Bit-Banged SPI routines
- */
-
- #ifndef _SPI_H
- #define _SPI_H
-
- #include <stdint.h>
- #include <avr/io.h>
-
- #ifdef DEBUG
-
- // Arduino D2
- #define SCK_on PORTD |= PD2
- #define SCK_off PORTD &= ~(PD2)
-
- // Arduino D4
- #define MO_on PORTD |= PD4
- #define MO_off PORTD &= ~(PD4)
-
- // Arduino D7
- #define CS_on PORTD |= PD7
- #define CS_off PORTD &= ~(PD7)
-
- // Arduino D8
- #define MI_1 (PINB & PB0) == PB0
- #define MI_0 (PINB & PB0) != PB0
-
- // Arduino D12
- #define GDO_1 (PINB & PB4) == PB4
- #define GDO_0 (PINB & PB4) != PB4
-
- #else
-
- #define SCK_on PORTB |= PB4
- #define SCK_off PORTB &= ~(PB4)
-
- #define MO_on PORTB |= PB3
- #define MO_off PORTB &= ~(PB3)
-
- #define CS_on PORTB |= PB1
- #define CS_off PORTB &= ~(PB1)
-
- #define MI_1 (PINB & PB2) == PB2
- #define MI_0 (PINB & PB2) != PB2
-
- #define GDO_1 (PINB & PB0) == PB0
- #define GDO_0 (PINB & PB0) != PB0
-
- #endif
-
- #define NOP() __asm__ __volatile__("nop")
-
- void spiInit(void);
- void spiWrite(uint8_t command);
- uint8_t spiRead(void);
-
- #endif
|