config_common.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /* Copyright 2015-2018 Jack Humbert
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. /* diode directions */
  18. #define COL2ROW 0
  19. #define ROW2COL 1
  20. // useful for direct pin mapping
  21. #define NO_PIN (pin_t)(~0)
  22. #ifdef __AVR__
  23. # ifndef __ASSEMBLER__
  24. # include <avr/io.h>
  25. # endif
  26. # define PORT_SHIFTER 4 // this may be 4 for all AVR chips
  27. // If you want to add more to this list, reference the PINx definitions in these header
  28. // files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr
  29. # if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
  30. # define ADDRESS_BASE 0x00
  31. # define PINB_ADDRESS 0x3
  32. # define PINC_ADDRESS 0x6
  33. # define PIND_ADDRESS 0x9
  34. # define PINE_ADDRESS 0xC
  35. # define PINF_ADDRESS 0xF
  36. # elif defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
  37. # define ADDRESS_BASE 0x00
  38. # define PINB_ADDRESS 0x3
  39. # define PINC_ADDRESS 0x6
  40. # define PIND_ADDRESS 0x9
  41. # elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
  42. # define ADDRESS_BASE 0x00
  43. # define PINA_ADDRESS 0x0
  44. # define PINB_ADDRESS 0x3
  45. # define PINC_ADDRESS 0x6
  46. # define PIND_ADDRESS 0x9
  47. # define PINE_ADDRESS 0xC
  48. # define PINF_ADDRESS 0xF
  49. # elif defined(__AVR_ATmega32A__)
  50. # define ADDRESS_BASE 0x10
  51. # define PIND_ADDRESS 0x0
  52. # define PINC_ADDRESS 0x3
  53. # define PINB_ADDRESS 0x6
  54. # define PINA_ADDRESS 0x9
  55. # elif defined(__AVR_ATtiny85__)
  56. # define ADDRESS_BASE 0x10
  57. # define PINB_ADDRESS 0x6
  58. # else
  59. # error "Pins are not defined"
  60. # endif
  61. /* I/O pins */
  62. # define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin)
  63. # ifdef PORTA
  64. # define A0 PINDEF(A, 0)
  65. # define A1 PINDEF(A, 1)
  66. # define A2 PINDEF(A, 2)
  67. # define A3 PINDEF(A, 3)
  68. # define A4 PINDEF(A, 4)
  69. # define A5 PINDEF(A, 5)
  70. # define A6 PINDEF(A, 6)
  71. # define A7 PINDEF(A, 7)
  72. # endif
  73. # ifdef PORTB
  74. # define B0 PINDEF(B, 0)
  75. # define B1 PINDEF(B, 1)
  76. # define B2 PINDEF(B, 2)
  77. # define B3 PINDEF(B, 3)
  78. # define B4 PINDEF(B, 4)
  79. # define B5 PINDEF(B, 5)
  80. # define B6 PINDEF(B, 6)
  81. # define B7 PINDEF(B, 7)
  82. # endif
  83. # ifdef PORTC
  84. # define C0 PINDEF(C, 0)
  85. # define C1 PINDEF(C, 1)
  86. # define C2 PINDEF(C, 2)
  87. # define C3 PINDEF(C, 3)
  88. # define C4 PINDEF(C, 4)
  89. # define C5 PINDEF(C, 5)
  90. # define C6 PINDEF(C, 6)
  91. # define C7 PINDEF(C, 7)
  92. # endif
  93. # ifdef PORTD
  94. # define D0 PINDEF(D, 0)
  95. # define D1 PINDEF(D, 1)
  96. # define D2 PINDEF(D, 2)
  97. # define D3 PINDEF(D, 3)
  98. # define D4 PINDEF(D, 4)
  99. # define D5 PINDEF(D, 5)
  100. # define D6 PINDEF(D, 6)
  101. # define D7 PINDEF(D, 7)
  102. # endif
  103. # ifdef PORTE
  104. # define E0 PINDEF(E, 0)
  105. # define E1 PINDEF(E, 1)
  106. # define E2 PINDEF(E, 2)
  107. # define E3 PINDEF(E, 3)
  108. # define E4 PINDEF(E, 4)
  109. # define E5 PINDEF(E, 5)
  110. # define E6 PINDEF(E, 6)
  111. # define E7 PINDEF(E, 7)
  112. # endif
  113. # ifdef PORTF
  114. # define F0 PINDEF(F, 0)
  115. # define F1 PINDEF(F, 1)
  116. # define F2 PINDEF(F, 2)
  117. # define F3 PINDEF(F, 3)
  118. # define F4 PINDEF(F, 4)
  119. # define F5 PINDEF(F, 5)
  120. # define F6 PINDEF(F, 6)
  121. # define F7 PINDEF(F, 7)
  122. # endif
  123. # ifndef __ASSEMBLER__
  124. # define _PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + ((p) >> PORT_SHIFTER) + (offset))
  125. // Port X Input Pins Address
  126. # define PINx_ADDRESS(p) _PIN_ADDRESS(p, 0)
  127. // Port X Data Direction Register, 0:input 1:output
  128. # define DDRx_ADDRESS(p) _PIN_ADDRESS(p, 1)
  129. // Port X Data Register
  130. # define PORTx_ADDRESS(p) _PIN_ADDRESS(p, 2)
  131. # endif
  132. #elif defined(PROTOCOL_CHIBIOS)
  133. // Defines mapping for Proton C replacement
  134. # ifdef CONVERT_TO_PROTON_C
  135. // Left side (front)
  136. # define D3 PAL_LINE(GPIOA, 9)
  137. # define D2 PAL_LINE(GPIOA, 10)
  138. // GND
  139. // GND
  140. # define D1 PAL_LINE(GPIOB, 7)
  141. # define D0 PAL_LINE(GPIOB, 6)
  142. # define D4 PAL_LINE(GPIOB, 5)
  143. # define C6 PAL_LINE(GPIOB, 4)
  144. # define D7 PAL_LINE(GPIOB, 3)
  145. # define E6 PAL_LINE(GPIOB, 2)
  146. # define B4 PAL_LINE(GPIOB, 1)
  147. # define B5 PAL_LINE(GPIOB, 0)
  148. // Right side (front)
  149. // RAW
  150. // GND
  151. // RESET
  152. // VCC
  153. # define F4 PAL_LINE(GPIOA, 2)
  154. # define F5 PAL_LINE(GPIOA, 1)
  155. # define F6 PAL_LINE(GPIOA, 0)
  156. # define F7 PAL_LINE(GPIOB, 8)
  157. # define B1 PAL_LINE(GPIOB, 13)
  158. # define B3 PAL_LINE(GPIOB, 14)
  159. # define B2 PAL_LINE(GPIOB, 15)
  160. # define B6 PAL_LINE(GPIOB, 9)
  161. // LEDs (only D5/C13 uses an actual LED)
  162. # ifdef CONVERT_TO_PROTON_C_RXLED
  163. # define D5 PAL_LINE(GPIOC, 14)
  164. # define B0 PAL_LINE(GPIOC, 13)
  165. # else
  166. # define D5 PAL_LINE(GPIOC, 13)
  167. # define B0 PAL_LINE(GPIOC, 14)
  168. # endif
  169. # else
  170. # define A0 PAL_LINE(GPIOA, 0)
  171. # define A1 PAL_LINE(GPIOA, 1)
  172. # define A2 PAL_LINE(GPIOA, 2)
  173. # define A3 PAL_LINE(GPIOA, 3)
  174. # define A4 PAL_LINE(GPIOA, 4)
  175. # define A5 PAL_LINE(GPIOA, 5)
  176. # define A6 PAL_LINE(GPIOA, 6)
  177. # define A7 PAL_LINE(GPIOA, 7)
  178. # define A8 PAL_LINE(GPIOA, 8)
  179. # define A9 PAL_LINE(GPIOA, 9)
  180. # define A10 PAL_LINE(GPIOA, 10)
  181. # define A11 PAL_LINE(GPIOA, 11)
  182. # define A12 PAL_LINE(GPIOA, 12)
  183. # define A13 PAL_LINE(GPIOA, 13)
  184. # define A14 PAL_LINE(GPIOA, 14)
  185. # define A15 PAL_LINE(GPIOA, 15)
  186. # define B0 PAL_LINE(GPIOB, 0)
  187. # define B1 PAL_LINE(GPIOB, 1)
  188. # define B2 PAL_LINE(GPIOB, 2)
  189. # define B3 PAL_LINE(GPIOB, 3)
  190. # define B4 PAL_LINE(GPIOB, 4)
  191. # define B5 PAL_LINE(GPIOB, 5)
  192. # define B6 PAL_LINE(GPIOB, 6)
  193. # define B7 PAL_LINE(GPIOB, 7)
  194. # define B8 PAL_LINE(GPIOB, 8)
  195. # define B9 PAL_LINE(GPIOB, 9)
  196. # define B10 PAL_LINE(GPIOB, 10)
  197. # define B11 PAL_LINE(GPIOB, 11)
  198. # define B12 PAL_LINE(GPIOB, 12)
  199. # define B13 PAL_LINE(GPIOB, 13)
  200. # define B14 PAL_LINE(GPIOB, 14)
  201. # define B15 PAL_LINE(GPIOB, 15)
  202. # define B16 PAL_LINE(GPIOB, 16)
  203. # define B17 PAL_LINE(GPIOB, 17)
  204. # define B18 PAL_LINE(GPIOB, 18)
  205. # define B19 PAL_LINE(GPIOB, 19)
  206. # define C0 PAL_LINE(GPIOC, 0)
  207. # define C1 PAL_LINE(GPIOC, 1)
  208. # define C2 PAL_LINE(GPIOC, 2)
  209. # define C3 PAL_LINE(GPIOC, 3)
  210. # define C4 PAL_LINE(GPIOC, 4)
  211. # define C5 PAL_LINE(GPIOC, 5)
  212. # define C6 PAL_LINE(GPIOC, 6)
  213. # define C7 PAL_LINE(GPIOC, 7)
  214. # define C8 PAL_LINE(GPIOC, 8)
  215. # define C9 PAL_LINE(GPIOC, 9)
  216. # define C10 PAL_LINE(GPIOC, 10)
  217. # define C11 PAL_LINE(GPIOC, 11)
  218. # define C12 PAL_LINE(GPIOC, 12)
  219. # define C13 PAL_LINE(GPIOC, 13)
  220. # define C14 PAL_LINE(GPIOC, 14)
  221. # define C15 PAL_LINE(GPIOC, 15)
  222. # define D0 PAL_LINE(GPIOD, 0)
  223. # define D1 PAL_LINE(GPIOD, 1)
  224. # define D2 PAL_LINE(GPIOD, 2)
  225. # define D3 PAL_LINE(GPIOD, 3)
  226. # define D4 PAL_LINE(GPIOD, 4)
  227. # define D5 PAL_LINE(GPIOD, 5)
  228. # define D6 PAL_LINE(GPIOD, 6)
  229. # define D7 PAL_LINE(GPIOD, 7)
  230. # define D8 PAL_LINE(GPIOD, 8)
  231. # define D9 PAL_LINE(GPIOD, 9)
  232. # define D10 PAL_LINE(GPIOD, 10)
  233. # define D11 PAL_LINE(GPIOD, 11)
  234. # define D12 PAL_LINE(GPIOD, 12)
  235. # define D13 PAL_LINE(GPIOD, 13)
  236. # define D14 PAL_LINE(GPIOD, 14)
  237. # define D15 PAL_LINE(GPIOD, 15)
  238. # define E0 PAL_LINE(GPIOE, 0)
  239. # define E1 PAL_LINE(GPIOE, 1)
  240. # define E2 PAL_LINE(GPIOE, 2)
  241. # define E3 PAL_LINE(GPIOE, 3)
  242. # define E4 PAL_LINE(GPIOE, 4)
  243. # define E5 PAL_LINE(GPIOE, 5)
  244. # define E6 PAL_LINE(GPIOE, 6)
  245. # define E7 PAL_LINE(GPIOE, 7)
  246. # define E8 PAL_LINE(GPIOE, 8)
  247. # define E9 PAL_LINE(GPIOE, 9)
  248. # define E10 PAL_LINE(GPIOE, 10)
  249. # define E11 PAL_LINE(GPIOE, 11)
  250. # define E12 PAL_LINE(GPIOE, 12)
  251. # define E13 PAL_LINE(GPIOE, 13)
  252. # define E14 PAL_LINE(GPIOE, 14)
  253. # define E15 PAL_LINE(GPIOE, 15)
  254. # define F0 PAL_LINE(GPIOF, 0)
  255. # define F1 PAL_LINE(GPIOF, 1)
  256. # define F2 PAL_LINE(GPIOF, 2)
  257. # define F3 PAL_LINE(GPIOF, 3)
  258. # define F4 PAL_LINE(GPIOF, 4)
  259. # define F5 PAL_LINE(GPIOF, 5)
  260. # define F6 PAL_LINE(GPIOF, 6)
  261. # define F7 PAL_LINE(GPIOF, 7)
  262. # define F8 PAL_LINE(GPIOF, 8)
  263. # define F9 PAL_LINE(GPIOF, 9)
  264. # define F10 PAL_LINE(GPIOF, 10)
  265. # define F11 PAL_LINE(GPIOF, 11)
  266. # define F12 PAL_LINE(GPIOF, 12)
  267. # define F13 PAL_LINE(GPIOF, 13)
  268. # define F14 PAL_LINE(GPIOF, 14)
  269. # define F15 PAL_LINE(GPIOF, 15)
  270. # define G0 PAL_LINE(GPIOG, 0)
  271. # define G1 PAL_LINE(GPIOG, 1)
  272. # define G2 PAL_LINE(GPIOG, 2)
  273. # define G3 PAL_LINE(GPIOG, 3)
  274. # define G4 PAL_LINE(GPIOG, 4)
  275. # define G5 PAL_LINE(GPIOG, 5)
  276. # define G6 PAL_LINE(GPIOG, 6)
  277. # define G7 PAL_LINE(GPIOG, 7)
  278. # define G8 PAL_LINE(GPIOG, 8)
  279. # define G9 PAL_LINE(GPIOG, 9)
  280. # define G10 PAL_LINE(GPIOG, 10)
  281. # define G11 PAL_LINE(GPIOG, 11)
  282. # define G12 PAL_LINE(GPIOG, 12)
  283. # define G13 PAL_LINE(GPIOG, 13)
  284. # define G14 PAL_LINE(GPIOG, 14)
  285. # define G15 PAL_LINE(GPIOG, 15)
  286. # define H0 PAL_LINE(GPIOH, 0)
  287. # define H1 PAL_LINE(GPIOH, 1)
  288. # define H2 PAL_LINE(GPIOH, 2)
  289. # define H3 PAL_LINE(GPIOH, 3)
  290. # define H4 PAL_LINE(GPIOH, 4)
  291. # define H5 PAL_LINE(GPIOH, 5)
  292. # define H6 PAL_LINE(GPIOH, 6)
  293. # define H7 PAL_LINE(GPIOH, 7)
  294. # define H8 PAL_LINE(GPIOH, 8)
  295. # define H9 PAL_LINE(GPIOH, 9)
  296. # define H10 PAL_LINE(GPIOH, 10)
  297. # define H11 PAL_LINE(GPIOH, 11)
  298. # define H12 PAL_LINE(GPIOH, 12)
  299. # define H13 PAL_LINE(GPIOH, 13)
  300. # define H14 PAL_LINE(GPIOH, 14)
  301. # define H15 PAL_LINE(GPIOH, 15)
  302. # define I0 PAL_LINE(GPIOI, 0)
  303. # define I1 PAL_LINE(GPIOI, 1)
  304. # define I2 PAL_LINE(GPIOI, 2)
  305. # define I3 PAL_LINE(GPIOI, 3)
  306. # define I4 PAL_LINE(GPIOI, 4)
  307. # define I5 PAL_LINE(GPIOI, 5)
  308. # define I6 PAL_LINE(GPIOI, 6)
  309. # define I7 PAL_LINE(GPIOI, 7)
  310. # define I8 PAL_LINE(GPIOI, 8)
  311. # define I9 PAL_LINE(GPIOI, 9)
  312. # define I10 PAL_LINE(GPIOI, 10)
  313. # define I11 PAL_LINE(GPIOI, 11)
  314. # define I12 PAL_LINE(GPIOI, 12)
  315. # define I13 PAL_LINE(GPIOI, 13)
  316. # define I14 PAL_LINE(GPIOI, 14)
  317. # define I15 PAL_LINE(GPIOI, 15)
  318. # define J0 PAL_LINE(GPIOJ, 0)
  319. # define J1 PAL_LINE(GPIOJ, 1)
  320. # define J2 PAL_LINE(GPIOJ, 2)
  321. # define J3 PAL_LINE(GPIOJ, 3)
  322. # define J4 PAL_LINE(GPIOJ, 4)
  323. # define J5 PAL_LINE(GPIOJ, 5)
  324. # define J6 PAL_LINE(GPIOJ, 6)
  325. # define J7 PAL_LINE(GPIOJ, 7)
  326. # define J8 PAL_LINE(GPIOJ, 8)
  327. # define J9 PAL_LINE(GPIOJ, 9)
  328. # define J10 PAL_LINE(GPIOJ, 10)
  329. # define J11 PAL_LINE(GPIOJ, 11)
  330. # define J12 PAL_LINE(GPIOJ, 12)
  331. # define J13 PAL_LINE(GPIOJ, 13)
  332. # define J14 PAL_LINE(GPIOJ, 14)
  333. # define J15 PAL_LINE(GPIOJ, 15)
  334. // Keyboards can `#define KEYBOARD_REQUIRES_GPIOK` if they need to access GPIO-K pins. These conflict with a whole
  335. // bunch of layout definitions, so it's intentionally left out unless absolutely required -- in that case, the
  336. // keyboard designer should use a different symbol when defining their layout macros.
  337. # ifdef KEYBOARD_REQUIRES_GPIOK
  338. # define K0 PAL_LINE(GPIOK, 0)
  339. # define K1 PAL_LINE(GPIOK, 1)
  340. # define K2 PAL_LINE(GPIOK, 2)
  341. # define K3 PAL_LINE(GPIOK, 3)
  342. # define K4 PAL_LINE(GPIOK, 4)
  343. # define K5 PAL_LINE(GPIOK, 5)
  344. # define K6 PAL_LINE(GPIOK, 6)
  345. # define K7 PAL_LINE(GPIOK, 7)
  346. # define K8 PAL_LINE(GPIOK, 8)
  347. # define K9 PAL_LINE(GPIOK, 9)
  348. # define K10 PAL_LINE(GPIOK, 10)
  349. # define K11 PAL_LINE(GPIOK, 11)
  350. # define K12 PAL_LINE(GPIOK, 12)
  351. # define K13 PAL_LINE(GPIOK, 13)
  352. # define K14 PAL_LINE(GPIOK, 14)
  353. # define K15 PAL_LINE(GPIOK, 15)
  354. # endif
  355. # endif
  356. #endif
  357. #define API_SYSEX_MAX_SIZE 32
  358. #include "song_list.h"