Keyboard firmwares for Atmel AVR and Cortex-M
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

backlight.c 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2014 Ralf Schmitt <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include <avr/io.h>
  15. #include "backlight.h"
  16. /* Backlight pin configuration
  17. *
  18. * Alphas PB1 (high)
  19. * Numeric PB2 (high)
  20. * Mod+Num PB3 (high)
  21. * Backside PD6 (high)
  22. * TopRight PD7 (low)
  23. * F-Row PE6 (high)
  24. *
  25. */
  26. void backlight_set(uint8_t level)
  27. {
  28. // Set as output.
  29. DDRB |= (1<<1) | (1<<2) | (1<<3);
  30. DDRD |= (1<<6) | (1<<7);
  31. DDRE |= (1<<6);
  32. if(level & (1<<0))
  33. {
  34. PORTB &= ~(1<<1);
  35. PORTB &= ~(1<<2);
  36. PORTB &= ~(1<<3);
  37. PORTD &= ~(1<<6);
  38. PORTD |= (1<<7);
  39. PORTE &= ~(1<<6);
  40. }
  41. else
  42. {
  43. PORTB |= (1<<1);
  44. PORTB |= (1<<2);
  45. PORTB |= (1<<3);
  46. PORTD |= (1<<6);
  47. PORTD &= ~(1<<7);
  48. PORTE |= (1<<6);
  49. }
  50. }