Keyboard firmwares for Atmel AVR and Cortex-M
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.

kl27z_onekey.c 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. Copyright 2012 Jun Wako <[email protected]>
  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. #include "ch.h"
  15. #include "hal.h"
  16. /*
  17. * scan matrix
  18. */
  19. #include "print.h"
  20. #include "debug.h"
  21. #include "util.h"
  22. #include "wait.h"
  23. #include "matrix.h"
  24. #include "led.h"
  25. #include "keymap.h"
  26. inline
  27. uint8_t matrix_rows(void)
  28. {
  29. return MATRIX_ROWS;
  30. }
  31. inline
  32. uint8_t matrix_cols(void)
  33. {
  34. return MATRIX_COLS;
  35. }
  36. void matrix_init(void)
  37. {
  38. // internal pull-up
  39. palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_PULLUP);
  40. // LED blink
  41. palSetPadMode(GPIOD, 7, PAL_MODE_OUTPUT_PUSHPULL);
  42. palSetPad(GPIOD, 7);
  43. chThdSleepMilliseconds(200);
  44. palClearPad(GPIOD, 7);
  45. chThdSleepMilliseconds(200);
  46. palSetPad(GPIOD, 7);
  47. chThdSleepMilliseconds(200);
  48. palClearPad(GPIOD, 7);
  49. }
  50. uint8_t matrix_scan(void)
  51. {
  52. return 1;
  53. }
  54. inline
  55. bool matrix_is_on(uint8_t row, uint8_t col)
  56. {
  57. return !palReadPad(GPIOA, 4);
  58. }
  59. inline
  60. matrix_row_t matrix_get_row(uint8_t row)
  61. {
  62. return !palReadPad(GPIOA, 4);
  63. }
  64. void matrix_print(void)
  65. {
  66. }
  67. void led_set(uint8_t usb_led) {
  68. if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  69. // output high
  70. palSetPadMode(GPIOD, 7, PAL_MODE_OUTPUT_PUSHPULL);
  71. palSetPad(GPIOD, 7);
  72. } else {
  73. // Hi-Z
  74. palSetPadMode(GPIOD, 7, PAL_MODE_INPUT);
  75. }
  76. }
  77. //
  78. // Keymap
  79. //
  80. const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  81. {{KC_A}},
  82. };
  83. const action_t fn_actions[] = {
  84. };