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.

pinsDebug.h 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. bool endstop_monitor_flag = false;
  23. #if !defined(TIMER1B) // working with Teensyduino extension so need to re-define some things
  24. #include "pinsDebug_Teensyduino.h"
  25. #endif
  26. #define NAME_FORMAT "%-28s" // one place to specify the format of all the sources of names
  27. // "-" left justify, "28" minimum width of name, pad with blanks
  28. #define _PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); return true; }
  29. #define PIN_SAY(NAME) if (pin == NAME) _PIN_SAY(#NAME);
  30. #define _ANALOG_PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); pin_is_analog = true; return true; }
  31. #define ANALOG_PIN_SAY(NAME) if (pin == analogInputToDigitalPin(NAME)) _ANALOG_PIN_SAY(#NAME);
  32. #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(5)))
  33. int digitalRead_mod(int8_t pin) { // same as digitalRead except the PWM stop section has been removed
  34. uint8_t port = digitalPinToPort(pin);
  35. return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask(pin)) ? HIGH : LOW;
  36. }
  37. /**
  38. * Report pin name for a given fastio digital pin index
  39. */
  40. static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
  41. char buffer[30]; // for the sprintf statements
  42. pin_is_analog = false; // default to digital pin
  43. if (IS_ANALOG(pin)) {
  44. sprintf(buffer, "(A%2d) ", int(pin - analogInputToDigitalPin(0)));
  45. SERIAL_ECHO(buffer);
  46. }
  47. else SERIAL_ECHOPGM(" ");
  48. #if defined(RXD) && RXD >= 0
  49. if (pin == 0) { sprintf(buffer, NAME_FORMAT, "RXD"); SERIAL_ECHO(buffer); return true; }
  50. #endif
  51. #if defined(TXD) && TXD >= 0
  52. if (pin == 1) { sprintf(buffer, NAME_FORMAT, "TXD"); SERIAL_ECHO(buffer); return true; }
  53. #endif
  54. // Pin list updated from 7 OCT RCBugfix branch - max length of pin name is 24
  55. #if defined(__FD) && __FD >= 0
  56. PIN_SAY(__FD)
  57. #endif
  58. #if defined(__FS) && __FS >= 0
  59. PIN_SAY(__FS)
  60. #endif
  61. #if defined(__GD) && __GD >= 0
  62. PIN_SAY(__GD)
  63. #endif
  64. #if defined(__GS) && __GS >= 0
  65. PIN_SAY(__GS)
  66. #endif
  67. #if PIN_EXISTS(AVR_MISO)
  68. PIN_SAY(AVR_MISO_PIN);
  69. #endif
  70. #if PIN_EXISTS(AVR_MOSI)
  71. PIN_SAY(AVR_MOSI_PIN);
  72. #endif
  73. #if PIN_EXISTS(AVR_SCK)
  74. PIN_SAY(AVR_SCK_PIN);
  75. #endif
  76. #if PIN_EXISTS(AVR_SS)
  77. PIN_SAY(AVR_SS_PIN);
  78. #endif
  79. #if PIN_EXISTS(BEEPER)
  80. PIN_SAY(BEEPER_PIN);
  81. #endif
  82. #if defined(BTN_CENTER) && BTN_CENTER >= 0
  83. PIN_SAY(BTN_CENTER);
  84. #endif
  85. #if defined(BTN_DOWN) && BTN_DOWN >= 0
  86. PIN_SAY(BTN_DOWN);
  87. #endif
  88. #if defined(BTN_DWN) && BTN_DWN >= 0
  89. PIN_SAY(BTN_DWN);
  90. #endif
  91. #if defined(BTN_EN1) && BTN_EN1 >= 0
  92. PIN_SAY(BTN_EN1);
  93. #endif
  94. #if defined(BTN_EN2) && BTN_EN2 >= 0
  95. PIN_SAY(BTN_EN2);
  96. #endif
  97. #if defined(BTN_ENC) && BTN_ENC >= 0
  98. PIN_SAY(BTN_ENC);
  99. #endif
  100. #if defined(BTN_HOME) && BTN_HOME >= 0
  101. PIN_SAY(BTN_HOME);
  102. #endif
  103. #if defined(BTN_LEFT) && BTN_LEFT >= 0
  104. PIN_SAY(BTN_LEFT);
  105. #endif
  106. #if defined(BTN_LFT) && BTN_LFT >= 0
  107. PIN_SAY(BTN_LFT);
  108. #endif
  109. #if defined(BTN_RIGHT) && BTN_RIGHT >= 0
  110. PIN_SAY(BTN_RIGHT);
  111. #endif
  112. #if defined(BTN_RT) && BTN_RT >= 0
  113. PIN_SAY(BTN_RT);
  114. #endif
  115. #if defined(BTN_UP) && BTN_UP >= 0
  116. PIN_SAY(BTN_UP);
  117. #endif
  118. #if PIN_EXISTS(CONTROLLERFAN)
  119. PIN_SAY(CONTROLLERFAN_PIN);
  120. #endif
  121. #if PIN_EXISTS(DAC_DISABLE)
  122. PIN_SAY(DAC_DISABLE_PIN);
  123. #endif
  124. #if defined(DAC_STEPPER_GAIN) && DAC_STEPPER_GAIN >= 0
  125. PIN_SAY(DAC_STEPPER_GAIN);
  126. #endif
  127. #if defined(DAC_STEPPER_VREF) && DAC_STEPPER_VREF >= 0
  128. PIN_SAY(DAC_STEPPER_VREF);
  129. #endif
  130. #if PIN_EXISTS(DEBUG)
  131. PIN_SAY(DEBUG_PIN);
  132. #endif
  133. #if PIN_EXISTS(DIGIPOTSS)
  134. PIN_SAY(DIGIPOTSS_PIN);
  135. #endif
  136. #if defined(DOGLCD_A0) && DOGLCD_A0 >= 0
  137. PIN_SAY(DOGLCD_A0);
  138. #endif
  139. #if defined(DOGLCD_CS) && DOGLCD_CS >= 0
  140. PIN_SAY(DOGLCD_CS);
  141. #endif
  142. #if defined(DOGLCD_MOSI) && DOGLCD_MOSI >= 0
  143. PIN_SAY(DOGLCD_MOSI);
  144. #endif
  145. #if defined(DOGLCD_SCK) && DOGLCD_SCK >= 0
  146. PIN_SAY(DOGLCD_SCK);
  147. #endif
  148. #if PIN_EXISTS(E0_ATT)
  149. PIN_SAY(E0_ATT_PIN);
  150. #endif
  151. #if PIN_EXISTS(E0_AUTO_FAN)
  152. PIN_SAY(E0_AUTO_FAN_PIN);
  153. #endif
  154. #if PIN_EXISTS(E1_AUTO_FAN)
  155. PIN_SAY(E1_AUTO_FAN_PIN);
  156. #endif
  157. #if PIN_EXISTS(E2_AUTO_FAN)
  158. PIN_SAY(E2_AUTO_FAN_PIN);
  159. #endif
  160. #if PIN_EXISTS(E3_AUTO_FAN)
  161. PIN_SAY(E3_AUTO_FAN_PIN);
  162. #endif
  163. #if PIN_EXISTS(E0_DIR)
  164. PIN_SAY(E0_DIR_PIN);
  165. #endif
  166. #if PIN_EXISTS(E0_ENABLE)
  167. PIN_SAY(E0_ENABLE_PIN);
  168. #endif
  169. #if PIN_EXISTS(E0_MS1)
  170. PIN_SAY(E0_MS1_PIN);
  171. #endif
  172. #if PIN_EXISTS(E0_MS2)
  173. PIN_SAY(E0_MS2_PIN);
  174. #endif
  175. #if PIN_EXISTS(E0_STEP)
  176. PIN_SAY(E0_STEP_PIN);
  177. #endif
  178. #if PIN_EXISTS(E1_DIR)
  179. PIN_SAY(E1_DIR_PIN);
  180. #endif
  181. #if PIN_EXISTS(E1_ENABLE)
  182. PIN_SAY(E1_ENABLE_PIN);
  183. #endif
  184. #if PIN_EXISTS(E1_MS1)
  185. PIN_SAY(E1_MS1_PIN);
  186. #endif
  187. #if PIN_EXISTS(E1_MS2)
  188. PIN_SAY(E1_MS2_PIN);
  189. #endif
  190. #if PIN_EXISTS(E1_STEP)
  191. PIN_SAY(E1_STEP_PIN);
  192. #endif
  193. #if PIN_EXISTS(E2_DIR)
  194. PIN_SAY(E2_DIR_PIN);
  195. #endif
  196. #if PIN_EXISTS(E2_ENABLE)
  197. PIN_SAY(E2_ENABLE_PIN);
  198. #endif
  199. #if PIN_EXISTS(E2_STEP)
  200. PIN_SAY(E2_STEP_PIN);
  201. #endif
  202. #if PIN_EXISTS(E3_DIR)
  203. PIN_SAY(E3_DIR_PIN);
  204. #endif
  205. #if PIN_EXISTS(E3_ENABLE)
  206. PIN_SAY(E3_ENABLE_PIN);
  207. #endif
  208. #if PIN_EXISTS(E3_STEP)
  209. PIN_SAY(E3_STEP_PIN);
  210. #endif
  211. #if PIN_EXISTS(E4_DIR)
  212. PIN_SAY(E4_DIR_PIN);
  213. #endif
  214. #if PIN_EXISTS(E4_ENABLE)
  215. PIN_SAY(E4_ENABLE_PIN);
  216. #endif
  217. #if PIN_EXISTS(E4_STEP)
  218. PIN_SAY(E4_STEP_PIN);
  219. #endif
  220. #if defined(encrot1) && encrot1 >= 0
  221. PIN_SAY(encrot1);
  222. #endif
  223. #if defined(encrot2) && encrot2 >= 0
  224. PIN_SAY(encrot2);
  225. #endif
  226. #if defined(encrot3) && encrot3 >= 0
  227. PIN_SAY(encrot3);
  228. #endif
  229. #if defined(EXT_AUX_A0_IO) && EXT_AUX_A0_IO >= 0
  230. PIN_SAY(EXT_AUX_A0_IO);
  231. #endif
  232. #if defined(EXT_AUX_A1) && EXT_AUX_A1 >= 0
  233. PIN_SAY(EXT_AUX_A1);
  234. #endif
  235. #if defined(EXT_AUX_A1_IO) && EXT_AUX_A1_IO >= 0
  236. PIN_SAY(EXT_AUX_A1_IO);
  237. #endif
  238. #if defined(EXT_AUX_A2) && EXT_AUX_A2 >= 0
  239. PIN_SAY(EXT_AUX_A2);
  240. #endif
  241. #if defined(EXT_AUX_A2_IO) && EXT_AUX_A2_IO >= 0
  242. PIN_SAY(EXT_AUX_A2_IO);
  243. #endif
  244. #if defined(EXT_AUX_A3) && EXT_AUX_A3 >= 0
  245. PIN_SAY(EXT_AUX_A3);
  246. #endif
  247. #if defined(EXT_AUX_A3_IO) && EXT_AUX_A3_IO >= 0
  248. PIN_SAY(EXT_AUX_A3_IO);
  249. #endif
  250. #if defined(EXT_AUX_A4) && EXT_AUX_A4 >= 0
  251. PIN_SAY(EXT_AUX_A4);
  252. #endif
  253. #if defined(EXT_AUX_A4_IO) && EXT_AUX_A4_IO >= 0
  254. PIN_SAY(EXT_AUX_A4_IO);
  255. #endif
  256. #if defined(EXT_AUX_PWM_D24) && EXT_AUX_PWM_D24 >= 0
  257. PIN_SAY(EXT_AUX_PWM_D24);
  258. #endif
  259. #if defined(EXT_AUX_RX1_D2) && EXT_AUX_RX1_D2 >= 0
  260. PIN_SAY(EXT_AUX_RX1_D2);
  261. #endif
  262. #if defined(EXT_AUX_SDA_D1) && EXT_AUX_SDA_D1 >= 0
  263. PIN_SAY(EXT_AUX_SDA_D1);
  264. #endif
  265. #if defined(EXT_AUX_TX1_D3) && EXT_AUX_TX1_D3 >= 0
  266. PIN_SAY(EXT_AUX_TX1_D3);
  267. #endif
  268. #if PIN_EXISTS(FAN)
  269. PIN_SAY(FAN_PIN);
  270. #endif
  271. #if PIN_EXISTS(FAN1)
  272. PIN_SAY(FAN1_PIN);
  273. #endif
  274. #if PIN_EXISTS(FAN2)
  275. PIN_SAY(FAN2_PIN);
  276. #endif
  277. #if PIN_EXISTS(FIL_RUNOUT)
  278. PIN_SAY(FIL_RUNOUT_PIN);
  279. #endif
  280. #if PIN_EXISTS(FILWIDTH)
  281. ANALOG_PIN_SAY(FILWIDTH_PIN);
  282. #endif
  283. #if defined(GEN7_VERSION) && GEN7_VERSION >= 0
  284. PIN_SAY(GEN7_VERSION);
  285. #endif
  286. #if PIN_EXISTS(HEATER_0)
  287. PIN_SAY(HEATER_0_PIN);
  288. #endif
  289. #if PIN_EXISTS(HEATER_1)
  290. PIN_SAY(HEATER_1_PIN);
  291. #endif
  292. #if PIN_EXISTS(HEATER_2)
  293. PIN_SAY(HEATER_2_PIN);
  294. #endif
  295. #if PIN_EXISTS(HEATER_3)
  296. PIN_SAY(HEATER_3_PIN);
  297. #endif
  298. #if PIN_EXISTS(HEATER_4)
  299. PIN_SAY(HEATER_4_PIN);
  300. #endif
  301. #if PIN_EXISTS(HEATER_5)
  302. PIN_SAY(HEATER_5_PIN);
  303. #endif
  304. #if PIN_EXISTS(HEATER_6)
  305. PIN_SAY(HEATER_6_PIN);
  306. #endif
  307. #if PIN_EXISTS(HEATER_7)
  308. PIN_SAY(HEATER_7_PIN);
  309. #endif
  310. #if PIN_EXISTS(HEATER_BED)
  311. PIN_SAY(HEATER_BED_PIN);
  312. #endif
  313. #if defined(I2C_SCL) && I2C_SCL >= 0
  314. PIN_SAY(I2C_SCL);
  315. #endif
  316. #if defined(I2C_SDA) && I2C_SDA >= 0
  317. PIN_SAY(I2C_SDA);
  318. #endif
  319. #if PIN_EXISTS(KILL)
  320. PIN_SAY(KILL_PIN);
  321. #endif
  322. #if PIN_EXISTS(LCD_BACKLIGHT)
  323. PIN_SAY(LCD_BACKLIGHT_PIN);
  324. #endif
  325. #if defined(LCD_CONTRAST) && LCD_CONTRAST >= 0
  326. PIN_SAY(LCD_CONTRAST);
  327. #endif
  328. #if defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0
  329. PIN_SAY(LCD_PINS_D4);
  330. #endif
  331. #if defined(LCD_PINS_D5) && LCD_PINS_D5 >= 0
  332. PIN_SAY(LCD_PINS_D5);
  333. #endif
  334. #if defined(LCD_PINS_D6) && LCD_PINS_D6 >= 0
  335. PIN_SAY(LCD_PINS_D6);
  336. #endif
  337. #if defined(LCD_PINS_D7) && LCD_PINS_D7 >= 0
  338. PIN_SAY(LCD_PINS_D7);
  339. #endif
  340. #if defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0
  341. PIN_SAY(LCD_PINS_ENABLE);
  342. #endif
  343. #if defined(LCD_PINS_RS) && LCD_PINS_RS >= 0
  344. PIN_SAY(LCD_PINS_RS);
  345. #endif
  346. #if defined(LCD_SDSS) && LCD_SDSS >= 0
  347. PIN_SAY(LCD_SDSS);
  348. #endif
  349. #if PIN_EXISTS(LED)
  350. PIN_SAY(LED_PIN);
  351. #endif
  352. #if PIN_EXISTS(CASE_LIGHT)
  353. PIN_SAY(CASE_LIGHT_PIN);
  354. #endif
  355. #if PIN_EXISTS(MAIN_VOLTAGE_MEASURE)
  356. PIN_SAY(MAIN_VOLTAGE_MEASURE_PIN);
  357. #endif
  358. #if defined(MAX6675_SS) && MAX6675_SS >= 0
  359. PIN_SAY(MAX6675_SS);
  360. #endif
  361. #if PIN_EXISTS(MISO)
  362. PIN_SAY(MISO_PIN);
  363. #endif
  364. #if PIN_EXISTS(MOSFET_D)
  365. PIN_SAY(MOSFET_D_PIN);
  366. #endif
  367. #if PIN_EXISTS(MOSI)
  368. PIN_SAY(MOSI_PIN);
  369. #endif
  370. #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
  371. PIN_SAY(MOTOR_CURRENT_PWM_E_PIN);
  372. #endif
  373. #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
  374. PIN_SAY(MOTOR_CURRENT_PWM_XY_PIN);
  375. #endif
  376. #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
  377. PIN_SAY(MOTOR_CURRENT_PWM_Z_PIN);
  378. #endif
  379. #if defined(NUM_TLCS) && NUM_TLCS >= 0
  380. PIN_SAY(NUM_TLCS);
  381. #endif
  382. #if PIN_EXISTS(PHOTOGRAPH)
  383. PIN_SAY(PHOTOGRAPH_PIN);
  384. #endif
  385. #if PIN_EXISTS(PS_ON)
  386. PIN_SAY(PS_ON_PIN);
  387. #endif
  388. #if PIN_EXISTS(RAMPS_D10)
  389. PIN_SAY(RAMPS_D10_PIN);
  390. #endif
  391. #if PIN_EXISTS(RAMPS_D8)
  392. PIN_SAY(RAMPS_D8_PIN);
  393. #endif
  394. #if PIN_EXISTS(RAMPS_D9)
  395. PIN_SAY(RAMPS_D9_PIN);
  396. #endif
  397. #if PIN_EXISTS(RX_ENABLE)
  398. PIN_SAY(RX_ENABLE_PIN);
  399. #endif
  400. #if PIN_EXISTS(SAFETY_TRIGGERED)
  401. PIN_SAY(SAFETY_TRIGGERED_PIN);
  402. #endif
  403. #if PIN_EXISTS(SCK)
  404. PIN_SAY(SCK_PIN);
  405. #endif
  406. #if defined(SCL) && SCL >= 0
  407. PIN_SAY(SCL);
  408. #endif
  409. #if PIN_EXISTS(SD_DETECT)
  410. PIN_SAY(SD_DETECT_PIN);
  411. #endif
  412. #if defined(SDA) && SDA >= 0
  413. PIN_SAY(SDA);
  414. #endif
  415. #if defined(SDPOWER) && SDPOWER >= 0
  416. PIN_SAY(SDPOWER);
  417. #endif
  418. #if defined(SDSS) && SDSS >= 0
  419. PIN_SAY(SDSS);
  420. #endif
  421. #if PIN_EXISTS(SERVO0)
  422. PIN_SAY(SERVO0_PIN);
  423. #endif
  424. #if PIN_EXISTS(SERVO1)
  425. PIN_SAY(SERVO1_PIN);
  426. #endif
  427. #if PIN_EXISTS(SERVO2)
  428. PIN_SAY(SERVO2_PIN);
  429. #endif
  430. #if PIN_EXISTS(SERVO3)
  431. PIN_SAY(SERVO3_PIN);
  432. #endif
  433. #if defined(SHIFT_CLK) && SHIFT_CLK >= 0
  434. PIN_SAY(SHIFT_CLK);
  435. #endif
  436. #if defined(SHIFT_EN) && SHIFT_EN >= 0
  437. PIN_SAY(SHIFT_EN);
  438. #endif
  439. #if defined(SHIFT_LD) && SHIFT_LD >= 0
  440. PIN_SAY(SHIFT_LD);
  441. #endif
  442. #if defined(SHIFT_OUT) && SHIFT_OUT >= 0
  443. PIN_SAY(SHIFT_OUT);
  444. #endif
  445. #if PIN_EXISTS(SLED)
  446. PIN_SAY(SLED_PIN);
  447. #endif
  448. #if PIN_EXISTS(SLEEP_WAKE)
  449. PIN_SAY(SLEEP_WAKE_PIN);
  450. #endif
  451. #if PIN_EXISTS(SOL1)
  452. PIN_SAY(SOL1_PIN);
  453. #endif
  454. #if PIN_EXISTS(SOL2)
  455. PIN_SAY(SOL2_PIN);
  456. #endif
  457. #if PIN_EXISTS(SPINDLE_ENABLE)
  458. PIN_SAY(SPINDLE_ENABLE_PIN);
  459. #endif
  460. #if PIN_EXISTS(SPINDLE_SPEED)
  461. PIN_SAY(SPINDLE_SPEED_PIN);
  462. #endif
  463. #if PIN_EXISTS(SS)
  464. PIN_SAY(SS_PIN);
  465. #endif
  466. #if PIN_EXISTS(STAT_LED_BLUE)
  467. PIN_SAY(STAT_LED_BLUE_PIN);
  468. #endif
  469. #if PIN_EXISTS(STAT_LED_RED)
  470. PIN_SAY(STAT_LED_RED_PIN);
  471. #endif
  472. #if PIN_EXISTS(STEPPER_RESET)
  473. PIN_SAY(STEPPER_RESET_PIN);
  474. #endif
  475. #if PIN_EXISTS(SUICIDE)
  476. PIN_SAY(SUICIDE_PIN);
  477. #endif
  478. #if defined(TC1) && TC1 >= 0
  479. ANALOG_PIN_SAY(TC1);
  480. #endif
  481. #if defined(TC2) && TC2 >= 0
  482. ANALOG_PIN_SAY(TC2);
  483. #endif
  484. #if PIN_EXISTS(TEMP_0)
  485. ANALOG_PIN_SAY(TEMP_0_PIN);
  486. #endif
  487. #if PIN_EXISTS(TEMP_1)
  488. ANALOG_PIN_SAY(TEMP_1_PIN);
  489. #endif
  490. #if PIN_EXISTS(TEMP_2)
  491. ANALOG_PIN_SAY(TEMP_2_PIN);
  492. #endif
  493. #if PIN_EXISTS(TEMP_3)
  494. ANALOG_PIN_SAY(TEMP_3_PIN);
  495. #endif
  496. #if PIN_EXISTS(TEMP_4)
  497. ANALOG_PIN_SAY(TEMP_4_PIN);
  498. #endif
  499. #if PIN_EXISTS(TEMP_BED)
  500. ANALOG_PIN_SAY(TEMP_BED_PIN);
  501. #endif
  502. #if PIN_EXISTS(TEMP_X)
  503. ANALOG_PIN_SAY(TEMP_X_PIN);
  504. #endif
  505. #if defined(TLC_BLANK_BIT) && TLC_BLANK_BIT >= 0
  506. PIN_SAY(TLC_BLANK_BIT);
  507. #endif
  508. #if PIN_EXISTS(TLC_BLANK)
  509. PIN_SAY(TLC_BLANK_PIN);
  510. #endif
  511. #if defined(TLC_CLOCK_BIT) && TLC_CLOCK_BIT >= 0
  512. PIN_SAY(TLC_CLOCK_BIT);
  513. #endif
  514. #if PIN_EXISTS(TLC_CLOCK)
  515. PIN_SAY(TLC_CLOCK_PIN);
  516. #endif
  517. #if defined(TLC_DATA_BIT) && TLC_DATA_BIT >= 0
  518. PIN_SAY(TLC_DATA_BIT);
  519. #endif
  520. #if PIN_EXISTS(TLC_DATA)
  521. PIN_SAY(TLC_DATA_PIN);
  522. #endif
  523. #if PIN_EXISTS(TLC_XLAT)
  524. PIN_SAY(TLC_XLAT_PIN);
  525. #endif
  526. #if PIN_EXISTS(TX_ENABLE)
  527. PIN_SAY(TX_ENABLE_PIN);
  528. #endif
  529. #if defined(UNUSED_PWM) && UNUSED_PWM >= 0
  530. PIN_SAY(UNUSED_PWM);
  531. #endif
  532. #if PIN_EXISTS(X_ATT)
  533. PIN_SAY(X_ATT_PIN);
  534. #endif
  535. #if PIN_EXISTS(X_DIR)
  536. PIN_SAY(X_DIR_PIN);
  537. #endif
  538. #if PIN_EXISTS(X_ENABLE)
  539. PIN_SAY(X_ENABLE_PIN);
  540. #endif
  541. #if PIN_EXISTS(X_MAX)
  542. PIN_SAY(X_MAX_PIN);
  543. #endif
  544. #if PIN_EXISTS(X_MIN)
  545. PIN_SAY(X_MIN_PIN);
  546. #endif
  547. #if PIN_EXISTS(X_MS1)
  548. PIN_SAY(X_MS1_PIN);
  549. #endif
  550. #if PIN_EXISTS(X_MS2)
  551. PIN_SAY(X_MS2_PIN);
  552. #endif
  553. #if PIN_EXISTS(X_STEP)
  554. PIN_SAY(X_STEP_PIN);
  555. #endif
  556. #if PIN_EXISTS(X_STOP)
  557. PIN_SAY(X_STOP_PIN);
  558. #endif
  559. #if PIN_EXISTS(X2_DIR)
  560. PIN_SAY(X2_DIR_PIN);
  561. #endif
  562. #if PIN_EXISTS(X2_ENABLE)
  563. PIN_SAY(X2_ENABLE_PIN);
  564. #endif
  565. #if PIN_EXISTS(X2_STEP)
  566. PIN_SAY(X2_STEP_PIN);
  567. #endif
  568. #if PIN_EXISTS(Y_ATT)
  569. PIN_SAY(Y_ATT_PIN);
  570. #endif
  571. #if PIN_EXISTS(Y_DIR)
  572. PIN_SAY(Y_DIR_PIN);
  573. #endif
  574. #if PIN_EXISTS(Y_ENABLE)
  575. PIN_SAY(Y_ENABLE_PIN);
  576. #endif
  577. #if PIN_EXISTS(Y_MAX)
  578. PIN_SAY(Y_MAX_PIN);
  579. #endif
  580. #if PIN_EXISTS(Y_MIN)
  581. PIN_SAY(Y_MIN_PIN);
  582. #endif
  583. #if PIN_EXISTS(Y_MS1)
  584. PIN_SAY(Y_MS1_PIN);
  585. #endif
  586. #if PIN_EXISTS(Y_MS2)
  587. PIN_SAY(Y_MS2_PIN);
  588. #endif
  589. #if PIN_EXISTS(Y_STEP)
  590. PIN_SAY(Y_STEP_PIN);
  591. #endif
  592. #if PIN_EXISTS(Y_STOP)
  593. PIN_SAY(Y_STOP_PIN);
  594. #endif
  595. #if PIN_EXISTS(Y2_DIR)
  596. PIN_SAY(Y2_DIR_PIN);
  597. #endif
  598. #if PIN_EXISTS(Y2_ENABLE)
  599. PIN_SAY(Y2_ENABLE_PIN);
  600. #endif
  601. #if PIN_EXISTS(Y2_STEP)
  602. PIN_SAY(Y2_STEP_PIN);
  603. #endif
  604. #if PIN_EXISTS(Z_ATT)
  605. PIN_SAY(Z_ATT_PIN);
  606. #endif
  607. #if PIN_EXISTS(Z_DIR)
  608. PIN_SAY(Z_DIR_PIN);
  609. #endif
  610. #if PIN_EXISTS(Z_ENABLE)
  611. PIN_SAY(Z_ENABLE_PIN);
  612. #endif
  613. #if PIN_EXISTS(Z_MAX)
  614. PIN_SAY(Z_MAX_PIN);
  615. #endif
  616. #if PIN_EXISTS(Z_MIN)
  617. PIN_SAY(Z_MIN_PIN);
  618. #endif
  619. #if PIN_EXISTS(Z_MIN_PROBE)
  620. PIN_SAY(Z_MIN_PROBE_PIN);
  621. #endif
  622. #if PIN_EXISTS(Z_MS1)
  623. PIN_SAY(Z_MS1_PIN);
  624. #endif
  625. #if PIN_EXISTS(Z_MS2)
  626. PIN_SAY(Z_MS2_PIN);
  627. #endif
  628. #if PIN_EXISTS(Z_STEP)
  629. PIN_SAY(Z_STEP_PIN);
  630. #endif
  631. #if PIN_EXISTS(Z_STOP)
  632. PIN_SAY(Z_STOP_PIN);
  633. #endif
  634. #if PIN_EXISTS(Z2_DIR)
  635. PIN_SAY(Z2_DIR_PIN);
  636. #endif
  637. #if PIN_EXISTS(Z2_ENABLE)
  638. PIN_SAY(Z2_ENABLE_PIN);
  639. #endif
  640. #if PIN_EXISTS(Z2_STEP)
  641. PIN_SAY(Z2_STEP_PIN);
  642. #endif
  643. sprintf(buffer, NAME_FORMAT, "<unused> ");
  644. SERIAL_ECHO(buffer);
  645. return false;
  646. } // report_pin_name
  647. #define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
  648. #define PWM_CASE(N,Z) \
  649. case TIMER##N##Z: \
  650. if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
  651. PWM_PRINT(OCR##N##Z); \
  652. return true; \
  653. } else return false
  654. /**
  655. * Print a pin's PWM status.
  656. * Return true if it's currently a PWM pin.
  657. */
  658. static bool pwm_status(uint8_t pin) {
  659. char buffer[20]; // for the sprintf statements
  660. switch(digitalPinToTimer(pin)) {
  661. #if defined(TCCR0A) && defined(COM0A1)
  662. PWM_CASE(0,A);
  663. PWM_CASE(0,B);
  664. #endif
  665. #if defined(TCCR1A) && defined(COM1A1)
  666. PWM_CASE(1,A);
  667. PWM_CASE(1,B);
  668. #if defined(COM1C1) && defined(TIMER1C)
  669. PWM_CASE(1,C);
  670. #endif
  671. #endif
  672. #if defined(TCCR2A) && defined(COM2A1)
  673. PWM_CASE(2,A);
  674. PWM_CASE(2,B);
  675. #endif
  676. #if defined(TCCR3A) && defined(COM3A1)
  677. PWM_CASE(3,A);
  678. PWM_CASE(3,B);
  679. #if defined(COM3C1)
  680. PWM_CASE(3,C);
  681. #endif
  682. #endif
  683. #ifdef TCCR4A
  684. PWM_CASE(4,A);
  685. PWM_CASE(4,B);
  686. PWM_CASE(4,C);
  687. #endif
  688. #if defined(TCCR5A) && defined(COM5A1)
  689. PWM_CASE(5,A);
  690. PWM_CASE(5,B);
  691. PWM_CASE(5,C);
  692. #endif
  693. case NOT_ON_TIMER:
  694. default:
  695. return false;
  696. }
  697. SERIAL_PROTOCOLPGM(" ");
  698. } // pwm_status
  699. #define WGM_MAKE3(N) (((TCCR##N##B & _BV(WGM##N##2)) >> 1) | (TCCR##N##A & (_BV(WGM##N##0) | _BV(WGM##N##1))))
  700. #define WGM_MAKE4(N) (WGM_MAKE3(N) | (TCCR##N##B & _BV(WGM##N##3)) >> 1)
  701. #define TIMER_PREFIX(T,L,N) do{ \
  702. WGM = WGM_MAKE##N(T); \
  703. SERIAL_PROTOCOLPGM(" TIMER"); \
  704. SERIAL_PROTOCOLPGM(STRINGIFY(T) STRINGIFY(L)); \
  705. SERIAL_PROTOCOLPAIR(" WGM: ", WGM); \
  706. SERIAL_PROTOCOLPAIR(" TIMSK" STRINGIFY(T) ": ", TIMSK##T); \
  707. }while(0)
  708. #define WGM_TEST1 (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6)
  709. #define WGM_TEST2 (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13)
  710. static void err_is_counter() {
  711. SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
  712. }
  713. static void err_is_interrupt() {
  714. SERIAL_PROTOCOLPGM(" Can't be used as a PWM because it's being used as an interrupt");
  715. }
  716. static void err_prob_interrupt() {
  717. SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer is being used as an interrupt");
  718. }
  719. static void can_be_used() { SERIAL_PROTOCOLPGM(" can be used as PWM "); }
  720. static void pwm_details(uint8_t pin) {
  721. uint8_t WGM;
  722. switch(digitalPinToTimer(pin)) {
  723. #if defined(TCCR0A) && defined(COM0A1)
  724. case TIMER0A:
  725. TIMER_PREFIX(0,A,3);
  726. if (WGM_TEST1) err_is_counter();
  727. else if (TEST(TIMSK0, OCIE0A)) err_is_interrupt();
  728. else if (TEST(TIMSK0, TOIE0)) err_prob_interrupt();
  729. else can_be_used();
  730. break;
  731. case TIMER0B:
  732. TIMER_PREFIX(0,B,3);
  733. if (WGM_TEST1) err_is_counter();
  734. else if (TEST(TIMSK0, OCIE0B)) err_is_interrupt();
  735. else if (TEST(TIMSK0, TOIE0)) err_prob_interrupt();
  736. else can_be_used();
  737. break;
  738. #endif
  739. #if defined(TCCR1A) && defined(COM1A1)
  740. case TIMER1A:
  741. TIMER_PREFIX(1,A,4);
  742. if (WGM_TEST2) err_is_counter();
  743. else if (TEST(TIMSK1, OCIE1A)) err_is_interrupt();
  744. else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
  745. else can_be_used();
  746. break;
  747. case TIMER1B:
  748. TIMER_PREFIX(1,B,4);
  749. if (WGM_TEST2) err_is_counter();
  750. else if (TEST(TIMSK1, OCIE1B)) err_is_interrupt();
  751. else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
  752. else can_be_used();
  753. break;
  754. #if defined(COM1C1) && defined(TIMER1C)
  755. case TIMER1C:
  756. TIMER_PREFIX(1,C,4);
  757. if (WGM_TEST2) err_is_counter();
  758. else if (TEST(TIMSK1, OCIE1C)) err_is_interrupt();
  759. else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
  760. else can_be_used();
  761. break;
  762. #endif
  763. #endif
  764. #if defined(TCCR2A) && defined(COM2A1)
  765. case TIMER2A:
  766. TIMER_PREFIX(2,A,3);
  767. if (WGM_TEST1) err_is_counter();
  768. else if (TIMSK2 & (_BV(TOIE2) | _BV(OCIE2A))) err_is_interrupt();
  769. else if (TEST(TIMSK2, TOIE2)) err_prob_interrupt();
  770. else can_be_used();
  771. break;
  772. case TIMER2B:
  773. TIMER_PREFIX(2,B,3);
  774. if (WGM_TEST1) err_is_counter();
  775. else if (TEST(TIMSK2, OCIE2B)) err_is_interrupt();
  776. else if (TEST(TIMSK2, TOIE2)) err_prob_interrupt();
  777. else can_be_used();
  778. break;
  779. #endif
  780. #if defined(TCCR3A) && defined(COM3A1)
  781. case TIMER3A:
  782. TIMER_PREFIX(3,A,3);
  783. if (WGM_TEST2) err_is_counter();
  784. else if (TEST(TIMSK3, OCIE3A)) err_is_interrupt();
  785. else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
  786. else can_be_used();
  787. break;
  788. case TIMER3B:
  789. TIMER_PREFIX(3,B,3);
  790. if (WGM_TEST2) err_is_counter();
  791. else if (TEST(TIMSK3, OCIE3B)) err_is_interrupt();
  792. else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
  793. else can_be_used();
  794. break;
  795. #if defined(COM3C1)
  796. case TIMER3C:
  797. TIMER_PREFIX(3,C,3);
  798. if (WGM_TEST2) err_is_counter();
  799. else if (TEST(TIMSK3, OCIE3C)) err_is_interrupt();
  800. else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
  801. else can_be_used();
  802. break;
  803. #endif
  804. #endif
  805. #ifdef TCCR4A
  806. case TIMER4A:
  807. TIMER_PREFIX(4,A,4);
  808. if (WGM_TEST2) err_is_counter();
  809. else if (TEST(TIMSK4, OCIE4A)) err_is_interrupt();
  810. else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt();
  811. else can_be_used();
  812. break;
  813. case TIMER4B:
  814. TIMER_PREFIX(4,B,4);
  815. if (WGM_TEST2) err_is_counter();
  816. else if (TEST(TIMSK4, OCIE4B)) err_is_interrupt();
  817. else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt();
  818. else can_be_used();
  819. break;
  820. case TIMER4C:
  821. TIMER_PREFIX(4,C,4);
  822. if (WGM_TEST2) err_is_counter();
  823. else if (TEST(TIMSK4, OCIE4C)) err_is_interrupt();
  824. else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt();
  825. else can_be_used();
  826. break;
  827. #endif
  828. #if defined(TCCR5A) && defined(COM5A1)
  829. case TIMER5A:
  830. TIMER_PREFIX(5,A,4);
  831. if (WGM_TEST2) err_is_counter();
  832. else if (TEST(TIMSK5, OCIE5A)) err_is_interrupt();
  833. else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt();
  834. else can_be_used();
  835. break;
  836. case TIMER5B:
  837. TIMER_PREFIX(5,B,4);
  838. if (WGM_TEST2) err_is_counter();
  839. else if (TEST(TIMSK5, OCIE5B)) err_is_interrupt();
  840. else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt();
  841. else can_be_used();
  842. break;
  843. case TIMER5C:
  844. TIMER_PREFIX(5,C,4);
  845. if (WGM_TEST2) err_is_counter();
  846. else if (TEST(TIMSK5, OCIE5C)) err_is_interrupt();
  847. else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt();
  848. else can_be_used();
  849. break;
  850. #endif
  851. case NOT_ON_TIMER: break;
  852. }
  853. SERIAL_PROTOCOLPGM(" ");
  854. } // pwm_details
  855. inline void report_pin_state(int8_t pin) {
  856. SERIAL_ECHO((int)pin);
  857. SERIAL_CHAR(' ');
  858. bool dummy;
  859. if (report_pin_name(pin, dummy)) {
  860. if (pin_is_protected(pin))
  861. SERIAL_ECHOPGM(" (protected)");
  862. else {
  863. SERIAL_ECHOPGM(" = ");
  864. pinMode(pin, INPUT_PULLUP);
  865. SERIAL_ECHO(digitalRead(pin));
  866. if (IS_ANALOG(pin)) {
  867. SERIAL_CHAR(' '); SERIAL_CHAR('(');
  868. SERIAL_ECHO(analogRead(pin - analogInputToDigitalPin(0)));
  869. SERIAL_CHAR(')');
  870. }
  871. }
  872. }
  873. SERIAL_EOL;
  874. }
  875. bool get_pinMode(int8_t pin) { return *portModeRegister(digitalPinToPort(pin)) & digitalPinToBitMask(pin); }
  876. // pretty report with PWM info
  877. inline void report_pin_state_extended(int8_t pin, bool ignore) {
  878. char buffer[30]; // for the sprintf statements
  879. // report pin number
  880. sprintf(buffer, "PIN:% 3d ", pin);
  881. SERIAL_ECHO(buffer);
  882. // report pin name
  883. bool analog_pin;
  884. report_pin_name(pin, analog_pin);
  885. // report pin state
  886. if (pin_is_protected(pin) && !ignore)
  887. SERIAL_ECHOPGM("protected ");
  888. else {
  889. if (analog_pin) {
  890. sprintf(buffer, "Analog in =% 5d", analogRead(pin - analogInputToDigitalPin(0)));
  891. SERIAL_ECHO(buffer);
  892. }
  893. else {
  894. if (!get_pinMode(pin)) {
  895. pinMode(pin, INPUT_PULLUP); // make sure input isn't floating
  896. SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin));
  897. }
  898. else if (pwm_status(pin)) {
  899. // do nothing
  900. }
  901. else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
  902. }
  903. }
  904. // report PWM capabilities
  905. pwm_details(pin);
  906. SERIAL_EOL;
  907. }