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 34KB

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