https://github.com/ruda/mcp23017
Library to use MCP23017 I/O Expander chip with STM32 via i2c interface
https://github.com/ruda/mcp23017
Last synced: 18 days ago
JSON representation
Library to use MCP23017 I/O Expander chip with STM32 via i2c interface
- Host: GitHub
- URL: https://github.com/ruda/mcp23017
- Owner: ruda
- License: mit
- Created: 2018-12-09T14:22:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-16T07:39:04.000Z (about 3 years ago)
- Last Synced: 2023-03-11T16:46:23.531Z (about 2 years ago)
- Language: C
- Homepage:
- Size: 1.95 KB
- Stars: 8
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.txt
- License: LICENSE
Awesome Lists containing this project
README
MCP23017 library for STM32.
Library to use MCP23017 I/O Expander chip with STM32 via i2c interface.
.---------.
GPB0<->|1 \_/ 28|<->GPA7
GPB1<->| |<->GPA6
GPB2<->| M |<->GPA5
GPB3<->| C |<->GPA4
GPB4<->| P |<->GPA3
GPB5<->| 2 |<->GPA2
GPB6<->| 3 |<->GPA1
GPB7<->| 0 |<->GPA0
VDD-->| 1 |-->INTA
VSS-->| 7 |-->INTB
NC---| |-->~RESET
SCL-->| |<--A2
SDA<->| |<--A1
NC---|14 15|<--A0
'---------'Example: Read bits from GPA then copy bits to GPB.
#include "mcp23017.h"
MCP23017_HandleTypeDef hmcp;
mcp23017_init(&hmcp, &hi2c1, MCP23017_ADDRESS_20);
mcp23017_iodir(&hmcp, MCP23017_PORTA, MCP23017_IODIR_ALL_INPUT);
mcp23017_iodir(&hmcp, MCP23017_PORTB, MCP23017_IODIR_ALL_OUTPUT);while (1) {
mcp23017_read_gpio(&hmcp, MCP23017_PORTA);
hmcp.gpio[MCP23017_PORTB] = hmcp.gpio[MCP23017_PORTA];
mcp23017_write_gpio(&hmcp, MCP23017_PORTB);
}