clueboard2.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "clueboard2.h"
  2. void matrix_init_kb(void) {
  3. // put your keyboard start-up code here
  4. // runs once when the firmware starts up
  5. matrix_init_user();
  6. led_init_ports();
  7. // JTAG disable for PORT F. write JTD bit twice within four cycles.
  8. MCUCR |= (1<<JTD);
  9. MCUCR |= (1<<JTD);
  10. };
  11. void led_init_ports() {
  12. // * Set our LED pins as output
  13. DDRB |= (1<<4);
  14. }
  15. void led_set_kb(uint8_t usb_led) {
  16. if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  17. // Turn capslock on
  18. PORTB |= (1<<4);
  19. } else {
  20. // Turn capslock off
  21. PORTB &= ~(1<<4);
  22. }
  23. }
  24. /* Clueboard 2.0 LED locations:
  25. *
  26. * Capslock: B4, pull high to turn on
  27. * LCtrl: Shared with Capslock, DO NOT INSTALL LED'S IN BOTH
  28. * Page Up: B7, pull high to turn on
  29. * Escape: D6, pull high to turn on
  30. * Arrows: D4, pull high to turn on
  31. */
  32. void backlight_init_ports(void) {
  33. print("init_backlight_pin()\n");
  34. // Set our LED pins as output
  35. DDRD |= (1<<6); // Esc
  36. DDRB |= (1<<7); // Page Up
  37. DDRD |= (1<<4); // Arrows
  38. // Set our LED pins low
  39. PORTD &= ~(1<<6); // Esc
  40. PORTB &= ~(1<<7); // Page Up
  41. PORTD &= ~(1<<4); // Arrows
  42. }
  43. void backlight_set(uint8_t level) {
  44. if ( level == 0 ) {
  45. // Turn off light
  46. PORTD |= (1<<6); // Esc
  47. PORTB |= (1<<7); // Page Up
  48. PORTD |= (1<<4); // Arrows
  49. } else {
  50. // Turn on light
  51. PORTD &= ~(1<<6); // Esc
  52. PORTB &= ~(1<<7); // Page Up
  53. PORTD &= ~(1<<4); // Arrows
  54. }
  55. }