Advertisement
Guest User

Untitled

a guest
Mar 20th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.29 KB | None | 0 0
  1. /********************************************************************************
  2.  * In config.h
  3.  ********************************************************************************/
  4.  
  5. #define MATRIX_ROWS 5
  6. #define MATRIX_COLS 14
  7.  
  8.  
  9. /********************************************************************************
  10.  * In keymap_common.h
  11.  ********************************************************************************/
  12.  
  13. #define KEYMAP( \
  14.     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
  15.     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
  16.     K20,      K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \
  17.               K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
  18.               K42, K43, K44, K45, K46,           K49, K4A, K4B, K4C, K4D \
  19. ) { \
  20.     { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \
  21.     { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \
  22.     { KC_##K20, KC_NO,    KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \
  23.     { KC_NO,    KC_NO,    KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \
  24.     { KC_NO,    KC_NO,    KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO,    KC_NO,    KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D }  \
  25. }
  26.  
  27. /********************************************************************************
  28.  * In matrix.c
  29.  ********************************************************************************/
  30.  
  31.  
  32. static void  init_cols(void)
  33. {
  34.     // Input with pull-up(DDR:0, PORT:1)
  35.     DDRF  &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
  36.     PORTF |=  (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
  37.     // DDRE  &= ~(1<<6);
  38.     // PORTE |=  (1<<6);
  39.     DDRD  &= ~(1<<7 | 1<<3 | 1<<2 | 1<<1);
  40.     PORTD |=  (1<<7 | 1<<3 | 1<<2 | 1<<1);
  41.     DDRC  &= ~(1<<6);
  42.     PORTC |=  (1<<6);
  43.     DDRB  &= ~(1<<6 | 1<<5 | 1<<4);
  44.     PORTB |=  (1<<6 | 1<<5 | 1<<4);
  45. }
  46.  
  47. static matrix_row_t read_cols(void)
  48. {
  49.     return (PINF&(1<<0) ? 0 : (1<<0)) |
  50.            (PINF&(1<<1) ? 0 : (1<<1)) |
  51.            (PINF&(1<<4) ? 0 : (1<<2)) |
  52.            (PINF&(1<<5) ? 0 : (1<<3)) |
  53.            (PINF&(1<<6) ? 0 : (1<<4)) |
  54.            (PINF&(1<<7) ? 0 : (1<<5)) |
  55.            (PINB&(1<<6) ? 0 : (1<<6)) |
  56.            (PINB&(1<<5) ? 0 : (1<<7)) |
  57.            (PINB&(1<<4) ? 0 : (1<<8)) |     // Rev.A and B
  58.            (PIND&(1<<7) ? 0 : (1<<9)) |
  59.            (PINC&(1<<6) ? 0 : (1<<10)) |
  60.            (PIND&(1<<3) ? 0 : (1<<11)) |
  61.            (PIND&(1<<2) ? 0 : (1<<12)) |
  62.            (PIND&(1<<1) ? 0 : (1<<13));
  63. }
  64.  
  65. static void unselect_rows(void)
  66. {
  67.     // Hi-Z(DDR:0, PORT:0) to unselect
  68.     DDRB  &= ~0b10001111;
  69.     PORTB &= ~0b10001111;
  70. }
  71.  
  72. static void select_row(uint8_t row)
  73. {
  74.     // Output low(DDR:1, PORT:0) to select
  75.     switch (row) {
  76.         case 0:
  77.             DDRB  |= (1<<0);
  78.             PORTB &= ~(1<<0);
  79.             break;
  80.         case 1:
  81.             DDRB  |= (1<<1);
  82.             PORTB &= ~(1<<1);
  83.             break;
  84.         case 2:
  85.             DDRB  |= (1<<2);
  86.             PORTB &= ~(1<<2);
  87.             break;
  88.         case 3:
  89.             DDRB  |= (1<<3);
  90.             PORTB &= ~(1<<3);
  91.             break;
  92.         case 4:
  93.             DDRB  |= (1<<7);
  94.             PORTB &= ~(1<<7);
  95.             break;
  96.     }
  97.  
  98. }
  99.  
  100.  
  101. /********************************************************************************
  102.  * In keymap_poker.c
  103.  ********************************************************************************/
  104.  
  105. const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  106.     /* 0: All letter A for testing... */
  107.       KEYMAP(
  108.         A, A, A, A, A, A, A, A, A, A, A, A, A, A, \
  109.         A, A, A, A, A, A, A, A, A, A, A, A, A, A, \
  110.         A,    A, A, A, A, A, A, A, A, A, A, A, A, \
  111.               A, A, A, A, A, A, A, A, A, A, A, A, \
  112.               A, A, A, A, A,       A, A, A, A, A),
  113. };
  114. const uint16_t PROGMEM fn_actions[] = {
  115. };
  116.  
  117. /********************************************************************************
  118.  * In led.c -- I don't have an LED setup so I just set it to an unused pin
  119.  ********************************************************************************/
  120.  
  121.     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  122.         // output low
  123.         DDRD |= (1<<0);
  124.         PORTD &= ~(1<<0);
  125.     } else {
  126.         // Hi-Z
  127.         DDRD &= ~(1<<0);
  128.         PORTD &= ~(1<<0);
  129.     }
  130.  
  131.  
  132.  
  133. /********************************************************************************
  134.  * In Makefile
  135.  ********************************************************************************/
  136.  
  137. MCU = atmega32u4
  138. F_CPU = 16000000
  139. ARCH = AVR8
  140. OPT_DEFS += -DBOOTLOADER_SIZE=4096
  141.  
  142. BOOTMAGIC_ENABLE = yes  # Virtual DIP switch configuration(+1000)
  143. #MOUSEKEY_ENABLE = yes  # Mouse keys(+4700)
  144. #EXTRAKEY_ENABLE = yes  # Audio control and System control(+450)
  145. CONSOLE_ENABLE = yes    # Console for debug(+400)
  146. COMMAND_ENABLE = yes    # Commands for debug and configuration
  147. #SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
  148. NKRO_ENABLE = yes   # USB Nkey Rollover - not yet supported in LUFA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement