您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Copyright 2013,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/io.h>
  15. #include "led_matrix.h"
  16. #ifdef LED_MATRIX_ENABLE
  17. #if defined(GH60_REV_CNY)
  18. /* LED Column pin configuration
  19. * pin: F0 F1 E6 C7 C6 B7 D4 B0 B1 B5 B4 D7 D6 B3 (Rev.CNY)
  20. */
  21. void led_matrix_write_cols(led_matrix_row_t cols)
  22. {
  23. (cols & (1<<0)) ? (PORTF |= (1<<PF0)) : (PORTF &= ~(1<<PF0));
  24. (cols & (1<<1)) ? (PORTF |= (1<<PF1)) : (PORTF &= ~(1<<PF1));
  25. (cols & (1<<2)) ? (PORTE |= (1<<PE6)) : (PORTE &= ~(1<<PE6));
  26. (cols & (1<<3)) ? (PORTC |= (1<<PC7)) : (PORTC &= ~(1<<PC7));
  27. (cols & (1<<4)) ? (PORTC |= (1<<PC6)) : (PORTC &= ~(1<<PC6));
  28. (cols & (1<<5)) ? (PORTB |= (1<<PB7)) : (PORTB &= ~(1<<PB7));
  29. (cols & (1<<6)) ? (PORTD |= (1<<PD4)) : (PORTD &= ~(1<<PD4));
  30. (cols & (1<<7)) ? (PORTB |= (1<<PB0)) : (PORTB &= ~(1<<PB0));
  31. (cols & (1<<8)) ? (PORTB |= (1<<PB1)) : (PORTB &= ~(1<<PB1));
  32. (cols & (1<<9)) ? (PORTB |= (1<<PB5)) : (PORTB &= ~(1<<PB5));
  33. (cols & (1<<10)) ? (PORTB |= (1<<PB4)) : (PORTB &= ~(1<<PB4));
  34. (cols & (1<<11)) ? (PORTD |= (1<<PD7)) : (PORTD &= ~(1<<PD7));
  35. (cols & (1<<12)) ? (PORTD |= (1<<PD6)) : (PORTD &= ~(1<<PD6));
  36. (cols & (1<<13)) ? (PORTB |= (1<<PB3)) : (PORTB &= ~(1<<PB3));
  37. }
  38. /* LED Row pin configuration
  39. * row: 0 1 2 3 4 5
  40. * pin: B6 F5 F6 F7 F4 B2
  41. */
  42. void led_matrix_unselect_rows(void)
  43. {
  44. // unselect key matrix rows
  45. //DDRD &= ~0b00101111;
  46. //PORTD &= ~0b00101111;
  47. // bit 76543210
  48. DDRB &= ~0b01000100;
  49. PORTB &= ~0b01000100;
  50. // bit 76543210
  51. DDRF &= ~0b11110000;
  52. PORTF &= ~0b11110000;
  53. }
  54. /* LED Row pin configuration
  55. * row: 0 1 2 3 4 5
  56. * pin: B6 F5 F6 F7 F4 B2
  57. */
  58. void led_matrix_select_row(uint8_t row)
  59. {
  60. switch (row) {
  61. case 0:
  62. DDRB |= (1<<PB6);
  63. PORTB |= (1<<PB6);
  64. break;
  65. case 1:
  66. DDRF |= (1<<PF5);
  67. PORTF |= (1<<PF5);
  68. break;
  69. case 2:
  70. DDRF |= (1<<PF6);
  71. PORTF |= (1<<PF6);
  72. break;
  73. case 3:
  74. DDRF |= (1<<PF7);
  75. PORTF |= (1<<PF7);
  76. break;
  77. case 4:
  78. DDRF |= (1<<PF4);
  79. PORTF |= (1<<PF4);
  80. break;
  81. case 5:
  82. DDRB |= (1<<PB2);
  83. PORTB |= (1<<PB2);
  84. break;
  85. }
  86. }
  87. #endif
  88. #endif