Remove superfluous JTAG disable code (#6445)
* Remove superfluous JTAG disable code * 32A has differently named register * Accidentally some operators * 32A also has different JTAG pins * Wrap disable_jtag() in an ifndef * Document this new define * Rename the define, it conflicts with a LUFA thing Also, move the ifndef wrapping to the call in keyboard_setup()
This commit is contained in:
parent
977c316eb1
commit
f2c179de58
|
@ -184,22 +184,15 @@ Pressing any key during sleep should wake host.
|
|||
|
||||
Arduino Leonardo and micro have **ATMega32U4** and can be used for TMK, though Arduino bootloader may be a problem.
|
||||
|
||||
## Enabling JTAG
|
||||
|
||||
## Using PF4-7 Pins of USB AVR?
|
||||
You 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.
|
||||
By 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.
|
||||
|
||||
If you are using Teensy this isn't needed. Teensy is shipped with JTAGEN fuse bit unprogrammed to disable the function.
|
||||
If you would like to keep JTAG enabled, just add the following to your `config.h`:
|
||||
|
||||
See this code.
|
||||
```c
|
||||
#define NO_JTAG_DISABLE
|
||||
```
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
```
|
||||
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hbkb/matrix.c#L67
|
||||
|
||||
And read **26.5.1 MCU Control Register – MCUCR** of ATMega32U4 datasheet.
|
||||
|
||||
|
||||
## Adding LED Indicators of Lock Keys
|
||||
You need your own LED indicators for CapsLock, ScrollLock and NumLock? See this post.
|
||||
|
|
|
@ -173,23 +173,6 @@ EXTRAKEY_ENABLE = yes # 音频控制和系统控制
|
|||
|
||||
Arduino Leonardo和micro使用**ATMega32U4**,该芯片TMK可用,但Arduino的bootloader会导致问题。
|
||||
|
||||
|
||||
## 在USB AVR使用PF4-7针脚?
|
||||
你要置位MCUCR寄存器JTD位来将PF4-7设置为GPIO。这些针脚默认是JTAG功能。 像ATMega*U* or AT90USB*这样的MCU会受影响。
|
||||
|
||||
如果是用Teensy的话就不需要了。Tennsy自带JTAGEN位未编程来失能该功能。
|
||||
<!--翻译问题:上句可能有错,原文为:Teensy is shipped with JTAGEN fuse bit unprogrammed to disable the function. -->
|
||||
代码如下。
|
||||
```
|
||||
// F接口JTAG失能。在四个周期内写入两次JTD位。
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
```
|
||||
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hbkb/matrix.c#L67
|
||||
|
||||
阅读ATMega32U4的datasheet中的**26.5.1 MCU Control Register – MCUCR**。
|
||||
|
||||
|
||||
## 为锁定键添加指示灯
|
||||
你要自制CapsLock, ScrollLock 和 NumLock指示灯?见下文。
|
||||
|
||||
|
|
|
@ -63,9 +63,6 @@ void matrix_init(void)
|
|||
#ifdef UART_RGB_ENABLE
|
||||
uart_rgb_init();
|
||||
#endif
|
||||
// disable JTAG
|
||||
MCUCR = _BV(JTD);
|
||||
MCUCR = _BV(JTD);
|
||||
|
||||
// 85 REST
|
||||
DDRD |= _BV(PD7);
|
||||
|
|
|
@ -6,10 +6,6 @@ void matrix_init_kb(void) {
|
|||
// put your keyboard start-up code here
|
||||
// runs once when the firmware starts up
|
||||
matrix_init_user();
|
||||
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
};
|
||||
|
||||
void led_set_kb(uint8_t usb_led) {
|
||||
|
|
|
@ -8,10 +8,6 @@ void matrix_init_kb(void) {
|
|||
// runs once when the firmware starts up
|
||||
matrix_init_user();
|
||||
led_init_ports();
|
||||
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,10 +8,6 @@ void matrix_init_kb(void) {
|
|||
// runs once when the firmware starts up
|
||||
matrix_init_user();
|
||||
led_init_ports();
|
||||
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -77,10 +77,6 @@ uint8_t matrix_cols(void)
|
|||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// disable JTAG
|
||||
MCUCR = (1<<JTD);
|
||||
MCUCR = (1<<JTD);
|
||||
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
|
|
|
@ -104,13 +104,6 @@ uint8_t matrix_cols(void) {
|
|||
}
|
||||
|
||||
void matrix_init(void) {
|
||||
|
||||
// To use PORTF disable JTAG with writing JTD bit twice within four cycles.
|
||||
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__))
|
||||
MCUCR |= _BV(JTD);
|
||||
MCUCR |= _BV(JTD);
|
||||
#endif
|
||||
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
|
|
@ -26,10 +26,6 @@ host_driver_t rn42_driver = {
|
|||
|
||||
void rn42_init(void)
|
||||
{
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// PF7: BT connection control(high: connect, low: disconnect)
|
||||
rn42_autoconnect();
|
||||
|
||||
|
|
|
@ -172,10 +172,6 @@ uint8_t matrix_cols(void)
|
|||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// To use PORTF disable JTAG with writing JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// initialize row and col
|
||||
setup_io_pins();
|
||||
setup_leds();
|
||||
|
|
|
@ -77,10 +77,6 @@ uint8_t matrix_cols(void)
|
|||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// disable JTAG
|
||||
MCUCR = (1<<JTD);
|
||||
MCUCR = (1<<JTD);
|
||||
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
#include "launchpad.h"
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// Undo init of RX LED, we use that port currently
|
||||
//DDRB &= ~(1<<0);
|
||||
|
||||
matrix_init_user();
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
#define DISABLE_JTAG // The keyboard uses PF4 and PF7, which are used by JTAG.
|
||||
|
||||
#include "lets_split.h"
|
||||
|
||||
|
|
|
@ -237,5 +237,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
//#define EE_HANDS
|
||||
#define I2C_MASTER_LEFT
|
||||
//#define I2C_MASTER_RIGHT
|
||||
|
||||
#define DISABLE_JTAG
|
||||
|
|
|
@ -113,13 +113,6 @@ uint8_t matrix_cols(void) {
|
|||
}
|
||||
|
||||
void matrix_init(void) {
|
||||
|
||||
/* To use PORTF disable JTAG with writing JTD bit twice within four cycles. */
|
||||
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__))
|
||||
MCUCR |= _BV(JTD);
|
||||
MCUCR |= _BV(JTD);
|
||||
#endif
|
||||
|
||||
mcp23018_status = true;
|
||||
|
||||
/* initialize row and col */
|
||||
|
|
|
@ -136,12 +136,6 @@ bool has_usb(void) {
|
|||
|
||||
void matrix_init(void)
|
||||
{
|
||||
#ifdef DISABLE_JTAG
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
#endif
|
||||
|
||||
// initialize row and col
|
||||
#if (DIODE_DIRECTION == COL2ROW)
|
||||
unselect_rows();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef REV1_H
|
||||
#define REV1_H
|
||||
#define DISABLE_JTAG // The keyboard uses PF4, PF5 and PF7, which are used by JTAG.
|
||||
#define EE_HANDS // This isn't optional for the vitamins included
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
|
|
@ -130,10 +130,15 @@ static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
|
|||
#endif
|
||||
|
||||
void disable_jtag(void) {
|
||||
// To use PORTF disable JTAG with writing JTD bit twice within four cycles.
|
||||
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__))
|
||||
// To use PF4-7 (PC2-5 on ATmega32A), disable JTAG by writing JTD bit twice within four cycles.
|
||||
#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \
|
||||
defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || \
|
||||
defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
MCUCR |= _BV(JTD);
|
||||
MCUCR |= _BV(JTD);
|
||||
#elif defined(__AVR_ATmega32A__)
|
||||
MCUCSR |= _BV(JTD);
|
||||
MCUCSR |= _BV(JTD);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -184,7 +189,9 @@ void keyboard_post_init_kb(void) {
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void keyboard_setup(void) {
|
||||
#ifndef NO_JTAG_DISABLE
|
||||
disable_jtag();
|
||||
#endif
|
||||
matrix_setup();
|
||||
keyboard_pre_init_kb();
|
||||
}
|
||||
|
|
|
@ -57,8 +57,6 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) &&
|
|||
.time = (timer_read() | 1) \
|
||||
}
|
||||
|
||||
void disable_jtag(void);
|
||||
|
||||
/* it runs once at early stage of startup before keyboard_init. */
|
||||
void keyboard_setup(void);
|
||||
/* it runs once after initializing host side protocol, debug and MCU peripherals. */
|
||||
|
|
Loading…
Reference in New Issue