]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/handwired/dactyl/dactyl.h
Handwired/Dactyl refactor and Configurator support (#3222)
[qmk_firmware.git] / keyboards / handwired / dactyl / dactyl.h
1 #ifndef DACTYL_H
2 #define DACTYL_H
3
4 #include "quantum.h"
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include "i2cmaster.h"
8 #include <util/delay.h>
9
10 #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
11 #define CPU_16MHz       0x00
12
13 #define I2C_ADDR        0b0100000
14 #define I2C_ADDR_WRITE  ( (I2C_ADDR<<1) | I2C_WRITE )
15 #define I2C_ADDR_READ   ( (I2C_ADDR<<1) | I2C_READ  )
16 #define IODIRA          0x00            // i/o direction register
17 #define IODIRB          0x01
18 #define GPPUA           0x0C            // GPIO pull-up resistor register
19 #define GPPUB           0x0D
20 #define GPIOA           0x12            // general purpose i/o port register (write modifies OLAT)
21 #define GPIOB           0x13
22 #define OLATA           0x14            // output latch register
23 #define OLATB           0x15
24
25 extern uint8_t expander_status;
26 extern uint8_t expander_input_pin_mask;
27 extern bool i2c_initialized;
28
29 void init_dactyl(void);
30 void init_expander(void);
31
32 /*
33  *   LEFT HAND: LINES 38-45
34  *  RIGHT HAND: LINES 47-54
35  */
36 #define LAYOUT_dactyl(                                                  \
37                                                                         \
38     k00,k01,k02,k03,k04,k05,                                            \
39     k10,k11,k12,k13,k14,k15,                                            \
40     k20,k21,k22,k23,k24,k25,                                            \
41     k30,k31,k32,k33,k34,k35,                                            \
42     k40,k41,k42,k43,k44,                                                \
43                             k55,k50,                                    \
44                                 k54,                                    \
45                         k53,k52,k51,                                    \
46                                                                         \
47             k06,k07,k08,k09,k0A,k0B,                                    \
48             k16,k17,k18,k19,k1A,k1B,                                    \
49             k26,k27,k28,k29,k2A,k2B,                                    \
50             k36,k37,k38,k39,k3A,k3B,                                    \
51                 k47,k48,k49,k4A,k4B,                                    \
52     k5B,k56,                                                            \
53     k57,                                                                \
54     k5A,k59,k58 )                                                       \
55                                                                         \
56    /* matrix positions */                                               \
57    {                                                                    \
58     { k00, k01, k02, k03, k04, k05,     k06, k07, k08, k09, k0A, k0B }, \
59     { k10, k11, k12, k13, k14, k15,     k16, k17, k18, k19, k1A, k1B }, \
60     { k20, k21, k22, k23, k24, k25,     k26, k27, k28, k29, k2A, k2B }, \
61     { k30, k31, k32, k33, k34, k35,     k36, k37, k38, k39, k3A, k3B }, \
62     { k40, k41, k42, k43, k44, KC_NO, KC_NO, k47, k48, k49, k4A, k4B }, \
63     { k50, k51, k52, k53, k54, k55,     k56, k57, k58, k59, k5A, k5B }, \
64    }
65
66
67 #endif