Rev 31 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
30 | jlesech | 1 | /**************************************************************************//** |
2 | * \brief MCP23008 library |
||
3 | * \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com |
||
4 | * \version 1.0 |
||
5 | * \date 20121025 |
||
6 | * |
||
7 | * This file is part of the iDreamMicro library. |
||
8 | * |
||
9 | * This library is free software: you can redistribute it and/or modify it under |
||
10 | * the terms of the GNU Lesser General Public License as published by the Free |
||
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
||
12 | * later version. |
||
13 | * |
||
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
||
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
16 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
||
17 | * details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Lesser General Public License |
||
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
||
21 | ******************************************************************************/ |
||
22 | |||
23 | /**************************************************************************//** |
||
24 | * \headerfile mcp23008.h |
||
25 | ******************************************************************************/ |
||
26 | |||
27 | #ifndef H__IDREAMMICRO__MCP23008__H |
||
28 | #define H__IDREAMMICRO__MCP23008__H |
||
29 | |||
30 | #ifdef _cplusplus |
||
31 | extern "C"{ |
||
32 | #endif |
||
33 | |||
34 | /****************************************************************************** |
||
35 | * Header file inclusions. |
||
36 | ******************************************************************************/ |
||
37 | |||
38 | #include <stdint.h> |
||
39 | |||
40 | /****************************************************************************** |
||
41 | * Public macro definitions. |
||
42 | ******************************************************************************/ |
||
43 | |||
44 | #define MCP23008__GP0 0 |
||
45 | #define MCP23008__GP1 1 |
||
46 | #define MCP23008__GP2 2 |
||
47 | #define MCP23008__GP3 3 |
||
48 | #define MCP23008__GP4 4 |
||
49 | #define MCP23008__GP5 5 |
||
50 | #define MCP23008__GP6 6 |
||
51 | #define MCP23008__GP7 7 |
||
52 | |||
53 | /****************************************************************************** |
||
54 | * Public type definitions. |
||
55 | ******************************************************************************/ |
||
56 | |||
57 | /**************************************************************************//** |
||
58 | * \enum mcp23008__directions |
||
59 | * \brief MCP23008 pin/port directions. |
||
60 | * |
||
61 | * \typedef mcp23008__direction_t |
||
62 | * \brief MCP23008 pin/port direction. |
||
63 | ******************************************************************************/ |
||
64 | typedef enum mcp23008__directions |
||
65 | { |
||
66 | MCP23008__DIRECTION__INPUT, /*!< Input. */ |
||
67 | MCP23008__DIRECTION__OUTPUT /*!< Output. */ |
||
68 | } mcp23008__direction_t; |
||
69 | |||
70 | /**************************************************************************//** |
||
71 | * \enum mcp23008__levels |
||
72 | * \brief MCP23008 GPIO levels. |
||
73 | * |
||
74 | * \typedef mcp23008__level_t |
||
75 | * \brief MCP23008 GPIO level. |
||
76 | ******************************************************************************/ |
||
77 | typedef enum mcp23008__levels |
||
78 | { |
||
79 | MCP23008__LEVEL__LOW, /*!< Low level. */ |
||
80 | MCP23008__LEVEL__HIGH /*!< High level. */ |
||
81 | } mcp23008__level_t; |
||
82 | |||
83 | /**************************************************************************//** |
||
84 | * \typedef mcp23008__gpio_t |
||
85 | * \brief |
||
86 | ******************************************************************************/ |
||
87 | typedef uint8_t mcp23008__gpio_t; |
||
88 | |||
89 | /****************************************************************************** |
||
90 | * Public function prototypes. |
||
91 | ******************************************************************************/ |
||
92 | |||
93 | /**************************************************************************//** |
||
94 | * \fn void mcp23008__initialize(uint8_t hardware_address) |
||
95 | * |
||
96 | * \brief Initialize MCP23008. |
||
97 | * |
||
98 | * \param hardware_address Hardware address defined by pins A0 to A2. |
||
99 | ******************************************************************************/ |
||
100 | void |
||
101 | mcp23008__initialize |
||
102 | ( |
||
103 | uint8_t hardware_address |
||
104 | ); |
||
105 | |||
106 | /**************************************************************************//** |
||
107 | * |
||
108 | ******************************************************************************/ |
||
109 | void |
||
110 | mcp23008__configure_pin |
||
111 | ( |
||
112 | mcp23008__gpio_t pin, |
||
113 | mcp23008__direction_t direction |
||
114 | ); |
||
115 | |||
116 | /**************************************************************************//** |
||
117 | * |
||
118 | ******************************************************************************/ |
||
119 | void |
||
120 | mcp23008__configure_port |
||
121 | ( |
||
122 | mcp23008__direction_t direction |
||
123 | ); |
||
124 | |||
125 | /**************************************************************************//** |
||
126 | * |
||
127 | ******************************************************************************/ |
||
128 | mcp23008__level_t |
||
129 | mcp23008__get_pin_level |
||
130 | ( |
||
131 | mcp23008__gpio_t pin |
||
132 | ); |
||
133 | |||
134 | /**************************************************************************//** |
||
135 | * |
||
136 | ******************************************************************************/ |
||
137 | void |
||
138 | mcp23008__set_pin_level |
||
139 | ( |
||
140 | mcp23008__gpio_t pin, |
||
141 | mcp23008__level_t level |
||
142 | ); |
||
143 | |||
144 | /**************************************************************************//** |
||
145 | * |
||
146 | ******************************************************************************/ |
||
147 | uint8_t |
||
148 | mcp23008__get_port_value |
||
149 | ( |
||
150 | void |
||
151 | ); |
||
152 | |||
153 | /**************************************************************************//** |
||
154 | * |
||
155 | ******************************************************************************/ |
||
156 | void |
||
157 | mcp23008__set_port_value |
||
158 | ( |
||
159 | uint8_t value |
||
160 | ); |
||
161 | |||
162 | #ifdef _cplusplus |
||
163 | } |
||
164 | #endif |
||
165 | |||
166 | #endif /* H__IDREAMMICRO__MCP23008__H */ |