safwan092

Untitled

Nov 4th, 2022
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1.  
  2.  
  3. // .\Documents\Arduino\libraries\grbl\cpu_map\cpu_map_atmega328p.h
  4.  
  5.  
  6. /*
  7. cpu_map_atmega328p.h - CPU and pin mapping configuration file
  8. Part of Grbl
  9.  
  10. Copyright (c) 2012-2015 Sungeun K. Jeon
  11.  
  12. Grbl is free software: you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation, either version 3 of the License, or
  15. (at your option) any later version.
  16.  
  17. Grbl is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with Grbl. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25.  
  26. /* Grbl officially supports the Arduino Uno, but the other supplied pin mappings are
  27. supplied by users, so your results may vary. This cpu_map file serves as a central
  28. pin mapping settings file for AVR 328p used on the Arduino Uno. */
  29.  
  30. #ifdef GRBL_PLATFORM
  31. #error "cpu_map already defined: GRBL_PLATFORM=" GRBL_PLATFORM
  32. #endif
  33.  
  34.  
  35. #define GRBL_PLATFORM "Atmega328p"
  36.  
  37. // Define serial port pins and interrupt vectors.
  38. #define SERIAL_RX USART_RX_vect
  39. #define SERIAL_UDRE USART_UDRE_vect
  40.  
  41. // Define step pulse output pins. NOTE: All step bit pins must be on the same port.
  42. #define STEP_DDR DDRD
  43. #define STEP_PORT PORTD
  44. #define X_STEP_BIT 2 // Uno Digital Pin 2
  45. #define Y_STEP_BIT 3 // Uno Digital Pin 3
  46. #define Z_STEP_BIT 4 // Uno Digital Pin 4
  47. #define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
  48.  
  49. // Define step direction output pins. NOTE: All direction pins must be on the same port.
  50. #define DIRECTION_DDR DDRD
  51. #define DIRECTION_PORT PORTD
  52. #define X_DIRECTION_BIT 5 // Uno Digital Pin 5
  53. #define Y_DIRECTION_BIT 6 // Uno Digital Pin 6
  54. #define Z_DIRECTION_BIT 7 // Uno Digital Pin 7
  55. #define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
  56.  
  57. // Define stepper driver enable/disable output pin.
  58. #define STEPPERS_DISABLE_DDR DDRB
  59. #define STEPPERS_DISABLE_PORT PORTB
  60. #define STEPPERS_DISABLE_BIT 0 // Uno Digital Pin 8
  61. #define STEPPERS_DISABLE_MASK (1<<STEPPERS_DISABLE_BIT)
  62.  
  63. // Define homing/hard limit switch input pins and limit interrupt vectors.
  64. // NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
  65. #define LIMIT_DDR DDRB
  66. #define LIMIT_PIN PINB
  67. #define LIMIT_PORT PORTB
  68. #define X_LIMIT_BIT 1 // Uno Digital Pin 9
  69. #define Y_LIMIT_BIT 2 // Uno Digital Pin 10
  70. #ifdef VARIABLE_SPINDLE // Z Limit pin and spindle enabled swapped to access hardware PWM on Pin 11.
  71. #define Z_LIMIT_BIT 4 // Uno Digital Pin 12
  72. #else
  73. #define Z_LIMIT_BIT 3 // Uno Digital Pin 11
  74. #endif
  75. #define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)) // All limit bits
  76. #define LIMIT_INT PCIE0 // Pin change interrupt enable pin
  77. #define LIMIT_INT_vect PCINT0_vect
  78. #define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
  79.  
  80. // Define spindle enable and spindle direction output pins.
  81. #define SPINDLE_ENABLE_DDR DDRB
  82. #define SPINDLE_ENABLE_PORT PORTB
  83. // Z Limit pin and spindle PWM/enable pin swapped to access hardware PWM on Pin 11.
  84. #ifdef VARIABLE_SPINDLE
  85. #ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
  86. // If enabled, spindle direction pin now used as spindle enable, while PWM remains on D11.
  87. #define SPINDLE_ENABLE_BIT 5 // Uno Digital Pin 13 (NOTE: D13 can't be pulled-high input due to LED.)
  88. #else
  89. #define SPINDLE_ENABLE_BIT 3 // Uno Digital Pin 11
  90. #endif
  91. #else
  92. #define SPINDLE_ENABLE_BIT 4 // Uno Digital Pin 12
  93. #endif
  94. #ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN
  95. #define SPINDLE_DIRECTION_DDR DDRB
  96. #define SPINDLE_DIRECTION_PORT PORTB
  97. #define SPINDLE_DIRECTION_BIT 5 // Uno Digital Pin 13 (NOTE: D13 can't be pulled-high input due to LED.)
  98. #endif
  99.  
  100. // Define flood and mist coolant enable output pins.
  101. // NOTE: Uno analog pins 4 and 5 are reserved for an i2c interface, and may be installed at
  102. // a later date if flash and memory space allows.
  103. #define COOLANT_FLOOD_DDR DDRC
  104. #define COOLANT_FLOOD_PORT PORTC
  105. #define COOLANT_FLOOD_BIT 3 // Uno Analog Pin 3
  106. #ifdef ENABLE_M7 // Mist coolant disabled by default. See config.h to enable/disable.
  107. #define COOLANT_MIST_DDR DDRC
  108. #define COOLANT_MIST_PORT PORTC
  109. #define COOLANT_MIST_BIT 4 // Uno Analog Pin 4
  110. #endif
  111.  
  112. // Define user-control controls (cycle start, reset, feed hold) input pins.
  113. // NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
  114. #define CONTROL_DDR DDRC
  115. #define CONTROL_PIN PINC
  116. #define CONTROL_PORT PORTC
  117. #define RESET_BIT 0 // Uno Analog Pin 0
  118. #define FEED_HOLD_BIT 1 // Uno Analog Pin 1
  119. #define CYCLE_START_BIT 2 // Uno Analog Pin 2
  120. #define SAFETY_DOOR_BIT 1 // Uno Analog Pin 1 NOTE: Safety door is shared with feed hold. Enabled by config define.
  121. #define CONTROL_INT PCIE1 // Pin change interrupt enable pin
  122. #define CONTROL_INT_vect PCINT1_vect
  123. #define CONTROL_PCMSK PCMSK1 // Pin change interrupt register
  124. #define CONTROL_MASK ((1<<RESET_BIT)|(1<<FEED_HOLD_BIT)|(1<<CYCLE_START_BIT)|(1<<SAFETY_DOOR_BIT))
  125. #define CONTROL_INVERT_MASK CONTROL_MASK // May be re-defined to only invert certain control pins.
  126.  
  127. // Define probe switch input pin.
  128. #define PROBE_DDR DDRC
  129. #define PROBE_PIN PINC
  130. #define PROBE_PORT PORTC
  131. #define PROBE_BIT 5 // Uno Analog Pin 5
  132. #define PROBE_MASK (1<<PROBE_BIT)
  133.  
  134. // Start of PWM & Stepper Enabled Spindle
  135. #ifdef VARIABLE_SPINDLE
  136. // Advanced Configuration Below You should not need to touch these variables
  137. #define PWM_MAX_VALUE 255.0
  138. #define TCCRA_REGISTER TCCR2A
  139. #define TCCRB_REGISTER TCCR2B
  140. #define OCR_REGISTER OCR2A
  141.  
  142. #define COMB_BIT COM2A1
  143. #define WAVE0_REGISTER WGM20
  144. #define WAVE1_REGISTER WGM21
  145. #define WAVE2_REGISTER WGM22
  146. #define WAVE3_REGISTER WGM23
  147.  
  148. // NOTE: On the 328p, these must be the same as the SPINDLE_ENABLE settings.
  149. #define SPINDLE_PWM_DDR DDRB
  150. #define SPINDLE_PWM_PORT PORTB
  151. #define SPINDLE_PWM_BIT 3 // Uno Digital Pin 11
  152. #endif // End of VARIABLE_SPINDLE
  153.  
Advertisement
Add Comment
Please, Sign In to add comment