dactyl.h 3.0 KB

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