aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/faq_debug.md17
-rw-r--r--docs/zh-cn/faq_debug.md17
-rw-r--r--keyboards/amj96/matrix.c3
-rw-r--r--keyboards/clueboard/17/17.c4
-rw-r--r--keyboards/clueboard/66/rev2/rev2.c4
-rw-r--r--keyboards/clueboard/66_hotswap/prototype/prototype.c4
-rw-r--r--keyboards/ergodone/matrix.c4
-rw-r--r--keyboards/handwired/promethium/matrix.c7
-rw-r--r--keyboards/hhkb/rn42/rn42.c4
-rwxr-xr-xkeyboards/hid_liber/matrix.c4
-rw-r--r--keyboards/hotdox/matrix.c4
-rw-r--r--keyboards/launchpad/rev1/rev1.c7
-rw-r--r--keyboards/lets_split/sockets/sockets.h1
-rw-r--r--keyboards/miniaxe/config.h2
-rw-r--r--keyboards/sx60/matrix.c7
-rw-r--r--keyboards/vitamins_included/matrix.c6
-rw-r--r--keyboards/vitamins_included/rev1/rev1.h1
-rw-r--r--tmk_core/common/keyboard.c11
-rw-r--r--tmk_core/common/keyboard.h2
19 files changed, 15 insertions, 94 deletions
diff --git a/docs/faq_debug.md b/docs/faq_debug.md
index f6cc729b6..5cc20251d 100644
--- a/docs/faq_debug.md
+++ b/docs/faq_debug.md
@@ -184,22 +184,15 @@ Pressing any key during sleep should wake host.
184 184
185Arduino Leonardo and micro have **ATMega32U4** and can be used for TMK, though Arduino bootloader may be a problem. 185Arduino Leonardo and micro have **ATMega32U4** and can be used for TMK, though Arduino bootloader may be a problem.
186 186
187## Enabling JTAG
187 188
188## Using PF4-7 Pins of USB AVR? 189By default, the JTAG debugging interface is disabled as soon as the keyboard starts up. JTAG-capable MCUs come from the factory with the `JTAGEN` fuse set, and it takes over certain pins of the MCU that the board may be using for the switch matrix, LEDs, etc.
189You need to set JTD bit of MCUCR yourself to use PF4-7 as GPIO. Those pins are configured to serve JTAG function by default. MCUs like ATMega*U* or AT90USB* are affected with this.
190 190
191If you are using Teensy this isn't needed. Teensy is shipped with JTAGEN fuse bit unprogrammed to disable the function. 191If you would like to keep JTAG enabled, just add the following to your `config.h`:
192 192
193See this code. 193```c
194#define NO_JTAG_DISABLE
194``` 195```
195 // JTAG disable for PORT F. write JTD bit twice within four cycles.
196 MCUCR |= (1<<JTD);
197 MCUCR |= (1<<JTD);
198```
199https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hbkb/matrix.c#L67
200
201And read **26.5.1 MCU Control Register – MCUCR** of ATMega32U4 datasheet.
202
203 196
204## Adding LED Indicators of Lock Keys 197## Adding LED Indicators of Lock Keys
205You need your own LED indicators for CapsLock, ScrollLock and NumLock? See this post. 198You need your own LED indicators for CapsLock, ScrollLock and NumLock? See this post.
diff --git a/docs/zh-cn/faq_debug.md b/docs/zh-cn/faq_debug.md
index ca8b3fd25..a3cc7c510 100644
--- a/docs/zh-cn/faq_debug.md
+++ b/docs/zh-cn/faq_debug.md
@@ -173,23 +173,6 @@ EXTRAKEY_ENABLE = yes # 音频控制和系统控制
173 173
174Arduino Leonardo和micro使用**ATMega32U4**,该芯片TMK可用,但Arduino的bootloader会导致问题。 174Arduino Leonardo和micro使用**ATMega32U4**,该芯片TMK可用,但Arduino的bootloader会导致问题。
175 175
176
177## 在USB AVR使用PF4-7针脚?
178你要置位MCUCR寄存器JTD位来将PF4-7设置为GPIO。这些针脚默认是JTAG功能。 像ATMega*U* or AT90USB*这样的MCU会受影响。
179
180如果是用Teensy的话就不需要了。Tennsy自带JTAGEN位未编程来失能该功能。
181<!--翻译问题:上句可能有错,原文为:Teensy is shipped with JTAGEN fuse bit unprogrammed to disable the function. -->
182代码如下。
183```
184 // F接口JTAG失能。在四个周期内写入两次JTD位。
185 MCUCR |= (1<<JTD);
186 MCUCR |= (1<<JTD);
187```
188https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hbkb/matrix.c#L67
189
190阅读ATMega32U4的datasheet中的**26.5.1 MCU Control Register – MCUCR**。
191
192
193## 为锁定键添加指示灯 176## 为锁定键添加指示灯
194你要自制CapsLock, ScrollLock 和 NumLock指示灯?见下文。 177你要自制CapsLock, ScrollLock 和 NumLock指示灯?见下文。
195 178
diff --git a/keyboards/amj96/matrix.c b/keyboards/amj96/matrix.c
index e41bbec72..5d00ea98f 100644
--- a/keyboards/amj96/matrix.c
+++ b/keyboards/amj96/matrix.c
@@ -63,9 +63,6 @@ void matrix_init(void)
63#ifdef UART_RGB_ENABLE 63#ifdef UART_RGB_ENABLE
64 uart_rgb_init(); 64 uart_rgb_init();
65#endif 65#endif
66 // disable JTAG
67 MCUCR = _BV(JTD);
68 MCUCR = _BV(JTD);
69 66
70 // 85 REST 67 // 85 REST
71 DDRD |= _BV(PD7); 68 DDRD |= _BV(PD7);
diff --git a/keyboards/clueboard/17/17.c b/keyboards/clueboard/17/17.c
index 627aa236d..9e8ca644e 100644
--- a/keyboards/clueboard/17/17.c
+++ b/keyboards/clueboard/17/17.c
@@ -6,10 +6,6 @@ void matrix_init_kb(void) {
6 // put your keyboard start-up code here 6 // put your keyboard start-up code here
7 // runs once when the firmware starts up 7 // runs once when the firmware starts up
8 matrix_init_user(); 8 matrix_init_user();
9
10 // JTAG disable for PORT F. write JTD bit twice within four cycles.
11 MCUCR |= (1<<JTD);
12 MCUCR |= (1<<JTD);
13}; 9};
14 10
15void led_set_kb(uint8_t usb_led) { 11void led_set_kb(uint8_t usb_led) {
diff --git a/keyboards/clueboard/66/rev2/rev2.c b/keyboards/clueboard/66/rev2/rev2.c
index 1a35b87b8..d676b6d5f 100644
--- a/keyboards/clueboard/66/rev2/rev2.c
+++ b/keyboards/clueboard/66/rev2/rev2.c
@@ -8,10 +8,6 @@ void matrix_init_kb(void) {
8 // runs once when the firmware starts up 8 // runs once when the firmware starts up
9 matrix_init_user(); 9 matrix_init_user();
10 led_init_ports(); 10 led_init_ports();
11
12 // JTAG disable for PORT F. write JTD bit twice within four cycles.
13 MCUCR |= (1<<JTD);
14 MCUCR |= (1<<JTD);
15} 11}
16 12
17 13
diff --git a/keyboards/clueboard/66_hotswap/prototype/prototype.c b/keyboards/clueboard/66_hotswap/prototype/prototype.c
index 991d4b8fa..7c307be61 100644
--- a/keyboards/clueboard/66_hotswap/prototype/prototype.c
+++ b/keyboards/clueboard/66_hotswap/prototype/prototype.c
@@ -8,10 +8,6 @@ void matrix_init_kb(void) {
8 // runs once when the firmware starts up 8 // runs once when the firmware starts up
9 matrix_init_user(); 9 matrix_init_user();
10 led_init_ports(); 10 led_init_ports();
11
12 // JTAG disable for PORT F. write JTD bit twice within four cycles.
13 MCUCR |= (1<<JTD);
14 MCUCR |= (1<<JTD);
15} 11}
16 12
17 13
diff --git a/keyboards/ergodone/matrix.c b/keyboards/ergodone/matrix.c
index 2eb8f24ba..4a8230aa8 100644
--- a/keyboards/ergodone/matrix.c
+++ b/keyboards/ergodone/matrix.c
@@ -77,10 +77,6 @@ uint8_t matrix_cols(void)
77 77
78void matrix_init(void) 78void matrix_init(void)
79{ 79{
80 // disable JTAG
81 MCUCR = (1<<JTD);
82 MCUCR = (1<<JTD);
83
84 unselect_rows(); 80 unselect_rows();
85 init_cols(); 81 init_cols();
86 82
diff --git a/keyboards/handwired/promethium/matrix.c b/keyboards/handwired/promethium/matrix.c
index 3b8e5af82..b4a4c6396 100644
--- a/keyboards/handwired/promethium/matrix.c
+++ b/keyboards/handwired/promethium/matrix.c
@@ -104,13 +104,6 @@ uint8_t matrix_cols(void) {
104} 104}
105 105
106void matrix_init(void) { 106void matrix_init(void) {
107
108 // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
109 #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__))
110 MCUCR |= _BV(JTD);
111 MCUCR |= _BV(JTD);
112 #endif
113
114 // initialize row and col 107 // initialize row and col
115 unselect_rows(); 108 unselect_rows();
116 init_cols(); 109 init_cols();
diff --git a/keyboards/hhkb/rn42/rn42.c b/keyboards/hhkb/rn42/rn42.c
index 154da4e10..06665425c 100644
--- a/keyboards/hhkb/rn42/rn42.c
+++ b/keyboards/hhkb/rn42/rn42.c
@@ -26,10 +26,6 @@ host_driver_t rn42_driver = {
26 26
27void rn42_init(void) 27void rn42_init(void)
28{ 28{
29 // JTAG disable for PORT F. write JTD bit twice within four cycles.
30 MCUCR |= (1<<JTD);
31 MCUCR |= (1<<JTD);
32
33 // PF7: BT connection control(high: connect, low: disconnect) 29 // PF7: BT connection control(high: connect, low: disconnect)
34 rn42_autoconnect(); 30 rn42_autoconnect();
35 31
diff --git a/keyboards/hid_liber/matrix.c b/keyboards/hid_liber/matrix.c
index de154890d..05554a24c 100755
--- a/keyboards/hid_liber/matrix.c
+++ b/keyboards/hid_liber/matrix.c
@@ -172,10 +172,6 @@ uint8_t matrix_cols(void)
172 172
173void matrix_init(void) 173void matrix_init(void)
174{ 174{
175 // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
176 MCUCR |= (1<<JTD);
177 MCUCR |= (1<<JTD);
178
179 // initialize row and col 175 // initialize row and col
180 setup_io_pins(); 176 setup_io_pins();
181 setup_leds(); 177 setup_leds();
diff --git a/keyboards/hotdox/matrix.c b/keyboards/hotdox/matrix.c
index 9d3a98db2..11a1142d4 100644
--- a/keyboards/hotdox/matrix.c
+++ b/keyboards/hotdox/matrix.c
@@ -77,10 +77,6 @@ uint8_t matrix_cols(void)
77 77
78void matrix_init(void) 78void matrix_init(void)
79{ 79{
80 // disable JTAG
81 MCUCR = (1<<JTD);
82 MCUCR = (1<<JTD);
83
84 unselect_rows(); 80 unselect_rows();
85 init_cols(); 81 init_cols();
86 82
diff --git a/keyboards/launchpad/rev1/rev1.c b/keyboards/launchpad/rev1/rev1.c
index a7aec80e1..cff4edf9f 100644
--- a/keyboards/launchpad/rev1/rev1.c
+++ b/keyboards/launchpad/rev1/rev1.c
@@ -1,14 +1,9 @@
1#include "launchpad.h" 1#include "launchpad.h"
2 2
3void matrix_init_kb(void) { 3void matrix_init_kb(void) {
4
5 // JTAG disable for PORT F. write JTD bit twice within four cycles.
6 MCUCR |= (1<<JTD);
7 MCUCR |= (1<<JTD);
8
9 // Undo init of RX LED, we use that port currently 4 // Undo init of RX LED, we use that port currently
10 //DDRB &= ~(1<<0); 5 //DDRB &= ~(1<<0);
11 6
12 matrix_init_user(); 7 matrix_init_user();
13 8
14}; \ No newline at end of file 9};
diff --git a/keyboards/lets_split/sockets/sockets.h b/keyboards/lets_split/sockets/sockets.h
index 0ee93c020..a1a3f00a0 100644
--- a/keyboards/lets_split/sockets/sockets.h
+++ b/keyboards/lets_split/sockets/sockets.h
@@ -1,5 +1,4 @@
1#pragma once 1#pragma once
2#define DISABLE_JTAG // The keyboard uses PF4 and PF7, which are used by JTAG.
3 2
4#include "lets_split.h" 3#include "lets_split.h"
5 4
diff --git a/keyboards/miniaxe/config.h b/keyboards/miniaxe/config.h
index db8509717..b0b9d4c47 100644
--- a/keyboards/miniaxe/config.h
+++ b/keyboards/miniaxe/config.h
@@ -237,5 +237,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
237//#define EE_HANDS 237//#define EE_HANDS
238#define I2C_MASTER_LEFT 238#define I2C_MASTER_LEFT
239//#define I2C_MASTER_RIGHT 239//#define I2C_MASTER_RIGHT
240
241#define DISABLE_JTAG
diff --git a/keyboards/sx60/matrix.c b/keyboards/sx60/matrix.c
index e8e9d6574..58647d13b 100644
--- a/keyboards/sx60/matrix.c
+++ b/keyboards/sx60/matrix.c
@@ -113,13 +113,6 @@ uint8_t matrix_cols(void) {
113} 113}
114 114
115void matrix_init(void) { 115void matrix_init(void) {
116
117 /* To use PORTF disable JTAG with writing JTD bit twice within four cycles. */
118 #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__))
119 MCUCR |= _BV(JTD);
120 MCUCR |= _BV(JTD);
121 #endif
122
123 mcp23018_status = true; 116 mcp23018_status = true;
124 117
125 /* initialize row and col */ 118 /* initialize row and col */
diff --git a/keyboards/vitamins_included/matrix.c b/keyboards/vitamins_included/matrix.c
index 1f5071c69..d44e70f08 100644
--- a/keyboards/vitamins_included/matrix.c
+++ b/keyboards/vitamins_included/matrix.c
@@ -136,12 +136,6 @@ bool has_usb(void) {
136 136
137void matrix_init(void) 137void matrix_init(void)
138{ 138{
139#ifdef DISABLE_JTAG
140 // JTAG disable for PORT F. write JTD bit twice within four cycles.
141 MCUCR |= (1<<JTD);
142 MCUCR |= (1<<JTD);
143#endif
144
145 // initialize row and col 139 // initialize row and col
146#if (DIODE_DIRECTION == COL2ROW) 140#if (DIODE_DIRECTION == COL2ROW)
147 unselect_rows(); 141 unselect_rows();
diff --git a/keyboards/vitamins_included/rev1/rev1.h b/keyboards/vitamins_included/rev1/rev1.h
index aa5029034..ee97e09cf 100644
--- a/keyboards/vitamins_included/rev1/rev1.h
+++ b/keyboards/vitamins_included/rev1/rev1.h
@@ -1,6 +1,5 @@
1#ifndef REV1_H 1#ifndef REV1_H
2#define REV1_H 2#define REV1_H
3#define DISABLE_JTAG // The keyboard uses PF4, PF5 and PF7, which are used by JTAG.
4#define EE_HANDS // This isn't optional for the vitamins included 3#define EE_HANDS // This isn't optional for the vitamins included
5 4
6#include QMK_KEYBOARD_H 5#include QMK_KEYBOARD_H
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 85d252548..8f0257cf6 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -130,10 +130,15 @@ static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
130#endif 130#endif
131 131
132void disable_jtag(void) { 132void disable_jtag(void) {
133// To use PORTF disable JTAG with writing JTD bit twice within four cycles. 133// To use PF4-7 (PC2-5 on ATmega32A), disable JTAG by writing JTD bit twice within four cycles.
134#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__)) 134#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \
135 defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || \
136 defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
135 MCUCR |= _BV(JTD); 137 MCUCR |= _BV(JTD);
136 MCUCR |= _BV(JTD); 138 MCUCR |= _BV(JTD);
139#elif defined(__AVR_ATmega32A__)
140 MCUCSR |= _BV(JTD);
141 MCUCSR |= _BV(JTD);
137#endif 142#endif
138} 143}
139 144
@@ -184,7 +189,9 @@ void keyboard_post_init_kb(void) {
184 * FIXME: needs doc 189 * FIXME: needs doc
185 */ 190 */
186void keyboard_setup(void) { 191void keyboard_setup(void) {
192#ifndef NO_JTAG_DISABLE
187 disable_jtag(); 193 disable_jtag();
194#endif
188 matrix_setup(); 195 matrix_setup();
189 keyboard_pre_init_kb(); 196 keyboard_pre_init_kb();
190} 197}
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h
index bf8b71fb7..19f98c74e 100644
--- a/tmk_core/common/keyboard.h
+++ b/tmk_core/common/keyboard.h
@@ -57,8 +57,6 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) &&
57 .time = (timer_read() | 1) \ 57 .time = (timer_read() | 1) \
58} 58}
59 59
60void disable_jtag(void);
61
62/* it runs once at early stage of startup before keyboard_init. */ 60/* it runs once at early stage of startup before keyboard_init. */
63void keyboard_setup(void); 61void keyboard_setup(void);
64/* it runs once after initializing host side protocol, debug and MCU peripherals. */ 62/* it runs once after initializing host side protocol, debug and MCU peripherals. */