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.

pinsDebug.h 34KB

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