You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

expander.h 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright 2016 Kai Ryu <[email protected]>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef EXPANDER_H
  15. #define EXPANDER_H
  16. #include <stdint.h>
  17. #include "matrix.h"
  18. #define MCP23017
  19. #define MCP23017_A0 0
  20. #define MCP23017_A1 0
  21. #define MCP23017_A2 0
  22. #ifdef MCP23017
  23. #define EXPANDER_ADDR ((0x20|(MCP23017_A0<<0)|(MCP23017_A1<<1)|(MCP23017_A2<<2)) << 1)
  24. enum EXPANDER_REG_BANK0 {
  25. EXPANDER_REG_IODIRA = 0,
  26. EXPANDER_REG_IODIRB,
  27. EXPANDER_REG_IPOLA,
  28. EXPANDER_REG_IPOLB,
  29. EXPANDER_REG_GPINTENA,
  30. EXPANDER_REG_GPINTENB,
  31. EXPANDER_REG_DEFVALA,
  32. EXPANDER_REG_DEFVALB,
  33. EXPANDER_REG_INTCONA,
  34. EXPANDER_REG_INTCONB,
  35. EXPANDER_REG_IOCONA,
  36. EXPANDER_REG_IOCONB,
  37. EXPANDER_REG_GPPUA,
  38. EXPANDER_REG_GPPUB,
  39. EXPANDER_REG_INTFA,
  40. EXPANDER_REG_INTFB,
  41. EXPANDER_REG_INTCAPA,
  42. EXPANDER_REG_INTCAPB,
  43. EXPANDER_REG_GPIOA,
  44. EXPANDER_REG_GPIOB,
  45. EXPANDER_REG_OLATA,
  46. EXPANDER_REG_OLATB
  47. };
  48. #endif
  49. void expander_init(void);
  50. void expander_scan(void);
  51. void expander_read_cols(void);
  52. uint8_t expander_get_col(uint8_t col);
  53. matrix_row_t expander_read_row(void);
  54. void expander_unselect_rows(void);
  55. void expander_select_row(uint8_t row);
  56. #endif