platform.c 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /* Copyright 2021 QMK
  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 3 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. #include "platform_deps.h"
  17. static void disable_jtag(void) {
  18. // To use PF4-7 (PC2-5 on ATmega32A), disable JTAG by writing JTD bit twice within four cycles.
  19. #if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
  20. MCUCR |= _BV(JTD);
  21. MCUCR |= _BV(JTD);
  22. #elif defined(__AVR_ATmega32A__)
  23. MCUCSR |= _BV(JTD);
  24. MCUCSR |= _BV(JTD);
  25. #endif
  26. }
  27. void platform_setup(void) {
  28. disable_jtag();
  29. }