uni_avr_rpi.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // unification for AVR and RPI
  2. #ifndef __AVR
  3. # define __AVR
  4. #endif
  5. #ifdef __AVR
  6. //#include "Arduino.h"
  7. #include "Marlin.h"
  8. #define GPIO_INP(gpio) pinMode(gpio, INPUT)
  9. #define GPIO_OUT(gpio) pinMode(gpio, OUTPUT)
  10. #define GPIO_SET(gpio) digitalWrite(gpio, HIGH)
  11. #define GPIO_CLR(gpio) digitalWrite(gpio, LOW)
  12. #define GPIO_GET(gpio) (digitalRead(gpio) != LOW)
  13. #define DELAY(delay) delayMicroseconds(delay)
  14. #define PRINT MYSERIAL.print
  15. #endif //RC522_AVR
  16. #ifdef __RPI
  17. #include <bcm2835.h>
  18. #define GPIO_INP(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_INPT)
  19. #define GPIO_OUT(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_OUTP)
  20. #define GPIO_SET(gpio) bcm2835_gpio_write(gpio, HIGH)
  21. #define GPIO_CLR(gpio) bcm2835_gpio_write(gpio, LOW)
  22. #define GPIO_GET(gpio) (bcm2835_gpio_lev(gpio) != LOW)
  23. #include <unistd.h>
  24. #define DELAY(delay) usleep(delay)
  25. #define PRINT(p) print(p)
  26. #define DEC 10
  27. #define HEX 16
  28. void print(const char* pc) { printf("%s", pc); }
  29. void print(int v) { printf("%d", v); }
  30. void print(float v) { printf("%f", v); }
  31. #endif //RC522_RPI