rev2.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }