hardware/Splitography: Disable the JTAG interface in the constructor

The ATMega32u4 chip Splitography does not have the JTAG interface disabled in
fuses, so we must do so from the firmware. Otherwise PIN_F4 - PIN_F7 would not
be usable for I/O.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/491/head
Gergely Nagy 6 years ago
parent f527591b57
commit 7b00b8b6b0
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -40,7 +40,28 @@ namespace hardware {
namespace softhruf { namespace softhruf {
class Splitography: public kaleidoscope::hardware::ATMegaKeyboard { class Splitography: public kaleidoscope::hardware::ATMegaKeyboard {
public: public:
Splitography(void) {} Splitography(void) {
/* These two lines here are the result of many hours spent chasing ghosts.
* These are great lines, and we love them dearly, for they make a set of
* pins that would otherwise be reserved for JTAG accessible from the
* firmware.
*
* Most AVR chips that get put into keyboards have the JTAG port disabled in
* fuses, but some do not. When they're used for JTAG, then no matter what
* we do in the firmware, they will not be affected. So in case JTAG is not
* disabled in fuses, we want to do that in the firmware. Luckily for us,
* that's doable, we just have to write the JTD bit into MCUCR twice within
* four cycles. These two lines do just that.
*
* For more information, see the ATMega16U4/ATMega32U4 datasheet, the
* following sections:
* - 2.2.7 (PIN Descriptions; PIN F)
* - 7.8.7 (On-chip Debug System)
* - 26.5.1 (MCU Control Register MCUCR)
*/
MCUCR |= (1 << JTD);
MCUCR |= (1 << JTD);
}
ATMEGA_KEYBOARD_CONFIG( ATMEGA_KEYBOARD_CONFIG(
ROW_PIN_LIST({ PIN_D0, PIN_D1, PIN_D2, PIN_D3 }), ROW_PIN_LIST({ PIN_D0, PIN_D1, PIN_D2, PIN_D3 }),

Loading…
Cancel
Save