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.

224 lines
7.2 KiB

Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
Massdrop keyboard support (#3780) * Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
5 years ago
  1. /*
  2. Copyright 2018 Massdrop Inc.
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _D51_UTIL_H_
  15. #define _D51_UTIL_H_
  16. #include "samd51j18a.h"
  17. /* Debug LED */
  18. #if DEBUG_LED_ENABLE == 1
  19. # define DBG_LED_ENA PORT->Group[DEBUG_LED_PORT].DIRSET.reg = (1 << DEBUG_LED_PIN)
  20. # define DBG_LED_DIS PORT->Group[DEBUG_LED_PORT].DIRCLR.reg = (1 << DEBUG_LED_PIN)
  21. # define DBG_LED_ON PORT->Group[DEBUG_LED_PORT].OUTSET.reg = (1 << DEBUG_LED_PIN)
  22. # define DBG_LED_OFF PORT->Group[DEBUG_LED_PORT].OUTCLR.reg = (1 << DEBUG_LED_PIN)
  23. #else
  24. # define DBG_LED_ENA
  25. # define DBG_LED_DIS
  26. # define DBG_LED_ON
  27. # define DBG_LED_OFF
  28. #endif
  29. /* Debug Port 1 */
  30. #if DEBUG_PORT1_ENABLE == 1
  31. # define DBG_1_ENA PORT->Group[DEBUG_PORT1_PORT].DIRSET.reg = (1 << DEBUG_PORT1_PIN)
  32. # define DBG_1_DIS PORT->Group[DEBUG_PORT1_PORT].DIRCLR.reg = (1 << DEBUG_PORT1_PIN)
  33. # define DBG_1_ON PORT->Group[DEBUG_PORT1_PORT].OUTSET.reg = (1 << DEBUG_PORT1_PIN)
  34. # define DBG_1_OFF PORT->Group[DEBUG_PORT1_PORT].OUTCLR.reg = (1 << DEBUG_PORT1_PIN)
  35. #else
  36. # define DBG_1_ENA
  37. # define DBG_1_DIS
  38. # define DBG_1_ON
  39. # define DBG_1_OFF
  40. #endif
  41. /* Debug Port 2 */
  42. #if DEBUG_PORT2_ENABLE == 1
  43. # define DBG_2_ENA PORT->Group[DEBUG_PORT2_PORT].DIRSET.reg = (1 << DEBUG_PORT2_PIN)
  44. # define DBG_2_DIS PORT->Group[DEBUG_PORT2_PORT].DIRCLR.reg = (1 << DEBUG_PORT2_PIN)
  45. # define DBG_2_ON PORT->Group[DEBUG_PORT2_PORT].OUTSET.reg = (1 << DEBUG_PORT2_PIN)
  46. # define DBG_2_OFF PORT->Group[DEBUG_PORT2_PORT].OUTCLR.reg = (1 << DEBUG_PORT2_PIN)
  47. #else
  48. # define DBG_2_ENA
  49. # define DBG_2_DIS
  50. # define DBG_2_ON
  51. # define DBG_2_OFF
  52. #endif
  53. /* Debug Port 3 */
  54. #if DEBUG_PORT3_ENABLE == 1
  55. # define DBG_3_ENA PORT->Group[DEBUG_PORT3_PORT].DIRSET.reg = (1 << DEBUG_PORT3_PIN)
  56. # define DBG_3_DIS PORT->Group[DEBUG_PORT3_PORT].DIRCLR.reg = (1 << DEBUG_PORT3_PIN)
  57. # define DBG_3_ON PORT->Group[DEBUG_PORT3_PORT].OUTSET.reg = (1 << DEBUG_PORT3_PIN)
  58. # define DBG_3_OFF PORT->Group[DEBUG_PORT3_PORT].OUTCLR.reg = (1 << DEBUG_PORT3_PIN)
  59. #else
  60. # define DBG_3_ENA
  61. # define DBG_3_DIS
  62. # define DBG_3_ON
  63. # define DBG_3_OFF
  64. #endif
  65. void dbg_print(uint32_t x);
  66. void dled_print(uint32_t x, uint8_t long_pause);
  67. void debug_code_init(void);
  68. void debug_code_disable(void);
  69. #ifdef DEBUG_BOOT_TRACING_ENABLE
  70. # define DBGC(n) debug_code = n
  71. extern volatile uint32_t debug_code;
  72. enum debug_code_list {
  73. DC_UNSET = 0,
  74. DC_CLK_INIT_BEGIN,
  75. DC_CLK_INIT_COMPLETE,
  76. DC_CLK_SET_I2C1_FREQ_BEGIN,
  77. DC_CLK_SET_I2C1_FREQ_COMPLETE,
  78. DC_CLK_SET_I2C0_FREQ_BEGIN,
  79. DC_CLK_SET_I2C0_FREQ_COMPLETE,
  80. DC_CLK_SET_SPI_FREQ_BEGIN,
  81. DC_CLK_SET_SPI_FREQ_COMPLETE,
  82. DC_CLK_ENABLE_TIMEBASE_BEGIN,
  83. DC_CLK_ENABLE_TIMEBASE_SYNC_ENABLE,
  84. DC_CLK_ENABLE_TIMEBASE_SYNC_SWRST_1,
  85. DC_CLK_ENABLE_TIMEBASE_SYNC_SWRST_2,
  86. DC_CLK_ENABLE_TIMEBASE_TC4_BEGIN,
  87. DC_CLK_ENABLE_TIMEBASE_TC4_SYNC_DISABLE,
  88. DC_CLK_ENABLE_TIMEBASE_TC4_SYNC_SWRST_1,
  89. DC_CLK_ENABLE_TIMEBASE_TC4_SYNC_SWRST_2,
  90. DC_CLK_ENABLE_TIMEBASE_TC4_SYNC_CLTRB,
  91. DC_CLK_ENABLE_TIMEBASE_TC4_SYNC_CC0,
  92. DC_CLK_ENABLE_TIMEBASE_TC4_COMPLETE,
  93. DC_CLK_ENABLE_TIMEBASE_TC5_BEGIN,
  94. DC_CLK_ENABLE_TIMEBASE_TC5_SYNC_DISABLE,
  95. DC_CLK_ENABLE_TIMEBASE_TC5_SYNC_SWRST_1,
  96. DC_CLK_ENABLE_TIMEBASE_TC5_SYNC_SWRST_2,
  97. DC_CLK_ENABLE_TIMEBASE_TC5_SYNC_CLTRB,
  98. DC_CLK_ENABLE_TIMEBASE_TC5_COMPLETE,
  99. DC_CLK_ENABLE_TIMEBASE_TC0_BEGIN,
  100. DC_CLK_ENABLE_TIMEBASE_TC0_SYNC_DISABLE,
  101. DC_CLK_ENABLE_TIMEBASE_TC0_SYNC_SWRST_1,
  102. DC_CLK_ENABLE_TIMEBASE_TC0_SYNC_SWRST_2,
  103. DC_CLK_ENABLE_TIMEBASE_TC0_COMPLETE,
  104. DC_CLK_ENABLE_TIMEBASE_EVSYS_BEGIN,
  105. DC_CLK_ENABLE_TIMEBASE_EVSYS_COMPLETE,
  106. DC_CLK_ENABLE_TIMEBASE_COMPLETE,
  107. DC_CLK_SET_GCLK_FREQ_BEGIN,
  108. DC_CLK_SET_GCLK_FREQ_SYNC_1,
  109. DC_CLK_SET_GCLK_FREQ_SYNC_2,
  110. DC_CLK_SET_GCLK_FREQ_SYNC_3,
  111. DC_CLK_SET_GCLK_FREQ_SYNC_4,
  112. DC_CLK_SET_GCLK_FREQ_SYNC_5,
  113. DC_CLK_SET_GCLK_FREQ_COMPLETE,
  114. DC_CLK_INIT_OSC_BEGIN,
  115. DC_CLK_INIT_OSC_SYNC_1,
  116. DC_CLK_INIT_OSC_SYNC_2,
  117. DC_CLK_INIT_OSC_SYNC_3,
  118. DC_CLK_INIT_OSC_SYNC_4,
  119. DC_CLK_INIT_OSC_SYNC_5,
  120. DC_CLK_INIT_OSC_COMPLETE,
  121. DC_CLK_RESET_TIME_BEGIN,
  122. DC_CLK_RESET_TIME_COMPLETE,
  123. DC_CLK_OSC_INIT_BEGIN,
  124. DC_CLK_OSC_INIT_XOSC0_SYNC,
  125. DC_CLK_OSC_INIT_DPLL_SYNC_DISABLE,
  126. DC_CLK_OSC_INIT_DPLL_SYNC_RATIO,
  127. DC_CLK_OSC_INIT_DPLL_SYNC_ENABLE,
  128. DC_CLK_OSC_INIT_DPLL_WAIT_LOCK,
  129. DC_CLK_OSC_INIT_DPLL_WAIT_CLKRDY,
  130. DC_CLK_OSC_INIT_GCLK_SYNC_GENCTRL0,
  131. DC_CLK_OSC_INIT_COMPLETE,
  132. DC_SPI_INIT_BEGIN,
  133. DC_SPI_WRITE_DRE,
  134. DC_SPI_WRITE_TXC_1,
  135. DC_SPI_WRITE_TXC_2,
  136. DC_SPI_SYNC_ENABLING,
  137. DC_SPI_INIT_COMPLETE,
  138. DC_PORT_DETECT_INIT_BEGIN,
  139. DC_PORT_DETECT_INIT_FAILED,
  140. DC_PORT_DETECT_INIT_COMPLETE,
  141. DC_USB_RESET_BEGIN,
  142. DC_USB_RESET_COMPLETE,
  143. DC_USB_SET_HOST_BY_VOLTAGE_BEGIN,
  144. DC_USB_SET_HOST_5V_LOW_WAITING,
  145. DC_USB_SET_HOST_BY_VOLTAGE_COMPLETE,
  146. DC_USB_CONFIGURE_BEGIN,
  147. DC_USB_CONFIGURE_GET_SERIAL,
  148. DC_USB_CONFIGURE_COMPLETE,
  149. DC_USB_WRITE2422_BLOCK_BEGIN,
  150. DC_USB_WRITE2422_BLOCK_SYNC_SYSOP,
  151. DC_USB_WRITE2422_BLOCK_COMPLETE,
  152. DC_ADC0_CLOCK_INIT_BEGIN,
  153. DC_ADC0_CLOCK_INIT_COMPLETE,
  154. DC_ADC0_INIT_BEGIN,
  155. DC_ADC0_SWRST_SYNCING_1,
  156. DC_ADC0_SWRST_SYNCING_2,
  157. DC_ADC0_AVGCTRL_SYNCING_1,
  158. DC_ADC0_AVGCTRL_SYNCING_2,
  159. DC_ADC0_SAMPCTRL_SYNCING_1,
  160. DC_ADC0_ENABLE_SYNCING_1,
  161. DC_ADC0_INIT_COMPLETE,
  162. DC_I2C0_INIT_BEGIN,
  163. DC_I2C0_INIT_SYNC_ENABLING,
  164. DC_I2C0_INIT_SYNC_SYSOP,
  165. DC_I2C0_INIT_WAIT_IDLE,
  166. DC_I2C0_INIT_COMPLETE,
  167. DC_I2C1_INIT_BEGIN,
  168. DC_I2C1_INIT_SYNC_ENABLING,
  169. DC_I2C1_INIT_SYNC_SYSOP,
  170. DC_I2C1_INIT_WAIT_IDLE,
  171. DC_I2C1_INIT_COMPLETE,
  172. DC_I2C3733_INIT_CONTROL_BEGIN,
  173. DC_I2C3733_INIT_CONTROL_COMPLETE,
  174. DC_I2C3733_INIT_DRIVERS_BEGIN,
  175. DC_I2C3733_INIT_DRIVERS_COMPLETE,
  176. DC_I2C_DMAC_LED_INIT_BEGIN,
  177. DC_I2C_DMAC_LED_INIT_COMPLETE,
  178. DC_I2C3733_CONTROL_SET_BEGIN,
  179. DC_I2C3733_CONTROL_SET_COMPLETE,
  180. DC_LED_MATRIX_INIT_BEGIN,
  181. DC_LED_MATRIX_INIT_COMPLETE,
  182. DC_USB2422_INIT_BEGIN,
  183. DC_USB2422_INIT_WAIT_5V_LOW,
  184. DC_USB2422_INIT_OSC_SYNC_DISABLING,
  185. DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_1,
  186. DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_2,
  187. DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_3,
  188. DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_4,
  189. DC_USB2422_INIT_OSC_SYNC_DFLLMUL,
  190. DC_USB2422_INIT_OSC_SYNC_ENABLING,
  191. DC_USB2422_INIT_USB_SYNC_SWRST,
  192. DC_USB2422_INIT_USB_WAIT_SWRST,
  193. DC_USB2422_INIT_USB_SYNC_ENABLING,
  194. DC_USB2422_INIT_COMPLETE,
  195. DC_MAIN_UDC_START_BEGIN,
  196. DC_MAIN_UDC_START_COMPLETE,
  197. DC_MAIN_CDC_INIT_BEGIN,
  198. DC_MAIN_CDC_INIT_COMPLETE,
  199. /* Never change the order of error codes! Only add codes to end! */
  200. };
  201. #else
  202. # define DBGC(n) \
  203. {}
  204. #endif // DEBUG_BOOT_TRACING_ENABLE
  205. #endif //_D51_UTIL_H_