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.

64 lines
1.2 KiB

6 years ago
  1. #include "garlicboard.h"
  2. #include "led.h"
  3. void matrix_init_kb(void) {
  4. // put your keyboard start-up code here
  5. // runs once when the firmware starts up
  6. matrix_init_user();
  7. led_init_ports();
  8. };
  9. void matrix_scan_kb(void) {
  10. // put your looping keyboard code here
  11. // runs every cycle (a lot)
  12. matrix_scan_user();
  13. };
  14. void led_init_ports(void) {
  15. // * Set our LED pins as output
  16. DDRE |= (1<<6);
  17. DDRD |= (1<<3);
  18. DDRC |= (1<<6);
  19. DDRC |= (1<<7);
  20. }
  21. void led_set_kb(uint8_t usb_led) {
  22. if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  23. PORTE |= (1<<6);
  24. } else {
  25. PORTE &= ~(1<<6);
  26. }
  27. if (usb_led & (1<<USB_LED_NUM_LOCK)) {
  28. PORTD |= (1<<3);
  29. } else {
  30. PORTD &= ~(1<<3);
  31. }
  32. }
  33. uint32_t layer_state_set_kb(uint32_t state) {
  34. if (state & (1<<4)) {
  35. PORTC |= (1<<6);
  36. } else {
  37. PORTC &= ~(1<<6);
  38. }
  39. if (state & (1<<2)) {
  40. PORTC |= (1<<7);
  41. } else {
  42. PORTC &= ~(1<<7);
  43. }
  44. if (state & (1<<5)) {
  45. PORTE |= (1<<6);
  46. PORTD |= (1<<3);
  47. PORTC |= (1<<6);
  48. PORTC |= (1<<7);
  49. } else {
  50. PORTE &= ~(1<<6);
  51. PORTD &= ~(1<<3);
  52. PORTC &= ~(1<<6);
  53. PORTC &= ~(1<<7);
  54. }
  55. return state;
  56. }