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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #if ENABLED(USE_ESP32_EXIO)
  37. // Read a pin wrapper
  38. #define READ(IO) digitalRead(IO)
  39. // Write to a pin wrapper
  40. #define WRITE(IO, v) (IO >= 100 ? Write_EXIO(IO, v) : digitalWrite(IO, v))
  41. #else
  42. // Read a pin wrapper
  43. #define READ(IO) (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
  44. // Write to a pin wrapper
  45. #define WRITE(IO, v) (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
  46. #endif
  47. // Set pin as input wrapper (0x80 | (v << 5) | (IO - 100))
  48. #define SET_INPUT(IO) _SET_INPUT(IO)
  49. // Set pin as input with pullup wrapper
  50. #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
  51. // Set pin as input with pulldown (substitution)
  52. #define SET_INPUT_PULLDOWN SET_INPUT
  53. // Set pin as output wrapper
  54. #define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); }while(0)
  55. // Set pin as PWM
  56. #define SET_PWM SET_OUTPUT
  57. // Set pin as output and init
  58. #define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
  59. // digitalRead/Write wrappers
  60. #define extDigitalRead(IO) digitalRead(IO)
  61. #define extDigitalWrite(IO,V) digitalWrite(IO,V)
  62. // PWM outputs
  63. #define PWM_PIN(P) (P < 34 || P > 127) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
  64. // Toggle pin value
  65. #define TOGGLE(IO) WRITE(IO, !READ(IO))
  66. //
  67. // Ports and functions
  68. //
  69. // UART
  70. #define RXD 3
  71. #define TXD 1
  72. // TWI (I2C)
  73. #define SCL 5
  74. #define SDA 4