Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

mcp23x0817.h 2.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * mcp23xxx:
  3. * Copyright (c) 2012-2013 Gordon Henderson
  4. *
  5. * Header file for code using the MCP23x08 and 17 GPIO expander
  6. * chips.
  7. * This comes in 2 flavours: MCP230xx (08/17) which has an I2C
  8. * interface, and the MXP23Sxx (08/17) which has an SPI interface.
  9. ***********************************************************************
  10. * This file is part of wiringPi:
  11. * https://projects.drogon.net/raspberry-pi/wiringpi/
  12. *
  13. * wiringPi is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Lesser General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * wiringPi is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Lesser General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Lesser General Public
  24. * License along with wiringPi.
  25. * If not, see <http://www.gnu.org/licenses/>.
  26. ***********************************************************************
  27. */
  28. // MCP23x08 Registers
  29. #define MCP23x08_IODIR 0x00
  30. #define MCP23x08_IPOL 0x01
  31. #define MCP23x08_GPINTEN 0x02
  32. #define MCP23x08_DEFVAL 0x03
  33. #define MCP23x08_INTCON 0x04
  34. #define MCP23x08_IOCON 0x05
  35. #define MCP23x08_GPPU 0x06
  36. #define MCP23x08_INTF 0x07
  37. #define MCP23x08_INTCAP 0x08
  38. #define MCP23x08_GPIO 0x09
  39. #define MCP23x08_OLAT 0x0A
  40. // MCP23x17 Registers
  41. #define MCP23x17_IODIRA 0x00
  42. #define MCP23x17_IPOLA 0x02
  43. #define MCP23x17_GPINTENA 0x04
  44. #define MCP23x17_DEFVALA 0x06
  45. #define MCP23x17_INTCONA 0x08
  46. #define MCP23x17_IOCON 0x0A
  47. #define MCP23x17_GPPUA 0x0C
  48. #define MCP23x17_INTFA 0x0E
  49. #define MCP23x17_INTCAPA 0x10
  50. #define MCP23x17_GPIOA 0x12
  51. #define MCP23x17_OLATA 0x14
  52. #define MCP23x17_IODIRB 0x01
  53. #define MCP23x17_IPOLB 0x03
  54. #define MCP23x17_GPINTENB 0x05
  55. #define MCP23x17_DEFVALB 0x07
  56. #define MCP23x17_INTCONB 0x09
  57. #define MCP23x17_IOCONB 0x0B
  58. #define MCP23x17_GPPUB 0x0D
  59. #define MCP23x17_INTFB 0x0F
  60. #define MCP23x17_INTCAPB 0x11
  61. #define MCP23x17_GPIOB 0x13
  62. #define MCP23x17_OLATB 0x15
  63. // Bits in the IOCON register
  64. #define IOCON_UNUSED 0x01
  65. #define IOCON_INTPOL 0x02
  66. #define IOCON_ODR 0x04
  67. #define IOCON_HAEN 0x08
  68. #define IOCON_DISSLW 0x10
  69. #define IOCON_SEQOP 0x20
  70. #define IOCON_MIRROR 0x40
  71. #define IOCON_BANK_MODE 0x80
  72. // Default initialisation mode
  73. #define IOCON_INIT (IOCON_SEQOP)
  74. // SPI Command codes
  75. #define CMD_WRITE 0x40
  76. #define CMD_READ 0x41