This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
software:programming:i2c:shell [2017/03/07 15:02] – [Using user space via i2c] admin | software:programming:i2c:shell [2017/03/07 22:18] (current) – [References] admin | ||
---|---|---|---|
Line 6: | Line 6: | ||
</ | </ | ||
- | ==== Using user space via i2c ==== | + | ===== Setting MCP23008/ |
- | For mcp23017: | + | |
+ | ==== For mcp23008 ==== | ||
+ | <code bash> | ||
+ | # find out which i2c address the device listens to: | ||
+ | i2cdetect -y 0 | ||
+ | |||
+ | # you should find 0x20 | ||
+ | |||
+ | # Set all bits from port a to output: | ||
+ | i2cset -y 0 0x20 0x00 0x00 | ||
+ | |||
+ | # Write value to register GPIOA (0x09) oder OLATA (0x0A) | ||
+ | # For example: for bit 0, write: | ||
+ | i2cset -y 0 0x20 0x14 0x01 | ||
+ | </ | ||
+ | |||
+ | ==== For mcp23017 ==== | ||
<code bash> | <code bash> | ||
# find out which i2c address the device listens to: | # find out which i2c address the device listens to: | ||
Line 21: | Line 37: | ||
i2cset -y 0 0x20 0x14 0x01 | i2cset -y 0 0x20 0x14 0x01 | ||
</ | </ | ||
+ | |||
+ | ==== Hardware detection ==== | ||
+ | Color table: | ||
+ | ^ Bit ^ mcp23008 ^ mcp23017 ^ | ||
+ | | 1 | L_GRN | ||
+ | | 2 | L_BLU | ||
+ | | 4 | L_RED | ||
+ | | 8 | R_BLU | ||
+ | | 16 | R_GRN | ||
+ | | 32 | R_RED | ||
+ | | 64 | WHITE | ||
+ | | 128 | HEATR | ||
+ | |||
+ | <code bash> | ||
+ | # Detection for mcp23017: | ||
+ | i2cset -y 0 0x20 0x00 0x00 | ||
+ | i2cset -y 0 0x20 0x14 0x01 | ||
+ | i2cget -y 0 0x20 0x14 | ||
+ | |||
+ | # should give 0x01 on mcp23017 and 0x00 on mcp23008 | ||
+ | </ | ||
+ | |||
+ | ===== References ===== | ||
+ | * [[http:// |