retro_refit.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "retro_refit.h"
  2. __attribute__ ((weak))
  3. void matrix_init_user(void) {
  4. // leave this function blank - it can be defined in a keymap file
  5. };
  6. __attribute__ ((weak))
  7. void matrix_scan_user(void) {
  8. // leave this function blank - it can be defined in a keymap file
  9. };
  10. __attribute__ ((weak))
  11. void led_set_user(uint8_t usb_led) {
  12. // leave this function blank - it can be defined in a keymap file
  13. };
  14. void matrix_init_kb(void) {
  15. // put your keyboard start-up code here
  16. // runs once when the firmware starts up
  17. // Disable status LED on KB, enable status LED on Teensy (KB_STATUS = !TEENSY_STATUS)
  18. DDRD |= (1<<6);
  19. PORTD |= (1<<6);
  20. matrix_init_user();
  21. };
  22. void amatrix_scan_kb(void) {
  23. // put your looping keyboard code here
  24. // runs every cycle (a lot)
  25. matrix_scan_user();
  26. };
  27. void led_set_kb(uint8_t usb_led) {
  28. // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
  29. if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  30. // output low
  31. DDRD |= (1<<0);
  32. PORTD &= ~(1<<0);
  33. } else {
  34. // Hi-Z
  35. DDRD &= ~(1<<0);
  36. PORTD &= ~(1<<0);
  37. }
  38. if (usb_led & (1<<USB_LED_NUM_LOCK)) {
  39. // output low
  40. DDRD |= (1<<1);
  41. PORTD &= ~(1<<1);
  42. } else {
  43. // Hi-Z
  44. DDRD &= ~(1<<1);
  45. PORTD &= ~(1<<1);
  46. }
  47. if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
  48. // output low
  49. DDRC |= (1<<6);
  50. PORTC &= ~(1<<6);
  51. } else {
  52. // Hi-Z
  53. DDRC &= ~(1<<6);
  54. PORTC &= ~(1<<6);
  55. }
  56. led_set_user(usb_led);
  57. };