You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

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