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 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Bit-Banged SPI routines
  3. */
  4. #ifndef _ARM_SPI_H
  5. #define _ARM_SPI_H
  6. #include <stdint.h>
  7. #define DIR_OUTPUT 0
  8. #define DIR_INPUT 1
  9. void gpioInit(void);
  10. void gpioDir(uint8_t num, uint8_t dir);
  11. void gpioSet(uint8_t num, uint8_t val);
  12. uint8_t gpioGet(uint8_t num);
  13. #define SCK_on gpioSet(22, 1)
  14. #define SCK_off gpioSet(22, 0)
  15. #define SCK_dir gpioDir(22, DIR_OUTPUT)
  16. #define MO_on gpioSet(21, 1)
  17. #define MO_off gpioSet(21, 0)
  18. #define MO_dir gpioDir(21, DIR_OUTPUT)
  19. #define CS_on gpioSet(24, 1)
  20. #define CS_off gpioSet(24, 0)
  21. #define CS_dir gpioDir(24, DIR_OUTPUT)
  22. #define MI_1 gpioGet(23)
  23. #define MI_0 gpioGet(23)
  24. #define MI_dir gpioDir(23, DIR_INPUT)
  25. #define GDO_1 gpioGet(25)
  26. #define GDO_0 gpioGet(25)
  27. #define GDO_dir gpioDir(25, DIR_INPUT)
  28. #define NOP() __asm__ __volatile__("nop\n\t" \
  29. "nop\n\t" \
  30. "nop\n\t" \
  31. "nop\n\t" \
  32. "nop\n\t" \
  33. "nop\n\t")
  34. #endif