sp64.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright 2019 Neil Kettle
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "quantum.h"
  18. #ifdef RIGHT_HALF
  19. # include <stdint.h>
  20. # include "i2c_master.h"
  21. // I2C aliases and register addresses (see "mcp23018.md")
  22. # define I2C_ADDR 0b0100000
  23. # define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
  24. # define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
  25. # define IODIRA 0x00 // i/o direction register
  26. # define IODIRB 0x01
  27. # define GPPUA 0x0C // GPIO pull-up resistor register
  28. # define GPPUB 0x0D
  29. # define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
  30. # define GPIOB 0x13
  31. # define OLATA 0x14 // output latch register
  32. # define OLATB 0x15
  33. extern i2c_status_t mcp23018_status;
  34. # define MCP23018_I2C_TIMEOUT 100
  35. uint8_t init_mcp23018(void);
  36. #endif
  37. #define ___ KC_NO
  38. #define XXX KC_NO
  39. /* This is a shortcut to help you visually see your layout.
  40. *
  41. * The first section contains all of the arguments representing the physical
  42. * layout of the board and position of the keys.
  43. *
  44. * The second converts the arguments into a two-dimensional array which
  45. * represents the switch matrix.
  46. *
  47. * LEFT HAND RIGHT HAND
  48. * ┌-----┬-----┬-----┬-----┬-----┬-----┬-----┐ ┌-----┬-----┬-----┬-----┬-----┬-----┬----------┐
  49. * │ L00 │ L01 │ L02 │ L03 │ L04 │ L05 │ L06 │ │ R07 │ R08 │ R09 │ R0A │ R0B │ R0C │ R0D │
  50. * ├-----┴--┬--┴--┬--┴--┬--┴--┬--┴--┬--┴--┬--┘ ┌--┴--┬--┴--┬--┴--┬--┴--┬--┴--┬--┴--┬--┴--┬-------┤
  51. * │ L10 │ L11 │ L12 │ L13 │ L14 │ L15 │ │ R16 │ R17 │ R18 │ R19 │ R1A │ R1B │ R1C │ R1D │
  52. * ├--------┴┬----┴┬----┴┬----┴┬----┴┬----┴┐ └┬----┴┬----┴┬----┴┬----┴┬----┴┬----┴┬----┴-------┤
  53. * │ L20 │ L21 │ L22 │ L23 │ L24 │ L25 │ │ R26 │ R27 │ R28 │ R29 │ R2A │ R2B │ R2C │
  54. * ├---------┴┬----┴┬----┴┬----┴┬----┴┬----┴┐ └┬----┴┬----┴┬----┴┬----┴┬----┴┬----┴┬-----┬-----┤
  55. * │ L30 │ L31 │ L32 │ L33 │ L34 │ L35 │ │ R36 │ R37 │ R38 │ R39 │ R3A │ R3B │ R3C │ R3D │
  56. * ├------┬---┴-┬---┴--┬--┴-----┴----┬┴----┬┘ ┌┴-----┴-----┴--┬--┴----┬┴-----┼-----┼-----┼-----┤
  57. * │ L40 │ L41 │ L42 │ L43 │ L45 │ │ R46 │ R48 │ R4A │ R4B │ R4C │ R4D │
  58. * └------┴-----┴------┴-------------┴-----┘ └---------------┴-------┴------┴-----┴-----┴-----┘
  59. */
  60. #define LAYOUT( \
  61. L00, L01, L02, L03, L04, L05, L06, R07, R08, R09, R0A, R0B, R0C, R0D, \
  62. L10, L11, L12, L13, L14, L15, R16, R17, R18, R19, R1A, R1B, R1C, R1D, \
  63. L20, L21, L22, L23, L24, L25, R26, R27, R28, R29, R2A, R2B, R2C, \
  64. L30, L31, L32, L33, L34, L35, R36, R37, R38, R39, R3A, R3B, R3C, R3D, \
  65. L40, L41, L42, L43, L45, R46, R48, R4A, R4B, R4C, R4D \
  66. ) \
  67. /* matrix positions */ \
  68. { \
  69. { ___, ___, ___, ___, ___, ___, ___, R46, R48, R4A, R4B, R4C, R4D, R3D }, \
  70. { L40, L41, L42, L43, L45, L06, ___, R36, R37, R38, R39, R3A, R3B, R3C }, \
  71. { L30, L31, L32, L33, L34, L35, ___, R26, R27, R28, R29, R2A, R2B, R2C }, \
  72. { L20, L21, L22, L23, L24, L25, ___, R17, R18, R19, R1A, R1B, R1C, R1D }, \
  73. { L10, L11, L12, L13, L14, L15, ___, R07, R08, R09, R0A, R0B, R0C, R0D }, \
  74. { L00, L01, L02, L03, L04, L05, ___, R16, ___, ___, ___, ___, ___, ___ } \
  75. }