My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

fastio.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * Fast I/O Routines for LPC1768/9
  25. * Use direct port manipulation to save scads of processor time.
  26. * Contributed by Triffid_Hunter and modified by Kliment, thinkyhead, Bob-the-Kuhn, et.al.
  27. */
  28. /**
  29. * Description: Fast IO functions LPC1768
  30. *
  31. * For TARGET LPC1768
  32. */
  33. #include <Arduino.h>
  34. #define PWM_PIN(P) true // all pins are PWM capable
  35. #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
  36. #define LPC_PIN(pin) gpio_pin(pin)
  37. #define LPC_GPIO(port) gpio_port(port)
  38. #define SET_DIR_INPUT(IO) gpio_set_input(IO)
  39. #define SET_DIR_OUTPUT(IO) gpio_set_output(IO)
  40. #define SET_MODE(IO, mode) pinMode(IO, mode)
  41. #define WRITE_PIN_SET(IO) gpio_set(IO)
  42. #define WRITE_PIN_CLR(IO) gpio_clear(IO)
  43. #define READ_PIN(IO) gpio_get(IO)
  44. #define WRITE_PIN(IO,V) gpio_set(IO, V)
  45. /**
  46. * Magic I/O routines
  47. *
  48. * Now you can simply SET_OUTPUT(STEP); WRITE(STEP, HIGH); WRITE(STEP, LOW);
  49. *
  50. * Why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
  51. */
  52. /// Read a pin
  53. #define _READ(IO) READ_PIN(IO)
  54. /// Write to a pin
  55. #define _WRITE_VAR(IO,V) digitalWrite(IO,V)
  56. #define _WRITE(IO,V) WRITE_PIN(IO,V)
  57. /// toggle a pin
  58. #define _TOGGLE(IO) _WRITE(IO, !READ(IO))
  59. /// set pin as input
  60. #define _SET_INPUT(IO) SET_DIR_INPUT(IO)
  61. /// set pin as output
  62. #define _SET_OUTPUT(IO) SET_DIR_OUTPUT(IO)
  63. /// set pin as input with pullup mode
  64. #define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
  65. /// set pin as input with pulldown mode
  66. #define _PULLDOWN(IO,V) pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
  67. /// check if pin is an input
  68. #define _GET_INPUT(IO) (!gpio_get_dir(IO))
  69. /// check if pin is an output
  70. #define _GET_OUTPUT(IO) (gpio_get_dir(IO))
  71. /// check if pin is a timer
  72. /// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
  73. #define _GET_TIMER(IO) true
  74. /// Read a pin wrapper
  75. #define READ(IO) _READ(IO)
  76. /// Write to a pin wrapper
  77. #define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
  78. #define WRITE(IO,V) _WRITE(IO,V)
  79. /// toggle a pin wrapper
  80. #define TOGGLE(IO) _TOGGLE(IO)
  81. /// set pin as input wrapper
  82. #define SET_INPUT(IO) _SET_INPUT(IO)
  83. /// set pin as input with pullup wrapper
  84. #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
  85. /// set pin as input with pulldown wrapper
  86. #define SET_INPUT_PULLDOWN(IO) do{ _SET_INPUT(IO); _PULLDOWN(IO, HIGH); }while(0)
  87. /// set pin as output wrapper - reads the pin and sets the output to that value
  88. #define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
  89. /// check if pin is an input wrapper
  90. #define GET_INPUT(IO) _GET_INPUT(IO)
  91. /// check if pin is an output wrapper
  92. #define GET_OUTPUT(IO) _GET_OUTPUT(IO)
  93. /// check if pin is a timer (wrapper)
  94. #define GET_TIMER(IO) _GET_TIMER(IO)
  95. // Shorthand
  96. #define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
  97. // digitalRead/Write wrappers
  98. #define extDigitalRead(IO) digitalRead(IO)
  99. #define extDigitalWrite(IO,V) digitalWrite(IO,V)