sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mcp23x08.h
Go to the documentation of this file.
1 /*
2  * mcp23x17:
3  * Copyright (c) 2012-2013 Gordon Henderson
4  *
5  * Header file for code using the MCP23x17 GPIO expander chip.
6  * This comes in 2 flavours: MCP23017 which has an I2C interface,
7  * an the MXP23S17 which has an SPI interface.
8  ***********************************************************************
9  * This file is part of wiringPi:
10  * https://projects.drogon.net/raspberry-pi/wiringpi/
11  *
12  * wiringPi is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * wiringPi is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with wiringPi.
24  * If not, see <http://www.gnu.org/licenses/>.
25  ***********************************************************************
26  */
27 
28 
29 // MCP23x17 Registers
30 
31 #define IODIRA 0x00
32 #define IPOLA 0x02
33 #define GPINTENA 0x04
34 #define DEFVALA 0x06
35 #define INTCONA 0x08
36 #define IOCON 0x0A
37 #define GPPUA 0x0C
38 #define INTFA 0x0E
39 #define INTCAPA 0x10
40 #define GPIOA 0x12
41 #define OLATA 0x14
42 
43 #define IODIRB 0x01
44 #define IPOLB 0x03
45 #define GPINTENB 0x05
46 #define DEFVALB 0x07
47 #define INTCONB 0x09
48 #define IOCONB 0x0B
49 #define GPPUB 0x0D
50 #define INTFB 0x0F
51 #define INTCAPB 0x11
52 #define GPIOB 0x13
53 #define OLATB 0x15
54 
55 // Bits in the IOCON register
56 
57 #define IOCON_UNUSED 0x01
58 #define IOCON_INTPOL 0x02
59 #define IOCON_ODR 0x04
60 #define IOCON_HAEN 0x08
61 #define IOCON_DISSLW 0x10
62 #define IOCON_SEQOP 0x20
63 #define IOCON_MIRROR 0x40
64 #define IOCON_BANK_MODE 0x80
65 
66 // Default initialisation mode
67 
68 #define IOCON_INIT (IOCON_SEQOP)
69 
70 // SPI Command codes
71 
72 #define CMD_WRITE 0x40
73 #define CMD_READ 0x41