dactyl.h 3.0 KB

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