rev2.c 1.3 KB

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