|
24 | 24 | _MCP23S17_IODIRA = const(0x00)
|
25 | 25 | _MCP23S17_IODIRB = const(0x01)
|
26 | 26 | _MCP23S17_IPOLA = const(0x02)
|
| 27 | +_MCP23S17_IPOLB = const(0x03) |
27 | 28 | _MCP23S17_GPINTENA = const(0x04)
|
28 | 29 | _MCP23S17_DEFVALA = const(0x06)
|
29 | 30 | _MCP23S17_INTCONA = const(0x08)
|
|
38 | 39 | _MCP23S17_INTCAPB = const(0x11)
|
39 | 40 |
|
40 | 41 | # pylint: disable=too-many-arguments
|
| 42 | +# pylint: disable=too-many-public-methods |
41 | 43 | class MCP23S17(MCP23SXX):
|
42 | 44 | """Supports MCP23S17 instance on specified SPI bus and optionally
|
43 | 45 | at the specified SPI address.
|
@@ -165,9 +167,46 @@ def get_pin(self, pin):
|
165 | 167 | """Convenience function to create an instance of the DigitalInOut class
|
166 | 168 | pointing at the specified pin of this MCP23S17 device.
|
167 | 169 | """
|
168 |
| - assert 0 <= pin <= 15 |
| 170 | + if not 0 <= pin <= 15: |
| 171 | + raise ValueError("Pin number must be 0-15.") |
169 | 172 | return DigitalInOut(pin, self)
|
170 | 173 |
|
| 174 | + @property |
| 175 | + def ipol(self): |
| 176 | + """The raw IPOL output register. Each bit represents the |
| 177 | + polarity value of the associated pin (0 = normal, 1 = inverted), assuming that |
| 178 | + pin has been configured as an input previously. |
| 179 | + """ |
| 180 | + return self._read_u16le(_MCP23S17_IPOLA) |
| 181 | + |
| 182 | + @ipol.setter |
| 183 | + def ipol(self, val): |
| 184 | + self._write_u16le(_MCP23S17_IPOLA, val) |
| 185 | + |
| 186 | + @property |
| 187 | + def ipola(self): |
| 188 | + """The raw IPOL A output register. Each bit represents the |
| 189 | + polarity value of the associated pin (0 = normal, 1 = inverted), assuming that |
| 190 | + pin has been configured as an input previously. |
| 191 | + """ |
| 192 | + return self._read_u8(_MCP23S17_IPOLA) |
| 193 | + |
| 194 | + @ipola.setter |
| 195 | + def ipola(self, val): |
| 196 | + self._write_u8(_MCP23S17_IPOLA, val) |
| 197 | + |
| 198 | + @property |
| 199 | + def ipolb(self): |
| 200 | + """The raw IPOL B output register. Each bit represents the |
| 201 | + polarity value of the associated pin (0 = normal, 1 = inverted), assuming that |
| 202 | + pin has been configured as an input previously. |
| 203 | + """ |
| 204 | + return self._read_u8(_MCP23S17_IPOLB) |
| 205 | + |
| 206 | + @ipolb.setter |
| 207 | + def ipolb(self, val): |
| 208 | + self._write_u8(_MCP23S17_IPOLB, val) |
| 209 | + |
171 | 210 | @property
|
172 | 211 | def interrupt_configuration(self):
|
173 | 212 | """The raw INTCON interrupt control register. The INTCON register
|
|
0 commit comments