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.

fastio.h 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. * Copyright (c) 2017 Victor Perez
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. *
  22. */
  23. #pragma once
  24. /**
  25. * Fast I/O interfaces for STM32F4/7
  26. * These use GPIO functions instead of Direct Port Manipulation, as on AVR.
  27. */
  28. #ifndef PWM
  29. #define PWM OUTPUT
  30. #endif
  31. #define READ(IO) digitalRead(IO)
  32. #define WRITE(IO,V) digitalWrite(IO,V)
  33. #define _GET_MODE(IO)
  34. #define _SET_MODE(IO,M) pinMode(IO, M)
  35. #define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) /*!< Output Push Pull Mode & GPIO_NOPULL */
  36. #define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
  37. #define SET_INPUT(IO) _SET_MODE(IO, INPUT) /*!< Input Floating Mode */
  38. #define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) /*!< Input with Pull-up activation */
  39. #define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) /*!< Input with Pull-down activation */
  40. #define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
  41. #define SET_PWM(IO) _SET_MODE(IO, PWM)
  42. #define TOGGLE(IO) OUT_WRITE(IO, !READ(IO))
  43. #define IS_INPUT(IO)
  44. #define IS_OUTPUT(IO)
  45. #define PWM_PIN(P) true
  46. // digitalRead/Write wrappers
  47. #define extDigitalRead(IO) digitalRead(IO)
  48. #define extDigitalWrite(IO,V) digitalWrite(IO,V)
  49. //
  50. // Pins Definitions
  51. //
  52. #define PORTA 0
  53. #define PORTB 1
  54. #define PORTC 2
  55. #define PORTD 3
  56. #define PORTE 4
  57. #define PORTF 5
  58. #define PORTG 6
  59. #define _STM32_PIN(P,PN) ((PORT##P * 16) + PN)
  60. #undef PA0
  61. #define PA0 _STM32_PIN(A, 0)
  62. #undef PA1
  63. #define PA1 _STM32_PIN(A, 1)
  64. #undef PA2
  65. #define PA2 _STM32_PIN(A, 2)
  66. #undef PA3
  67. #define PA3 _STM32_PIN(A, 3)
  68. #undef PA4
  69. #define PA4 _STM32_PIN(A, 4)
  70. #undef PA5
  71. #define PA5 _STM32_PIN(A, 5)
  72. #undef PA6
  73. #define PA6 _STM32_PIN(A, 6)
  74. #undef PA7
  75. #define PA7 _STM32_PIN(A, 7)
  76. #undef PA8
  77. #define PA8 _STM32_PIN(A, 8)
  78. #undef PA9
  79. #define PA9 _STM32_PIN(A, 9)
  80. #undef PA10
  81. #define PA10 _STM32_PIN(A, 10)
  82. #undef PA11
  83. #define PA11 _STM32_PIN(A, 11)
  84. #undef PA12
  85. #define PA12 _STM32_PIN(A, 12)
  86. #undef PA13
  87. #define PA13 _STM32_PIN(A, 13)
  88. #undef PA14
  89. #define PA14 _STM32_PIN(A, 14)
  90. #undef PA15
  91. #define PA15 _STM32_PIN(A, 15)
  92. #undef PB0
  93. #define PB0 _STM32_PIN(B, 0)
  94. #undef PB1
  95. #define PB1 _STM32_PIN(B, 1)
  96. #undef PB2
  97. #define PB2 _STM32_PIN(B, 2)
  98. #undef PB3
  99. #define PB3 _STM32_PIN(B, 3)
  100. #undef PB4
  101. #define PB4 _STM32_PIN(B, 4)
  102. #undef PB5
  103. #define PB5 _STM32_PIN(B, 5)
  104. #undef PB6
  105. #define PB6 _STM32_PIN(B, 6)
  106. #undef PB7
  107. #define PB7 _STM32_PIN(B, 7)
  108. #undef PB8
  109. #define PB8 _STM32_PIN(B, 8)
  110. #undef PB9
  111. #define PB9 _STM32_PIN(B, 9)
  112. #undef PB10
  113. #define PB10 _STM32_PIN(B, 10)
  114. #undef PB11
  115. #define PB11 _STM32_PIN(B, 11)
  116. #undef PB12
  117. #define PB12 _STM32_PIN(B, 12)
  118. #undef PB13
  119. #define PB13 _STM32_PIN(B, 13)
  120. #undef PB14
  121. #define PB14 _STM32_PIN(B, 14)
  122. #undef PB15
  123. #define PB15 _STM32_PIN(B, 15)
  124. #undef PC0
  125. #define PC0 _STM32_PIN(C, 0)
  126. #undef PC1
  127. #define PC1 _STM32_PIN(C, 1)
  128. #undef PC2
  129. #define PC2 _STM32_PIN(C, 2)
  130. #undef PC3
  131. #define PC3 _STM32_PIN(C, 3)
  132. #undef PC4
  133. #define PC4 _STM32_PIN(C, 4)
  134. #undef PC5
  135. #define PC5 _STM32_PIN(C, 5)
  136. #undef PC6
  137. #define PC6 _STM32_PIN(C, 6)
  138. #undef PC7
  139. #define PC7 _STM32_PIN(C, 7)
  140. #undef PC8
  141. #define PC8 _STM32_PIN(C, 8)
  142. #undef PC9
  143. #define PC9 _STM32_PIN(C, 9)
  144. #undef PC10
  145. #define PC10 _STM32_PIN(C, 10)
  146. #undef PC11
  147. #define PC11 _STM32_PIN(C, 11)
  148. #undef PC12
  149. #define PC12 _STM32_PIN(C, 12)
  150. #undef PC13
  151. #define PC13 _STM32_PIN(C, 13)
  152. #undef PC14
  153. #define PC14 _STM32_PIN(C, 14)
  154. #undef PC15
  155. #define PC15 _STM32_PIN(C, 15)
  156. #undef PD0
  157. #define PD0 _STM32_PIN(D, 0)
  158. #undef PD1
  159. #define PD1 _STM32_PIN(D, 1)
  160. #undef PD2
  161. #define PD2 _STM32_PIN(D, 2)
  162. #undef PD3
  163. #define PD3 _STM32_PIN(D, 3)
  164. #undef PD4
  165. #define PD4 _STM32_PIN(D, 4)
  166. #undef PD5
  167. #define PD5 _STM32_PIN(D, 5)
  168. #undef PD6
  169. #define PD6 _STM32_PIN(D, 6)
  170. #undef PD7
  171. #define PD7 _STM32_PIN(D, 7)
  172. #undef PD8
  173. #define PD8 _STM32_PIN(D, 8)
  174. #undef PD9
  175. #define PD9 _STM32_PIN(D, 9)
  176. #undef PD10
  177. #define PD10 _STM32_PIN(D, 10)
  178. #undef PD11
  179. #define PD11 _STM32_PIN(D, 11)
  180. #undef PD12
  181. #define PD12 _STM32_PIN(D, 12)
  182. #undef PD13
  183. #define PD13 _STM32_PIN(D, 13)
  184. #undef PD14
  185. #define PD14 _STM32_PIN(D, 14)
  186. #undef PD15
  187. #define PD15 _STM32_PIN(D, 15)
  188. #undef PE0
  189. #define PE0 _STM32_PIN(E, 0)
  190. #undef PE1
  191. #define PE1 _STM32_PIN(E, 1)
  192. #undef PE2
  193. #define PE2 _STM32_PIN(E, 2)
  194. #undef PE3
  195. #define PE3 _STM32_PIN(E, 3)
  196. #undef PE4
  197. #define PE4 _STM32_PIN(E, 4)
  198. #undef PE5
  199. #define PE5 _STM32_PIN(E, 5)
  200. #undef PE6
  201. #define PE6 _STM32_PIN(E, 6)
  202. #undef PE7
  203. #define PE7 _STM32_PIN(E, 7)
  204. #undef PE8
  205. #define PE8 _STM32_PIN(E, 8)
  206. #undef PE9
  207. #define PE9 _STM32_PIN(E, 9)
  208. #undef PE10
  209. #define PE10 _STM32_PIN(E, 10)
  210. #undef PE11
  211. #define PE11 _STM32_PIN(E, 11)
  212. #undef PE12
  213. #define PE12 _STM32_PIN(E, 12)
  214. #undef PE13
  215. #define PE13 _STM32_PIN(E, 13)
  216. #undef PE14
  217. #define PE14 _STM32_PIN(E, 14)
  218. #undef PE15
  219. #define PE15 _STM32_PIN(E, 15)
  220. #ifdef STM32F7
  221. #undef PORTF
  222. #define PORTF 5
  223. #undef PF0
  224. #define PF0 _STM32_PIN(F, 0)
  225. #undef PF1
  226. #define PF1 _STM32_PIN(F, 1)
  227. #undef PF2
  228. #define PF2 _STM32_PIN(F, 2)
  229. #undef PF3
  230. #define PF3 _STM32_PIN(F, 3)
  231. #undef PF4
  232. #define PF4 _STM32_PIN(F, 4)
  233. #undef PF5
  234. #define PF5 _STM32_PIN(F, 5)
  235. #undef PF6
  236. #define PF6 _STM32_PIN(F, 6)
  237. #undef PF7
  238. #define PF7 _STM32_PIN(F, 7)
  239. #undef PF8
  240. #define PF8 _STM32_PIN(F, 8)
  241. #undef PF9
  242. #define PF9 _STM32_PIN(F, 9)
  243. #undef PF10
  244. #define PF10 _STM32_PIN(F, 10)
  245. #undef PF11
  246. #define PF11 _STM32_PIN(F, 11)
  247. #undef PF12
  248. #define PF12 _STM32_PIN(F, 12)
  249. #undef PF13
  250. #define PF13 _STM32_PIN(F, 13)
  251. #undef PF14
  252. #define PF14 _STM32_PIN(F, 14)
  253. #undef PF15
  254. #define PF15 _STM32_PIN(F, 15)
  255. #undef PORTG
  256. #define PORTG 6
  257. #undef PG0
  258. #define PG0 _STM32_PIN(G, 0)
  259. #undef PG1
  260. #define PG1 _STM32_PIN(G, 1)
  261. #undef PG2
  262. #define PG2 _STM32_PIN(G, 2)
  263. #undef PG3
  264. #define PG3 _STM32_PIN(G, 3)
  265. #undef PG4
  266. #define PG4 _STM32_PIN(G, 4)
  267. #undef PG5
  268. #define PG5 _STM32_PIN(G, 5)
  269. #undef PG6
  270. #define PG6 _STM32_PIN(G, 6)
  271. #undef PG7
  272. #define PG7 _STM32_PIN(G, 7)
  273. #undef PG8
  274. #define PG8 _STM32_PIN(G, 8)
  275. #undef PG9
  276. #define PG9 _STM32_PIN(G, 9)
  277. #undef PG10
  278. #define PG10 _STM32_PIN(G, 10)
  279. #undef PG11
  280. #define PG11 _STM32_PIN(G, 11)
  281. #undef PG12
  282. #define PG12 _STM32_PIN(G, 12)
  283. #undef PG13
  284. #define PG13 _STM32_PIN(G, 13)
  285. #undef PG14
  286. #define PG14 _STM32_PIN(G, 14)
  287. #undef PG15
  288. #define PG15 _STM32_PIN(G, 15)
  289. #endif // STM32GENERIC && STM32F7