xd75.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copyright 2017 Benjamin Kesselring
  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 2 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 "xd75.h"
  17. #define XD75_CAPSLOCK_LED 2 // B2
  18. #define XD75_GP103_LED 4 // F4
  19. #define XD75_KEYCAPS_LED 5 // F5
  20. #define XD75_GP100_LED 7 // F7
  21. void matrix_init_kb(void) {
  22. // put your keyboard start-up code here
  23. // runs once when the firmware starts up
  24. capslock_led_init();
  25. gp100_led_init();
  26. gp103_led_init();
  27. keycaps_led_init();
  28. matrix_init_user();
  29. }
  30. void matrix_scan_kb(void) {
  31. // put your looping keyboard code here
  32. // runs every cycle (a lot)
  33. matrix_scan_user();
  34. }
  35. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  36. // put your per-action keyboard code here
  37. // runs for every action, just before processing by the firmware
  38. return process_record_user(keycode, record);
  39. }
  40. void led_set_kb(uint8_t usb_led) {
  41. // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
  42. led_set_user(usb_led);
  43. }
  44. void capslock_led_init(void) {
  45. DDRB |= (1 << XD75_CAPSLOCK_LED);
  46. capslock_led_off();
  47. }
  48. void capslock_led_off(void) {
  49. PORTB |= (1 << XD75_CAPSLOCK_LED);
  50. }
  51. void capslock_led_on(void) {
  52. PORTB &= ~(1 << XD75_CAPSLOCK_LED);
  53. }
  54. void gp100_led_init(void) {
  55. DDRF |= (1 << XD75_GP100_LED);
  56. gp100_led_off();
  57. }
  58. void gp100_led_off(void) {
  59. PORTF |= (1 << XD75_GP100_LED);
  60. }
  61. void gp100_led_on(void) {
  62. PORTF &= ~(1 << XD75_GP100_LED);
  63. }
  64. void gp103_led_init(void) {
  65. DDRF |= (1 << XD75_GP103_LED);
  66. gp103_led_off();
  67. }
  68. void gp103_led_off(void) {
  69. PORTF &= ~(1 << XD75_GP103_LED);
  70. }
  71. void gp103_led_on(void) {
  72. PORTF |= (1 << XD75_GP103_LED);
  73. }
  74. void keycaps_led_init(void) {
  75. DDRF |= (1 << XD75_KEYCAPS_LED);
  76. keycaps_led_off();
  77. }
  78. void keycaps_led_off(void) {
  79. PORTF |= (1 << XD75_KEYCAPS_LED);
  80. }
  81. void keycaps_led_on(void) {
  82. PORTF &= ~(1 << XD75_KEYCAPS_LED);
  83. }