Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. Copyright 2014 Kai Ryu <[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/pgmspace.h>
  15. #include "ledmap.h"
  16. #ifdef LEDMAP_ENABLE
  17. static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
  18. [0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock
  19. [1] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // NumLock
  20. [2] = LEDMAP_SCROLL_LOCK | LEDMAP_BACKLIGHT, // Logo
  21. [3] = LEDMAP_BACKLIGHT, // Backlight
  22. };
  23. uint8_t ledmap_get_code(uint8_t index)
  24. {
  25. return pgm_read_byte(&ledmaps[index]);
  26. }
  27. /* LED pin configration
  28. * CapsLock: PC7
  29. * NumLock: PE6
  30. * Logo: PC6
  31. * Backlight: PB7
  32. */
  33. void ledmap_led_init(void)
  34. {
  35. DDRC |= (1<<PC7);
  36. PORTC |= (1<<PC7);
  37. DDRE |= (1<<PE6);
  38. PORTE |= (1<<PE6);
  39. DDRC |= (1<<PC6);
  40. PORTC &= ~(1<<PC6);
  41. DDRB |= (1<<PB7);
  42. PORTB &= ~(1<<PB7);
  43. }
  44. void ledmap_led_on(uint8_t index)
  45. {
  46. switch (index) {
  47. case 0:
  48. PORTC &= ~(1<<PC7);
  49. break;
  50. case 1:
  51. PORTE &= ~(1<<PE6);
  52. break;
  53. case 2:
  54. PORTC |= (1<<PC6);
  55. break;
  56. case 3:
  57. PORTB |= (1<<PB7);
  58. }
  59. }
  60. void ledmap_led_off(uint8_t index)
  61. {
  62. switch (index) {
  63. case 0:
  64. PORTC |= (1<<PC7);
  65. break;
  66. case 1:
  67. PORTE |= (1<<PE6);
  68. break;
  69. case 2:
  70. PORTC &= ~(1<<PB6);
  71. break;
  72. case 3:
  73. PORTB &= ~(1<<PB7);
  74. break;
  75. }
  76. }
  77. #endif