Statistics
| Branch: | Revision:

ddr4s / fw / wiringPi / wiringPi / mcp23x0817.h @ 32:cadb9025f1e0

History | View | Annotate | Download (2.53 KB)

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

    
29
// MCP23x08 Registers
30
        
31
#define        MCP23x08_IODIR                0x00
32
#define        MCP23x08_IPOL                0x01
33
#define        MCP23x08_GPINTEN        0x02
34
#define        MCP23x08_DEFVAL                0x03
35
#define        MCP23x08_INTCON                0x04
36
#define        MCP23x08_IOCON                0x05
37
#define        MCP23x08_GPPU                0x06
38
#define        MCP23x08_INTF                0x07
39
#define        MCP23x08_INTCAP                0x08
40
#define        MCP23x08_GPIO                0x09
41
#define        MCP23x08_OLAT                0x0A
42

    
43
// MCP23x17 Registers
44

    
45
#define        MCP23x17_IODIRA                0x00
46
#define        MCP23x17_IPOLA                0x02
47
#define        MCP23x17_GPINTENA        0x04
48
#define        MCP23x17_DEFVALA        0x06
49
#define        MCP23x17_INTCONA        0x08
50
#define        MCP23x17_IOCON                0x0A
51
#define        MCP23x17_GPPUA                0x0C
52
#define        MCP23x17_INTFA                0x0E
53
#define        MCP23x17_INTCAPA        0x10
54
#define        MCP23x17_GPIOA                0x12
55
#define        MCP23x17_OLATA                0x14
56

    
57
#define        MCP23x17_IODIRB                0x01
58
#define        MCP23x17_IPOLB                0x03
59
#define        MCP23x17_GPINTENB        0x05
60
#define        MCP23x17_DEFVALB        0x07
61
#define        MCP23x17_INTCONB        0x09
62
#define        MCP23x17_IOCONB                0x0B
63
#define        MCP23x17_GPPUB                0x0D
64
#define        MCP23x17_INTFB                0x0F
65
#define        MCP23x17_INTCAPB        0x11
66
#define        MCP23x17_GPIOB                0x13
67
#define        MCP23x17_OLATB                0x15
68

    
69
// Bits in the IOCON register
70

    
71
#define        IOCON_UNUSED        0x01
72
#define        IOCON_INTPOL        0x02
73
#define        IOCON_ODR        0x04
74
#define        IOCON_HAEN        0x08
75
#define        IOCON_DISSLW        0x10
76
#define        IOCON_SEQOP        0x20
77
#define        IOCON_MIRROR        0x40
78
#define        IOCON_BANK_MODE        0x80
79

    
80
// Default initialisation mode
81

    
82
#define        IOCON_INIT        (IOCON_SEQOP)
83

    
84
// SPI Command codes
85

    
86
#define        CMD_WRITE        0x40
87
#define CMD_READ        0x41