Naze32 clone with Frysky receiver
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.

spi.h 549B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Bit-Banged SPI routines
  3. */
  4. #ifndef _SPI_H
  5. #define _SPI_H
  6. #include <stdint.h>
  7. #include <avr/io.h>
  8. #define SCK_on PORTB |= PB4
  9. #define SCK_off PORTB &= ~(PB4)
  10. #define MO_on PORTB |= PB3
  11. #define MO_off PORTB &= ~(PB3)
  12. #define CS_on PORTB |= PB1
  13. #define CS_off PORTB &= ~(PB1)
  14. #define MI_1 (PINB & PB2) == PB2
  15. #define MI_0 (PINB & PB2) != PB2
  16. #define GDO_1 (PINB & PB0) == PB0
  17. #define GDO_0 (PINB & PB0) != PB0
  18. #define NOP() __asm__ __volatile__("nop")
  19. void spiInit(void);
  20. void spiWrite(uint8_t command);
  21. uint8_t spiRead(void);
  22. #endif