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

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