My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

fastio.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #include "i2s.h"
  24. /**
  25. * Utility functions
  26. */
  27. // I2S expander pin mapping.
  28. #define IS_I2S_EXPANDER_PIN(IO) TEST(IO, 7)
  29. #define I2S_EXPANDER_PIN_INDEX(IO) (IO & 0x7F)
  30. // Set pin as input
  31. #define _SET_INPUT(IO) pinMode(IO, INPUT)
  32. // Set pin as output
  33. #define _SET_OUTPUT(IO) pinMode(IO, OUTPUT)
  34. // Set pin as input with pullup mode
  35. #define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
  36. // Read a pin wrapper
  37. #define READ(IO) (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
  38. // Write to a pin wrapper
  39. #define WRITE(IO, v) (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
  40. // Set pin as input wrapper
  41. #define SET_INPUT(IO) _SET_INPUT(IO)
  42. // Set pin as input with pullup wrapper
  43. #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
  44. // Set pin as output wrapper
  45. #define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); }while(0)
  46. // Set pin as PWM
  47. #define SET_PWM SET_OUTPUT
  48. // Set pin as output and init
  49. #define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
  50. // digitalRead/Write wrappers
  51. #define extDigitalRead(IO) digitalRead(IO)
  52. #define extDigitalWrite(IO,V) digitalWrite(IO,V)
  53. // PWM outputs
  54. #define PWM_PIN(P) (P < 34 || P > 127) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
  55. // Toggle pin value
  56. #define TOGGLE(IO) WRITE(IO, !READ(IO))
  57. //
  58. // Ports and functions
  59. //
  60. // UART
  61. #define RXD 3
  62. #define TXD 1
  63. // TWI (I2C)
  64. #define SCL 5
  65. #define SDA 4