# Simple I2C Wrapper
## Features
- i2c master init and device management
- pin/port configuration with menuconfig
- optional c++ wrapper
## Menuconfig
```bash
idf.py menuconfig
```
### Path
Component config -> I2C
### Default Configs
| I2C | Type | Macro | Values |
| ------- | ------------ | ------------------ | -------- |
| SCL | GPIO_NUM | CONFIG_I2C_SCL_PIN | 20 |
| SDA | GPIO_NUM | CONFIG_I2C_SDA_PIN | 21 |
| Port | I2C_PORT_NUM | CONFIG_I2C_PORT | 0 |
## Installation
### IDF Component Registry
```bash
idf.py add-dependency thewesdev/i2c
```
### Github
```bash
git clone https://github.com/thewesdev/i2c components/i2c
```
## Code Examples
### C
```c
#include "i2c.h"
void app_main() {
i2c_master_init();
void *dev_handle = i2c_master_add_device(0x57, 100000);
...
}
```
### Cpp
```cpp
extern "C" void app_main() {
i2c::master::init();
void *dev_handle = i2c::master::add_device(0x57, 100000);
}
```
idf.py add-dependency "thewesdev/i2c^0.0.1"