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.

58 lines
1.6 KiB

  1. /*
  2. Copyright 2012 Jun Wako <wakojun@gmail.com>
  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. #pragma once
  15. /* key matrix size */
  16. #define MATRIX_ROWS 16 // keycode bit: 3-0
  17. #define MATRIX_COLS 8 // keycode bit: 6-4
  18. /* key combination for command */
  19. #define IS_COMMAND() ( \
  20. get_mods() == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) || \
  21. get_mods() == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RSFT)) \
  22. )
  23. #define XT_CLOCK_PIN D1
  24. #define XT_DATA_PIN D0
  25. #define XT_RST_PIN B7
  26. /* hard reset: low pulse for 500ms and after that HiZ for safety */
  27. #define XT_RESET() do { \
  28. gpio_write_pin_low(XT_RST_PIN); \
  29. gpio_set_pin_output(XT_RST_PIN); \
  30. wait_ms(500); \
  31. gpio_set_pin_input(XT_RST_PIN); \
  32. } while (0)
  33. /* INT1 for falling edge of clock line */
  34. #define XT_INT_INIT() do { \
  35. EICRA |= ((1 << ISC11) | (0 << ISC10)); \
  36. } while (0)
  37. /* clears flag and enables interrupt */
  38. #define XT_INT_ON() do { \
  39. EIFR |= (1 << INTF1); \
  40. EIMSK |= (1 << INT1); \
  41. } while (0)
  42. #define XT_INT_OFF() do { \
  43. EIMSK &= ~(1 << INT1); \
  44. } while (0)
  45. #define XT_INT_VECT INT1_vect